0 votes
in HTML by

Write the code necessary to create a 300 pixel by 300 pixel <canvas>. Within it, paint a blue 100 pixel by 100 pixel square with the top-left corner of the square located 50 pixels from both the top and left edges of the canvas.

1 Answer

0 votes
by

Here is one simple implementation:

<canvas id="c" width="300" height="300"></canvas>

<script>
  var canvas = document.getElementById( "c" );
  var drawing_context = canvas.getContext( "2d" );
  drawing_context.fillStyle = "blue";
  drawing_context.fillRect( 50, 50, 100, 100 );
</script>

Related questions

0 votes
asked Feb 23 in HTML by DavidAnderson
0 votes
asked Feb 22, 2022 in Novice Guide to Visual Design by sharadyadav1986
...