Difference between revisions of "Flag of Greece"

From ProgZoo
Jump to navigation Jump to search
(Created page with "<pre id='shellbody' data-qtp='canvas'></pre> <div class=qu data-width=300 data-height=200> * 300 by 200 * 5 blue stripes <pre class=usr> function drawFlag(ctx){ } </pre> <pre...")
 
 
Line 9: Line 9:
<pre class=ans>
<pre class=ans>
function drawFlag(ctx){
function drawFlag(ctx){
  let w = 300;
  let h = 200;
  ctx.fillStyle= 'white';
  ctx.fillRect(0,0,300,200);
  ctx.strokeStyle = 'blue';
  ctx.lineWidth = h / 9;
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.stroke();
  ctx.translate(0, -5*2*h/9);
  ctx.fillStyle = 'blue';
  ctx.fillRect(0,0,5*h/9,5*h/9);
  ctx.strokeStyle = 'white';
  ctx.beginPath();
  ctx.moveTo(0,5*h/9/2);
  ctx.lineTo(5*h/9,5*h/9/2);
  ctx.stroke();
}
}
</pre>
</pre>
</div>
</div>

Latest revision as of 15:44, 18 August 2021


  • 300 by 200
  • 5 blue stripes
function drawFlag(ctx){
}
function drawFlag(ctx){
  let w = 300;
  let h = 200;
  ctx.fillStyle= 'white';
  ctx.fillRect(0,0,300,200);
  ctx.strokeStyle = 'blue';
  ctx.lineWidth = h / 9;
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.moveTo(0, h/18);
  ctx.lineTo(w, h/18);
  ctx.translate(0, 2*h/9);
  ctx.stroke();
  ctx.translate(0, -5*2*h/9); 
  ctx.fillStyle = 'blue';
  ctx.fillRect(0,0,5*h/9,5*h/9);
  ctx.strokeStyle = 'white';
  ctx.beginPath();
  ctx.moveTo(0,5*h/9/2);
  ctx.lineTo(5*h/9,5*h/9/2);
  ctx.stroke();
}