Flags: Worked Examples
(Redirected from Worked example Benin)
Video from Panopto:
1) Benin
{{#ev:youtube|JsZafc6Y7xQ}}
- The flag is 150 by 100
- The green rectangle is 50 by 100
- The yellow and red rectangles are 100 by 50

Input
xxxxxxxxxx
function drawFlag(ctx)
{
ctx.fillStyle = 'green';
ctx.fillRect(0,0,50,100);
ctx.fillStyle = 'yellow';
ctx.fillRect(50,0,100,50);
ctx.fillStyle = 'red';
ctx.fillRect(50,50,100,50);
}
Output
function drawFlag(ctx) { ctx.fillStyle = 'green'; ctx.fillRect(0,0,50,100); ctx.fillStyle = 'yellow'; ctx.fillRect(50,0,100,50); ctx.fillStyle = 'red'; ctx.fillRect(50,50,100,50); }
function drawFlag(ctx) { ctx.fillStyle = 'green'; ctx.fillRect(0,0,50,100); ctx.fillStyle = 'yellow'; ctx.fillRect(50,0,100,50); ctx.fillStyle = 'red'; ctx.fillRect(50,50,100,50); }