Skip to content

Commit

Permalink
fix: no flashing color between states at low duration
Browse files Browse the repository at this point in the history
  • Loading branch information
peterklingelhofer committed Mar 12, 2023
1 parent 66fde3c commit 60b6f0f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ enum State {
EXHALE,
POST_EXHALE,
}
function progressState(state: State): State {
switch (state) {
case State.INHALE:
return State.POST_INHALE;
case State.POST_INHALE:
return State.EXHALE;
case State.EXHALE:
return State.POST_EXHALE;
case State.POST_EXHALE:
return State.INHALE;
}
}
const canvas = document.createElement("canvas");
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
Expand Down Expand Up @@ -59,6 +47,23 @@ const {
colorPause,
} = storedValues;

const stateAfterInhale: State =
durationPostInhale > 0 ? State.POST_INHALE : State.EXHALE;
const stateAfterExhale: State =
durationPostExhale > 0 ? State.POST_EXHALE : State.INHALE;
function progressState(state: State): State {
switch (state) {
case State.INHALE:
return stateAfterInhale;
case State.POST_INHALE:
return State.EXHALE;
case State.EXHALE:
return stateAfterExhale;
case State.POST_EXHALE:
return State.INHALE;
}
}

let state = State.INHALE;
let startFrame = 0;
let endFrame = 0;
Expand Down

0 comments on commit 60b6f0f

Please sign in to comment.