Skip to content

Commit c90862f

Browse files
committed
arc fix for precision
1 parent b7a82dc commit c90862f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Processing.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8053,18 +8053,21 @@
80538053
vr = height / 2,
80548054
centerX = x + hr,
80558055
centerY = y + vr,
8056-
startLUT = 0 | (0.5 + start * p.RAD_TO_DEG * 2),
8057-
stopLUT = 0 | (0.5 + stop * p.RAD_TO_DEG * 2),
8058-
i, j;
8056+
step = (stop-start)/10,
8057+
i, angle;
8058+
80598059
if (doFill) {
80608060
// shut off stroke for a minute
80618061
var savedStroke = doStroke;
80628062
doStroke = false;
80638063
p.beginShape();
80648064
p.vertex(centerX, centerY);
8065-
for (i = startLUT; i <= stopLUT; i++) {
8066-
j = i % PConstants.SINCOS_LENGTH;
8067-
p.vertex(centerX + cosLUT[j] * hr, centerY + sinLUT[j] * vr);
8065+
for (i=0, angle; start + i*step < stop + step; i++) {
8066+
angle = start + i*step;
8067+
p.vertex(
8068+
Math.floor(centerX + Math.cos(angle) * hr),
8069+
Math.floor(centerY + Math.sin(angle) * vr)
8070+
);
80688071
}
80698072
p.endShape(PConstants.CLOSE);
80708073
doStroke = savedStroke;
@@ -8075,9 +8078,12 @@
80758078
var savedFill = doFill;
80768079
doFill = false;
80778080
p.beginShape();
8078-
for (i = startLUT; i <= stopLUT; i++) {
8079-
j = i % PConstants.SINCOS_LENGTH;
8080-
p.vertex(centerX + cosLUT[j] * hr, centerY + sinLUT[j] * vr);
8081+
for (i=0, angle; start + i*step < stop + step; i++) {
8082+
angle = start + i*step;
8083+
p.vertex(
8084+
Math.floor(centerX + Math.cos(angle) * hr),
8085+
Math.floor(centerY + Math.sin(angle) * vr)
8086+
);
80818087
}
80828088
p.endShape();
80838089
doFill = savedFill;

0 commit comments

Comments
 (0)