Skip to content

Commit 40f5d6a

Browse files
committed
Colors improved for arrays, other bits
1 parent 059fa08 commit 40f5d6a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Attempt at making colors for different data structure components less
2+
// crazy. We have intuitive names for a selection of colors and in the
3+
// default colour scheme these are rendered as expected (apple = red,
4+
// leaf = green, etc), but if a differnt golobal color scheme is chosen
5+
// under settings these can change (apples are not always green, etc).
6+
// Existing code has numbers (0-5) or strings ('0'-'5') and things like
7+
// selected, selected3, sorted, verRed and patched that map to different
8+
// colors (and there was/is no consistency between the mappings in 1D
9+
// arrays and 2D arrays, let alone graphs/trees).
10+
// Here we map between names for global colors and integers, that can be
11+
// used to hook into existing code without too much pain. In the
12+
// future, maybe these names should migrate into the code more plus more
13+
// colors should be added. Ideally, the mappings between different
14+
// representations should be eliminated eventually. If we want a
15+
// consistent colour for "sorted" things across different algorithms,
16+
// that can be done on top of colors, eg, define color_sorted to be a
17+
// particular named color.
18+
// Numbers (etc) are mapped back to color names in files such as
19+
// src/components/DataStructures/Array/Array1DRenderer/Array1DRenderer.module.scss
20+
// There is also a mapping from JS to HTML in files such as
21+
// src/components/DataStructures/Array/Array1DTracer.js
22+
// The colors are defined in
23+
// src/styles/global.scss
24+
25+
export const colors = {
26+
sky: 0, // (in default scheme) blue
27+
leaf: 1, // (in default scheme) green
28+
apple: 2, // (in default scheme) red
29+
peach: 3, // (in default scheme) orange
30+
// XXX add stone (grey), ink (black), darker/lighter versions of other
31+
// colors,...
32+
};
33+

0 commit comments

Comments
 (0)