Skip to content

Commit

Permalink
Cycle colors rather than randomly select them
Browse files Browse the repository at this point in the history
  • Loading branch information
aboodman committed Apr 29, 2021
1 parent d42b7a2 commit 7981436
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shared/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ function key(id: string): string {
}

const colors = ["red", "blue", "white", "green", "yellow"];
let nextColor = 0;

export function randomShape() {
const s = randInt(100, 400);
const fill = colors[nextColor++];
if (nextColor == colors.length) {
nextColor = 0;
}
return {
id: newID(),
shape: {
Expand All @@ -110,7 +115,7 @@ export function randomShape() {
width: s,
height: s,
rotate: randInt(0, 359),
fill: colors[randInt(0, colors.length - 1)],
fill,
} as Shape,
};
}

0 comments on commit 7981436

Please sign in to comment.