Skip to content

Commit

Permalink
Color gradients for squares/circles #27
Browse files Browse the repository at this point in the history
  • Loading branch information
sonph committed Apr 23, 2020
1 parent 8f1c399 commit f72ae94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/js/viz_circles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as u from './utils.js';

export default class Circles {
constructor(canvas, options={}) {
this.canvas = canvas;
Expand Down Expand Up @@ -56,10 +58,9 @@ export default class Circles {
}

getColor(noteNumber) {
if (noteNumber == 0) {
return '#E74C3C';
}
return '#95A5A6';
return u.sprintf(
'rgb($, $, $)',
50, 150, Math.floor(255 - (255 / this.numBeats) * noteNumber));
}

/** Change how many beats per measure. */
Expand Down
9 changes: 5 additions & 4 deletions src/js/viz_squares.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as u from './utils.js';

export default class Squares {
constructor(canvas, options={}) {
this.canvas = canvas;
Expand Down Expand Up @@ -41,10 +43,9 @@ export default class Squares {
}

getColor(noteNumber) {
if (noteNumber == 0) {
return '#E74C3C';
}
return '#95A5A6';
return u.sprintf(
'rgb($, $, $)',
50, 150, Math.floor(255 - (255 / this.numBeats) * noteNumber));
}

/** Change how many beats per measure. */
Expand Down

0 comments on commit f72ae94

Please # to comment.