Skip to content

Commit

Permalink
feat: circle is configurable option
Browse files Browse the repository at this point in the history
  • Loading branch information
peterklingelhofer committed Mar 14, 2023
1 parent 27b19e0 commit 48a15a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ enum State {
EXHALE,
POST_EXHALE,
}
enum Shape {
CIRCLE = "circle",
RECTANGLE = "rectangle",
}
const FRAMES_PER_SECOND = 60;
const BACKDROP_COLOR: Color = "#000";
const IS_CIRCULAR = true;
const calculateEndFrame = (duration: number) =>
startFrame + duration * FRAMES_PER_SECOND;
const calculateElapsed = (frames: number) =>
Expand All @@ -35,6 +38,7 @@ const ctx = canvas.getContext("2d");
const {
colorExhale = "rgb(0, 221, 255)",
colorInhale = "rgb(168, 50, 150)",
circleOrRectangle = Shape.CIRCLE,
durationExhale = 10,
durationInhale = 5,
durationPostExhale = 0,
Expand All @@ -43,6 +47,7 @@ const {
} = localStorage;

Object.assign(localStorage, {
circleOrRectangle,
durationInhale,
durationExhale,
durationPostExhale,
Expand Down Expand Up @@ -132,7 +137,7 @@ function draw(): void {
ctx.fillStyle = color;
}

if (IS_CIRCULAR) {
if (circleOrRectangle === Shape.CIRCLE) {
const centerX = canvasWidth / 2;
const centerY = canvasHeight / 2;
const startAngle = 0;
Expand Down

0 comments on commit 48a15a3

Please sign in to comment.