3 ms·
The "star"-section of the US flag: ``` // Draw 50 stars: 9 rows of alternating 6 or 5 stars ctx.fillStyle = white; for (let row = 0; row <
by qwertox 3y ago
The "star"-section of the US flag:
```
// Draw 50 stars: 9 rows of alternating 6 or 5 stars
ctx.fillStyle = white;
for (let row = 0; row < 9; row++) {
for (let col = 0; col < (row % 2 === 0 ? 6 : 5); col++) {
let x = 16 + col \* 32 + (row % 2) \* 16;
let y = 16 + row \* 32;
ctx.beginPath();
ctx.arc(x, y, 4, 0, Math.PI \* 2);
ctx.fill();
}
}
}
```
Effectively drawing circles and the rectangle which contains them is rotated right by 90° so that a section of the blue rectangle is not covered and the dots are partially above the red stripes.
At least when I input it into ChatGPT with GPT-4, that's the result.
And the rendered solution by the site has the stars offset so that some are not fully in the blue rectangle. Accurately is something different.
- deleted 3y ago[deleted]