Skip to content

Commit

Permalink
Add 2 to b1 instead of 1
Browse files Browse the repository at this point in the history
I'm not sure why exactly this works, but it makes the ellipses slightly
less boxy and makes rendering ovals more consistent.
  • Loading branch information
desttinghim committed Sep 2, 2022
1 parent 05113cb commit c38bb5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtimes/native/src/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void w4_framebufferOval (int x, int y, int width, int height) {

// Error increments. Also known as the decision parameters
int dx = 4 * (1 - a) * b * b;
int dy = 4 * (b1 + 1) * a * a;
int dy = 4 * (b1 + 2) * a * a;

// Error of 1 step
int err = dx + dy + b1 * a * a;
Expand Down
4 changes: 2 additions & 2 deletions runtimes/web/src/framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class Framebuffer {
const fillColor = (dc0 - 1) & 0x3;

let a = width;
let b = height;
const b = height;
let b1 = (height + 1) % 2; // Compensates for precision loss when dividing

let north = y;
Expand All @@ -182,7 +182,7 @@ export class Framebuffer {

// Error increments. Also known as the decision parameters
let dx = 4 * (1 - a) * b * b;
let dy = 4 * (b1 + 1) * a * a;
let dy = 4 * (b1 + 2) * a * a;

// Error of 1 step
let err = dx + dy + b1 * a * a;
Expand Down

0 comments on commit c38bb5d

Please sign in to comment.