Road Sign Square: Difference between revisions
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
* The black square is 100, the line width is 16. | * The black square is 100, the line width is 16. | ||
* The yellow is rgb(255,227,0) | * The yellow is rgb(255,227,0) | ||
{{#ev:https://youtube.com?watch=7H-BcvEBmZ8}} | |||
<pre class=usr> | <pre class=usr> | ||
function drawFlag(ctx){ | function drawFlag(ctx){ |
Revision as of 17:05, 19 August 2021
1) Road Sign Version 1
- The yellow square has side 150, the radius of the corner is 40.
- The black square is 100, the line width is 16.
- The yellow is rgb(255,227,0)
{{#ev:https://youtube.com?watch=7H-BcvEBmZ8}}
Input
x
function drawFlag(ctx){
ctx.fillStyle = 'rgb(255,227,0)';
ctx.fillRect(0,0,150,150);
ctx.lineWidth = 16;
ctx.strokeStyle = 'black';
ctx.moveTo( 25, 25);
ctx.lineTo(125, 25);
ctx.lineTo(125,125);
ctx.lineTo( 25,125);
ctx.closePath();
ctx.stroke();
}
Output
function drawFlag(ctx){ ctx.fillStyle = 'rgb(255,227,0)'; ctx.fillRect(0,0,150,150); ctx.lineWidth = 16; ctx.strokeStyle = 'black'; ctx.moveTo( 25, 25); ctx.lineTo(125, 25); ctx.lineTo(125,125); ctx.lineTo( 25,125); ctx.closePath(); ctx.stroke(); }
function drawFlag(ctx){ ctx.fillStyle = 'rgb(255,227,0)'; ctx.fillRect(0,0,150,150); ctx.lineWidth = 16; ctx.strokeStyle = 'black'; ctx.moveTo( 25, 25); ctx.lineTo(125, 25); ctx.lineTo(125,125); ctx.lineTo( 25,125); ctx.closePath(); ctx.stroke(); }
2) Get it right
- The drawing surface is 160 y 160
- The yellow square has side 150, the radius of the corner is 20.
- The black square is 100, the line width is 16.
- The yellow is rgb(255,227,0)
Input
xxxxxxxxxx
function drawFlag(ctx){
ctx.fillStyle = 'rgb(255,227,0)';
ctx.fillRect(0,0,150,150);
ctx.lineWidth = 16;
ctx.strokeStyle = 'black';
ctx.moveTo( 25, 25);
ctx.lineTo(125, 25);
ctx.lineTo(125,125);
ctx.lineTo( 25,125);
ctx.closePath();
ctx.stroke();
}
Output
function drawFlag(ctx){ ctx.fillStyle = 'rgb(255,227,0)'; ctx.fillRect(0,0,150,150); ctx.lineWidth = 16; ctx.strokeStyle = 'black'; ctx.moveTo( 25, 25); ctx.lineTo(125, 25); ctx.lineTo(125,125); ctx.lineTo( 25,125); ctx.closePath(); ctx.stroke(); }
function drawFlag(ctx){ ctx.fillStyle = 'rgb(255,227,0)'; ctx.fillRect(0,0,150,150); ctx.lineWidth = 16; ctx.strokeStyle = 'black'; ctx.moveTo( 25, 25); ctx.lineTo(125, 25); ctx.lineTo(125,125); ctx.lineTo( 25,125); ctx.closePath(); ctx.stroke(); }