Skip to content

Commit

Permalink
refactor: improve the size finding logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vighnesh153 committed Nov 21, 2023
1 parent 2f513c3 commit a205d85
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ export class PseudoHilbertCurveGame {
}

*start() {
const p1 = new Point(100, 100);
const p2 = new Point(100, 200);
const p3 = new Point(200, 200);
const p4 = new Point(200, 100);
const curves = generateCurve(p1, p2, p3, p4, 6);
const { width, height } = this.#canvasWrapper;
const level = 5;
const size = Math.round((height * 5) / 11);

const x1 = width / 2 - size / 2;
const x2 = x1 + size;
const y1 = height / 2 - size / 2;
const y2 = y1 + size;

const p1 = new Point(x1, y1);
const p2 = new Point(x1, y2);
const p3 = new Point(x2, y2);
const p4 = new Point(x2, y1);

const curves = generateCurve(p1, p2, p3, p4, level);
this.drawLines(curves);

yield;
Expand Down

0 comments on commit a205d85

Please sign in to comment.