Get canvas 2D context and draw a filled circle

This tests Canvas API coordinates and context acquisition. A strong answer selects the canvas, calls getContext("2d"), uses path functions for circles, sets color style, and fills. A red flag is ignoring the top-left origin or using SVG instead.
WHAT IT TESTS: Whether you know the imperative steps to acquire a Canvas 2D context and use path commands for shapes that are not primitives. ANSWER OUTLINE: First, select the canvas element and call getContext("2d"). Second, use path drawing functions to define the circle because only rectangles are native primitives. Third, set the color and stroke style on the context before filling the path. RED FLAG: Describing SVG or CSS instead of immediate mode canvas paths, or misplacing the top-left origin.
Read the original → developer.mozilla.org
- #typescript
- #canvas
- #web apis
- #2d context
- #frontend
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.