Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

HTML da Canvas yordamida qanday qilib sikl ichida davomli tarzda to'rtburchak yasasa bo'ladi.

+1 ovoz
98 marta ko‘rilgan
so‘radi 27 sentabr, 17 HunterX1 (364 bal)
<html>
<head>
<script type="text/javascript">
function labelCalc(){
    var labelW = document.getElementById('labelW').value;
    var labelL = document.getElementById('labelL').value;
    
    var minDistBottom = 2.5;
    var minDistTop = 2.5;
    var distance = 2.5;
    
    var countLVer = Math.floor( 350/(parseInt(labelL) + 2 * distance));
    var countWVer = Math.floor( 320/(parseInt(labelW) + minDistTop + minDistBottom));
    
    var countLHor = Math.floor( 350/ (parseInt(labelW) + 2*distance));
    var countWHor = Math.floor( 320/ (parseInt(labelL) + minDistTop + minDistBottom));
    
    
    var countPageVer = parseInt(countWVer) * parseInt(countLVer);
    document.getElementById('countPageVer').innerHTML = " " + parseInt(countPageVer);
    var countPageHor = parseInt(countWHor) * parseInt(countLHor);
    document.getElementById('countPageHor').innerHTML = " " + parseInt(countPageHor);
    
    var canvas, context, canvaso, contexto;
    canvaso = document.getElementById('imageView');
    context = canvaso.getContext('2d');
    
    context.lineWidth = 2;
    
    var i, j, x = 10, y = 10;
    context.strokeStyle = '#000000';
    context.strokeRect(x, y, 160, 175);
    
    var counter = 0;
    for(i = x+1.25; i <= labelW/2; i++){
        for(j=y+1.25; j <= labelL/2; j++){
            context.strokeStyle = '#000000';
            context.strokeRect(i, j, labelW/2, labelL/2);
            
        }
    }
    }
   </script>
</head>

<input type="text" id="labelW" value="" placeholder="укажите ширину">мм.

<input type="text" id="labelL" value="" placeholder="укажите длину">мм.

<button class="btn" onclick="labelCalc()">Calculate</button>
<div class="result" id="countPageHor"></div>
<div class="result" id="countPageVer"></div>
    <canvas id="imageView" width="280" height="195"></canvas>

</html>
Shunaqa ko'rinishda bo'lishi kerak deb o'ylayman.

1 ta javob

0 ovoz
javob berdi 10 noyabr, 17 HunterX1 (364 bal)
var ctx = document.getElementById('canvas').getContext('2d');

var w = parseInt(labelW)/2.3188, l = parseInt(labelL)/2.3026;

var d = 5/2.3333;

var cn=1/2.3333;

var marg = 2.5/1.3333

ctx.clearRect(0+cn,0+cn, 138, 152);

var ml = (134 - (w * countWVer))/2;

var mt = (148 - (l * countLVer))/2;

for(i=0; i<countWVer; i++){

for(j=0; j<countLVer; j++){

ctx.beginPath();

ctx.lineWidth = 1/2;

ctx.strokeRect((w+d)*i + ml,(l+d)*j + mt, w, l);

ctx.fillStyle="#998e8e";

ctx.fillRect((w+d)*i + ml, (l+d)*j + mt, w, l);

ctx.closePath();

}

}
izoh qoldirdi 19 fevral, 18 Kodirjonov (104 bal)
canvas ni o'rgatadigon kitobla bomi ??

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...