Skip to content

Commit

Permalink
[puzzle-geometry] Refactor colors into a separate file.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Oct 4, 2024
1 parent a1d5c3c commit ff9dc76
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 95 deletions.
97 changes: 2 additions & 95 deletions src/cubing/puzzle-geometry/PuzzleGeometry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Move, QuantumMove } from "../alg";
import type { KPuzzleDefinition, KTransformationData } from "../kpuzzle";
import { defaultPlatonicColorSchemes } from "./colors";
import { FaceNameSwizzler } from "./FaceNameSwizzler";
import {
FaceRenamingMapper,
Expand Down Expand Up @@ -269,100 +270,6 @@ function defaultnets(): any {
};
}

enum PGColors {
White = "#ffffff",
Orange = "#ff8000",
Green = "#44ee00",
Red = "#ff0000",
Blue = "#2266ff",
Yellow = "#f4f400",

Purple = "#8800dd",
Gray = "#aaaaaa",
Cream = "#e8d0a0",
Pink = "#ff66cc",

DarkBlue = "#0000ff",
Aqua = "#3399ff",
DarkGreen = "#008800",
Lime = "#99ff00",
DarkGray = "#5c5c5c",
Teal = "#007a89",
Brown = "#7d3b11",
Lavender = "#b9a1ff",
SeaGreen = "#5ec4b6",
VeryDarkGray = "#292929",
Burgundy = "#980000",
Cerise = "#d41f69",
}

// TODO: change this back to a const JSON definition.
function defaultcolors(): any {
return {
// the colors should use the same naming convention as the nets, above.
4: {
F: PGColors.Green,
D: PGColors.Yellow,
L: PGColors.Red,
R: PGColors.Blue,
},
6: {
U: PGColors.White,
F: PGColors.Green,
R: PGColors.Red,
D: PGColors.Yellow,
B: PGColors.Blue,
L: PGColors.Orange,
},
8: {
U: PGColors.White,
F: PGColors.Green,
R: PGColors.Red,
D: PGColors.Yellow,
BB: PGColors.Blue,
L: PGColors.Purple,
BL: PGColors.Orange,
BR: PGColors.Gray,
},
12: {
U: PGColors.White,
F: PGColors.DarkGreen,
R: PGColors.Red,
C: PGColors.Cream,
A: PGColors.Aqua,
L: PGColors.Purple,
E: PGColors.Pink,
BF: PGColors.Lime,
BR: PGColors.DarkBlue,
BL: PGColors.Yellow,
I: PGColors.Orange,
D: PGColors.Gray,
},
20: {
R: PGColors.Yellow,
C: PGColors.Cerise,
F: PGColors.DarkGreen,
E: PGColors.DarkGray,
L: PGColors.Purple,
U: PGColors.White,
A: PGColors.Teal,
G: PGColors.Red,
I: PGColors.Brown,
S: PGColors.Lavender,
H: PGColors.Aqua,
J: PGColors.SeaGreen,
B: PGColors.Green,
K: PGColors.Cream,
D: PGColors.Gray,
M: PGColors.Pink,
O: PGColors.VeryDarkGray,
P: PGColors.Orange,
N: PGColors.Burgundy,
Q: PGColors.Blue,
},
};
}

// Orientation conventions are specified here. For each of the five platonic
// solids, by face count, we have three lists of "cubie names" consisting of
// a concatenation of face names. For vertex (corner) and edge cubies, the
Expand Down Expand Up @@ -870,7 +777,7 @@ export class PuzzleGeometry {
this.baseFaceCount = baseplanes.length as BaseFaceCount;
const net = defaultnets()[baseplanes.length];
this.net = net;
this.colors = defaultcolors()[baseplanes.length];
this.colors = defaultPlatonicColorSchemes()[baseplanes.length];
if (this.options.verbosity > 0) {
console.log(`# Base planes: ${baseplanes.length}`);
}
Expand Down
93 changes: 93 additions & 0 deletions src/cubing/puzzle-geometry/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
export enum PGColors {
White = "#ffffff",
Orange = "#ff8000",
Green = "#44ee00",
Red = "#ff0000",
Blue = "#2266ff",
Yellow = "#f4f400",

Purple = "#8800dd",
Gray = "#aaaaaa",
Cream = "#e8d0a0",
Pink = "#ff66cc",

DarkBlue = "#0000ff",
Aqua = "#3399ff",
DarkGreen = "#008800",
Lime = "#99ff00",
DarkGray = "#5c5c5c",
Teal = "#007a89",
Brown = "#7d3b11",
Lavender = "#b9a1ff",
SeaGreen = "#5ec4b6",
VeryDarkGray = "#292929",
Burgundy = "#980000",
Cerise = "#d41f69",
}

// TODO: change this back to a const JSON definition.
export function defaultPlatonicColorSchemes(): any {
return {
// the colors should use the same naming convention as the nets, above.
4: {
F: PGColors.Green,
D: PGColors.Yellow,
L: PGColors.Red,
R: PGColors.Blue,
},
6: {
U: PGColors.White,
F: PGColors.Green,
R: PGColors.Red,
D: PGColors.Yellow,
B: PGColors.Blue,
L: PGColors.Orange,
},
8: {
U: PGColors.White,
F: PGColors.Green,
R: PGColors.Red,
D: PGColors.Yellow,
BB: PGColors.Blue,
L: PGColors.Purple,
BL: PGColors.Orange,
BR: PGColors.Gray,
},
12: {
U: PGColors.White,
F: PGColors.DarkGreen,
R: PGColors.Red,
C: PGColors.Cream,
A: PGColors.Aqua,
L: PGColors.Purple,
E: PGColors.Pink,
BF: PGColors.Lime,
BR: PGColors.DarkBlue,
BL: PGColors.Yellow,
I: PGColors.Orange,
D: PGColors.Gray,
},
20: {
R: PGColors.Yellow,
C: PGColors.Cerise,
F: PGColors.DarkGreen,
E: PGColors.DarkGray,
L: PGColors.Purple,
U: PGColors.White,
A: PGColors.Teal,
G: PGColors.Red,
I: PGColors.Brown,
S: PGColors.Lavender,
H: PGColors.Aqua,
J: PGColors.SeaGreen,
B: PGColors.Green,
K: PGColors.Cream,
D: PGColors.Gray,
M: PGColors.Pink,
O: PGColors.VeryDarkGray,
P: PGColors.Orange,
N: PGColors.Burgundy,
Q: PGColors.Blue,
},
};
}

0 comments on commit ff9dc76

Please sign in to comment.