Circle drawing performance
This commit is contained in:
1 parent
953a02e3f5
commit
3354f25582
1 file changed
+2
-5
@@ -60,11 +60,8 @@ export function strokeRect(ctx, x, y, w, h, color) {
|
|||||||
|
|
||||||
export function drawCircle(ctx, x, y, r, color) {
|
export function drawCircle(ctx, x, y, r, color) {
|
||||||
for (let cy = -r; cy <= r; cy++) {
|
for (let cy = -r; cy <= r; cy++) {
|
||||||
for (let cx = -r; cx <= r; cx++) {
|
const w = Math.round(Math.sqrt(r*r - cy*cy));
|
||||||
if (cx*cx + cy*cy <= r*r + r*0.85) {
|
drawRect(ctx, x-w, y+cy, w*2, 1, color);
|
||||||
plot(ctx, x+cx, y+cy, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user