Difference between revisions of "Flags with Methods"
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
**The small flags are 75 by 50 | **The small flags are 75 by 50 | ||
**The margins are 10 | **The margins are 10 | ||
<pre class=usr> | |||
function drawFlag(ctx){ | |||
} | |||
</pre> | |||
<pre class=ans> | |||
function drawFlag(ctx){ | |||
function tri(x,y,cl){ | |||
ctx.translate(x,y); | |||
cl.forEach((c,i)=>{ | |||
ctx.fillStyle = c; | |||
ctx.fillRect(i*75/cl.length,0,75/cl.length,50); | |||
}); | |||
ctx.translate(-x,-y); | |||
} | |||
ctx.fillStyle = 'gray'; | |||
tri(10,10,['red','white','blue']); | |||
tri(95,10,['red','yellow','blue']); | |||
tri(10,70,['black','yellow','red']); | |||
tri(95,70,['green','white','green']); | |||
} | |||
</pre> | |||
</div> | |||
== Nordic cross == | |||
<div class=qu data-width=180 data-height=130> | |||
Several countries have flags that contain three colors in vertical stripes. | |||
[[Image:flagtricolour.png|left|frame|Three colour flags]] | |||
The Nordic Cross features in flags of Scandinavia | |||
Draw the flags of: | |||
* Sweden | |||
* Denmark | |||
* Finland | |||
* Östergötland | |||
* The small flags are 75 by 50. | |||
* The squares on the left are 20 by 20. | |||
* The line width is 10. | |||
<pre class=usr> | <pre class=usr> |
Revision as of 12:36, 17 August 2021
Three colours
Several countries have flags that contain three colors in vertical stripes.
Draw the flags of:
- France
- Romania
- Belgium
- Nigeria
- Sizes are:
- The small flags are 75 by 50
- The margins are 10
function drawFlag(ctx){ }
function drawFlag(ctx){ function tri(x,y,cl){ ctx.translate(x,y); cl.forEach((c,i)=>{ ctx.fillStyle = c; ctx.fillRect(i*75/cl.length,0,75/cl.length,50); }); ctx.translate(-x,-y); } ctx.fillStyle = 'gray'; tri(10,10,['red','white','blue']); tri(95,10,['red','yellow','blue']); tri(10,70,['black','yellow','red']); tri(95,70,['green','white','green']); }
Nordic cross
Several countries have flags that contain three colors in vertical stripes.
The Nordic Cross features in flags of Scandinavia
Draw the flags of:
- Sweden
- Denmark
- Finland
- Östergötland
- The small flags are 75 by 50.
- The squares on the left are 20 by 20.
- The line width is 10.
function drawFlag(ctx){ }
function drawFlag(ctx){ function tri(x,y,cl){ ctx.translate(x,y); cl.forEach((c,i)=>{ ctx.fillStyle = c; ctx.fillRect(i*75/cl.length,0,75/cl.length,50); }); ctx.translate(-x,-y); } ctx.fillStyle = 'gray'; tri(10,10,['red','white','blue']); tri(95,10,['red','yellow','blue']); tri(10,70,['black','yellow','red']); tri(95,70,['green','white','green']); }