Skip to content

Commit

Permalink
More circle drawing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
bleroy committed Dec 12, 2023
1 parent 81b5592 commit 4a4c114
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions AddAndShift/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function drawCircle(canvas, xc, yc, r,
ctx.fillStyle = "black";
const before = performance.now();

// We'll need this later... Prepare arrays to receive sine and cosine values
// as side effects of drawing a circle
const sine = [], cosine = [];

for (let i = 0; i < loops; i++) {
// This algorithm relies on the differential equation system for a circle.
// From:
Expand All @@ -61,10 +65,6 @@ function drawCircle(canvas, xc, yc, r,
let n = 0;
for (let twopown = 1; twopown < r; n++, twopown <<= 1);

// We'll need this later... Prepare arrays to receive sine and cosine values
// as side effects of drawing a circle
const sine = [], cosine = [];

// Now we can start from (r, 0) and apply the differential equations at each step
let x = r << bdp, y = 0, t = 0;
while (x >= y) { // We only need draw 1/8th of the circle, symmetries will do the rest
Expand Down

0 comments on commit 4a4c114

Please sign in to comment.