Difference between revisions of "Flags with Rectangles"
Jump to navigation
Jump to search
Tag: Reverted |
|||
Line 1: | Line 1: | ||
<pre id='shellbody' data-qtp='canvas'></pre> | <pre id='shellbody' data-qtp='canvas'></pre> | ||
==Movement in Squares== | |||
<div class='qu' data-width="240" data-height="240"> | |||
<div class='qu' data-width=" | |||
<pre class='usr'> | <pre class='usr'> | ||
function drawFlag(ctx) | function drawFlag(ctx) | ||
{ | { | ||
ctx.fillStyle = ' | ctx.fillStyle = 'white'; | ||
ctx.fillRect(0,0, | ctx.fillRect(0,0,240,240); | ||
for(let y=0;y<12;y++){ | |||
for(let x=0;x<24;x++){ | |||
if ((x+y)%2==1){ | |||
ctx.fillRect(240*x/24,240*y/12,240/24,240/12); | |||
} | |||
} | |||
} | |||
} | } | ||
</pre> | </pre> | ||
Line 23: | Line 23: | ||
ctx.fillRect(0,0,150,100); | ctx.fillRect(0,0,150,100); | ||
} | } | ||
</pre> | </pre> | ||
</div> | </div> |
Revision as of 16:32, 9 July 2023
Movement in Squares
function drawFlag(ctx) { ctx.fillStyle = 'white'; ctx.fillRect(0,0,240,240); for(let y=0;y<12;y++){ for(let x=0;x<24;x++){ if ((x+y)%2==1){ ctx.fillRect(240*x/24,240*y/12,240/24,240/12); } } } }
function drawFlag(ctx) { ctx.fillStyle = 'green'; ctx.fillRect(0,0,150,100); }