Answers Latest Version 100% Pass
What does the `canvas.getContext('2d')` method do in JavaScript graphics?
✔✔ It returns a drawing context that allows you to draw 2D graphics on the canvas.
How can you clear an entire HTML5 canvas?
✔✔ Use `context.clearRect(0, 0, canvas.width, canvas.height)`.
Which JavaScript method is used to animate graphics on a canvas?
✔✔ `requestAnimationFrame(callback)`.
How do you change the stroke color of a shape in the canvas?
✔✔ Set `context.strokeStyle` to the desired color.
What does `context.fillRect(50, 50, 100, 100)` do?
✔✔ It draws a filled rectangle at (50,50) with a width and height of 100 pixels.
1
, How do you draw a circle using the canvas API?
✔✔ Use `context.arc(x, y, radius, 0, Math.PI * 2)`.
What function starts a new path for drawing in canvas?
✔✔ `context.beginPath()`.
How can you draw a straight line on a canvas?
✔✔ Use `context.moveTo(x, y)` and `context.lineTo(x, y)`, then call `context.stroke()`.
What JavaScript object represents an HTML canvas element?
✔✔ The `HTMLCanvasElement` object.
How can you write text on a canvas?
✔✔ Use `context.fillText('Hello', x, y)`.
What property is used to set the width of lines in canvas drawings?
✔✔ `context.lineWidth`.
2