Skip to content

Commit b8bcce3

Browse files
committed
refactor: route zodiac/timeline colors through ProfileColorProperty
1 parent 31e5bc4 commit b8bcce3

8 files changed

Lines changed: 108 additions & 30 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Shared code keeps the `SolarSystemModels` prefix; per-screen code uses the
1818

1919
| File | Purpose |
2020
|---|---|
21-
| `src/SolarSystemModelsColors.ts` | All `ProfileColorProperty` instances (default + projector) |
21+
| `src/SolarSystemModelsColors.ts` | All `ProfileColorProperty` instances (default + projector profiles); includes timeline/zodiac orbit-area keys and exported `zodiacGhostBarColor()` for speed-based Ptolemaic ghosting bars |
2222
| `src/SolarSystemModelsConstants.ts` | Named numeric constants (layout px, physics SI units) |
2323
| `src/SolarSystemModelsNamespace.ts` | Namespace used by `.register()` |
2424
| `src/common/SolarSystemModelsPanel.ts` | Pre-themed `Panel` wrapper (uses `SolarSystemModelsColors`) |

src/SolarSystemModelsColors.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProfileColorProperty } from "scenerystack/scenery";
1+
import { Color, ProfileColorProperty } from "scenerystack/scenery";
22
import SolarSystemModelsNamespace from "./SolarSystemModelsNamespace.js";
33

44
const SolarSystemModelsColors = {
@@ -88,6 +88,14 @@ const SolarSystemModelsColors = {
8888
default: "#0a0a18",
8989
projector: "#edf0f5",
9090
}),
91+
configurationsOrbitAreaBackgroundColorProperty: new ProfileColorProperty(
92+
SolarSystemModelsNamespace,
93+
"configurationsOrbitAreaBackground",
94+
{
95+
default: "#060d1a",
96+
projector: "#e8ecf2",
97+
},
98+
),
9199

92100
// ── Zodiac ring decorations ────────────────────────────────────────────────
93101

@@ -107,6 +115,22 @@ const SolarSystemModelsColors = {
107115
default: "#444455",
108116
projector: "#9999bb",
109117
}),
118+
configurationsZodiacGlyphColorProperty: new ProfileColorProperty(
119+
SolarSystemModelsNamespace,
120+
"configurationsZodiacGlyph",
121+
{
122+
default: "#aaaacc",
123+
projector: "#445566",
124+
},
125+
),
126+
configurationsZodiacDividerColorProperty: new ProfileColorProperty(
127+
SolarSystemModelsNamespace,
128+
"configurationsZodiacDivider",
129+
{
130+
default: "#334455",
131+
projector: "#99aabb",
132+
},
133+
),
110134

111135
// ── Constellation decorations ──────────────────────────────────────────────
112136

@@ -136,10 +160,22 @@ const SolarSystemModelsColors = {
136160
default: "#334466",
137161
projector: "#aabbcc",
138162
}),
163+
timelineAxisColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineAxis", {
164+
default: "#1a2a44",
165+
projector: "#ccd8e8",
166+
}),
139167
timelineEventColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineEvent", {
140168
default: "#446688",
141169
projector: "#334466",
142170
}),
171+
timelineSelectedHighlightColorProperty: new ProfileColorProperty(
172+
SolarSystemModelsNamespace,
173+
"timelineSelectedHighlight",
174+
{
175+
default: "#335577aa",
176+
projector: "#8899bb88",
177+
},
178+
),
143179
timelineSelectedColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineSelected", {
144180
default: "#223355",
145181
projector: "#ccd8e8",
@@ -148,10 +184,39 @@ const SolarSystemModelsColors = {
148184
default: "#aabbcc",
149185
projector: "#334466",
150186
}),
187+
timelineDirectionLabelColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineDirectionLabel", {
188+
default: "#5577aa",
189+
projector: "#334466",
190+
}),
191+
timelineEventNameLabelColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineEventNameLabel", {
192+
default: "#99aabb",
193+
projector: "#445566",
194+
}),
195+
timelineTickLabelColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineTickLabel", {
196+
default: "#556677",
197+
projector: "#667788",
198+
}),
151199
timelineLabelColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "timelineLabel", {
152200
default: "#9999bb",
153201
projector: "#445566",
154202
}),
203+
204+
// ── Ptolemaic path trail ───────────────────────────────────────────────────
205+
206+
pathTrailLiveSegmentColorProperty: new ProfileColorProperty(SolarSystemModelsNamespace, "pathTrailLiveSegment", {
207+
default: "#ff0000",
208+
projector: "#cc0000",
209+
}),
155210
};
156211

212+
/** Ghosting bar tint from apparent zodiac-strip angular step (Flash Zodiac Strip.as). */
213+
export function zodiacGhostBarColor(deltaPx: number): Color {
214+
let factor = 1 - deltaPx / 3;
215+
if (factor < 0) {
216+
factor = 0;
217+
}
218+
const g = Math.floor(216 - 112 * factor);
219+
return new Color(21 + g, g, g);
220+
}
221+
157222
export default SolarSystemModelsColors;

src/configurations/view/ConfigurationsScreenView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ConfigurationsScreenView extends ScreenView {
6767

6868
// ── Orbit area background ───────────────────────────────────────────────
6969
const orbitAreaBg = new Rectangle(0, 0, ORBIT_AREA_SIZE, this.layoutBounds.height, {
70-
fill: "#060d1a",
70+
fill: SolarSystemModelsColors.configurationsOrbitAreaBackgroundColorProperty,
7171
});
7272
this.addChild(orbitAreaBg);
7373

src/configurations/view/ConfigurationsTimeline.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,54 @@ export class ConfigurationsTimeline extends Node {
3838

3939
const s = StringManager.getInstance().getConfigurationsStrings();
4040

41-
const bg = new Rectangle(0, 0, W, H, { fill: "#0d1117", stroke: "#334466", lineWidth: 1 });
41+
const bg = new Rectangle(0, 0, W, H, {
42+
fill: SolarSystemModelsColors.timelineBackgroundColorProperty,
43+
stroke: SolarSystemModelsColors.timelineBorderColorProperty,
44+
lineWidth: 1,
45+
});
4246
this.addChild(bg);
4347

4448
// Year-axis grid lines
45-
const axisLayer = new Path(null, { lineWidth: 1, stroke: "#1a2a44" });
49+
const axisLayer = new Path(null, {
50+
lineWidth: 1,
51+
stroke: SolarSystemModelsColors.timelineAxisColorProperty,
52+
});
4653
this.addChild(axisLayer);
4754

4855
// Event marks
49-
const eventLayer = new Path(null, { stroke: "#446688", lineWidth: 1 });
56+
const eventLayer = new Path(null, {
57+
stroke: SolarSystemModelsColors.timelineEventColorProperty,
58+
lineWidth: 1,
59+
});
5060
this.addChild(eventLayer);
5161

5262
// Selected-event highlight bar
5363
const selectedEventBg = new Rectangle(0, 0, W, 14, {
54-
fill: "#335577aa",
64+
fill: SolarSystemModelsColors.timelineSelectedHighlightColorProperty,
5565
visible: false,
5666
cornerRadius: 2,
5767
});
5868
this.addChild(selectedEventBg);
5969

6070
// Cursor line (center = current time)
6171
const cursorLine = new Path(new Shape().moveTo(0, H / 2).lineTo(W, H / 2), {
62-
stroke: "#aabbcc",
72+
stroke: SolarSystemModelsColors.timelineCursorColorProperty,
6373
lineWidth: 1.5,
6474
});
6575
this.addChild(cursorLine);
6676

6777
// Past / Future labels
6878
const pastLabel = new Text(s.timelinePastStringProperty, {
6979
font: new PhetFont({ size: 9, weight: "bold" }),
70-
fill: "#5577aa",
80+
fill: SolarSystemModelsColors.timelineDirectionLabelColorProperty,
7181
});
7282
pastLabel.right = W - 4;
7383
pastLabel.bottom = H / 2 - 3;
7484
this.addChild(pastLabel);
7585

7686
const futureLabel = new Text(s.timelineFutureStringProperty, {
7787
font: new PhetFont({ size: 9, weight: "bold" }),
78-
fill: "#5577aa",
88+
fill: SolarSystemModelsColors.timelineDirectionLabelColorProperty,
7989
});
8090
futureLabel.right = W - 4;
8191
futureLabel.top = H / 2 + 3;
@@ -84,7 +94,11 @@ export class ConfigurationsTimeline extends Node {
8494
// Event-name label pool
8595
const labelPool: Text[] = [];
8696
for (let i = 0; i < 20; i++) {
87-
const t = new Text("", { font: new PhetFont(9), fill: "#99aabb", maxWidth: W * 0.4 - 4 });
97+
const t = new Text("", {
98+
font: new PhetFont(9),
99+
fill: SolarSystemModelsColors.timelineEventNameLabelColorProperty,
100+
maxWidth: W * 0.4 - 4,
101+
});
88102
t.visible = false;
89103
labelPool.push(t);
90104
this.addChild(t);
@@ -93,7 +107,10 @@ export class ConfigurationsTimeline extends Node {
93107
// Year tick-label pool
94108
const tickPool: Text[] = [];
95109
for (let i = 0; i < 16; i++) {
96-
const t = new Text("", { font: new PhetFont(8), fill: "#556677" });
110+
const t = new Text("", {
111+
font: new PhetFont(8),
112+
fill: SolarSystemModelsColors.timelineTickLabelColorProperty,
113+
});
97114
t.visible = false;
98115
tickPool.push(t);
99116
this.addChild(t);
@@ -165,7 +182,7 @@ export class ConfigurationsTimeline extends Node {
165182
labelIdx++;
166183
}
167184
const hs = new Rectangle(0, y - 6, W * 0.4, 12, {
168-
fill: "#ffffff01",
185+
fill: "rgba(0,0,0,0)",
169186
cursor: "pointer",
170187
});
171188
hs.addInputListener(

src/configurations/view/ConfigurationsZodiacStrip.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ConfigurationsZodiacStrip extends Node {
2323
// Band background
2424
const band = new Rectangle(0, 0, STRIP_WIDTH, STRIP_HEIGHT, {
2525
fill: SolarSystemModelsColors.zodiacBandColorProperty,
26-
stroke: "#555577",
26+
stroke: SolarSystemModelsColors.zodiacBorderColorProperty,
2727
lineWidth: 1,
2828
});
2929
this.addChild(band);
@@ -33,15 +33,17 @@ export class ConfigurationsZodiacStrip extends Node {
3333
for (let i = 0; i < 12; i++) {
3434
const label = new Text(ZODIAC_GLYPHS[i] ?? "", {
3535
font: new PhetFont(14),
36-
fill: "#aaaacc",
36+
fill: SolarSystemModelsColors.configurationsZodiacGlyphColorProperty,
3737
maxWidth: segW - 2,
3838
});
3939
label.centerX = (i + 0.5) * segW;
4040
label.centerY = STRIP_HEIGHT * 0.3;
4141
this.addChild(label);
4242

4343
if (i > 0) {
44-
const divider = new Rectangle(i * segW, 0, 1, STRIP_HEIGHT, { fill: "#334455" });
44+
const divider = new Rectangle(i * segW, 0, 1, STRIP_HEIGHT, {
45+
fill: SolarSystemModelsColors.configurationsZodiacDividerColorProperty,
46+
});
4547
this.addChild(divider);
4648
}
4749
}

src/ptolemaic/view/PtolemaicPathTrail.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { PtolemaicModel } from "../model/PtolemaicModel.js";
1313
// planet's current position. This is frame-rate independent.
1414
const NUM_SEGMENTS = 20;
1515
const SAMPLING_INTERVAL = 1.5; // days
16-
const RED_SEGMENT_COLOR = "#ff0000";
1716

1817
export class PtolemaicPathTrail extends Node {
1918
private readonly mvt: ModelViewTransform2;
@@ -38,7 +37,7 @@ export class PtolemaicPathTrail extends Node {
3837
}
3938

4039
this.tempSegment = new Path(null, {
41-
stroke: RED_SEGMENT_COLOR,
40+
stroke: SolarSystemModelsColors.pathTrailLiveSegmentColorProperty,
4241
lineWidth: 1,
4342
});
4443
this.addChild(this.tempSegment);

src/ptolemaic/view/PtolemaicScreenView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class PtolemaicScreenView extends ScreenView {
6262

6363
// ── Orbital area background ────────────────────────────────────────────
6464
const orbitAreaBg = new Rectangle(0, 0, ORBIT_VIEW_CENTER_X * 2 + 20, this.layoutBounds.height, {
65-
fill: "#0a0a18",
65+
fill: SolarSystemModelsColors.orbitAreaBackgroundColorProperty,
6666
});
6767
this.addChild(orbitAreaBg);
6868

@@ -76,7 +76,7 @@ export class PtolemaicScreenView extends ScreenView {
7676
for (let i = 0; i < 12; i++) {
7777
const angle = (i * Math.PI) / 6; // 0°, 30°, 60°, ... (sign boundaries)
7878
const tick = new Path(null, {
79-
stroke: "#888899",
79+
stroke: SolarSystemModelsColors.zodiacTickColorProperty,
8080
lineWidth: 1,
8181
});
8282
const x1 = ORBIT_VIEW_CENTER_X + Math.cos(angle) * tickInnerR;
@@ -95,7 +95,7 @@ export class PtolemaicScreenView extends ScreenView {
9595
const vy = ORBIT_VIEW_CENTER_Y - Math.sin(angle) * ZODIAC_LABEL_RADIUS;
9696
const label = new Text(ZODIAC_SIGNS[i] ?? "", {
9797
font: new PhetFont(10),
98-
fill: "#aabbcc",
98+
fill: SolarSystemModelsColors.zodiacLabelColorProperty,
9999
centerX: vx,
100100
centerY: vy,
101101
maxWidth: 55,
@@ -139,7 +139,7 @@ export class PtolemaicScreenView extends ScreenView {
139139
const sunOrbitVr = ORBIT_VIEW_SCALE * PTOLEMAIC_SUN_ORBIT_RADIUS;
140140
const sunOrbitViewCenter = mvt.modelToViewPosition(Vector2.ZERO);
141141
const sunOrbitCircle = new Path(Shape.circle(sunOrbitViewCenter.x, sunOrbitViewCenter.y, sunOrbitVr), {
142-
stroke: "#333355",
142+
stroke: SolarSystemModelsColors.sunOrbitReferenceColorProperty,
143143
lineWidth: 1,
144144
});
145145
this.addChild(sunOrbitCircle);

src/ptolemaic/view/PtolemaicZodiacStrip.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Shape } from "scenerystack/kite";
22
import { Circle, Node, Path, Rectangle, Text } from "scenerystack/scenery";
33
import { PhetFont } from "scenerystack/scenery-phet";
4-
import SolarSystemModelsColors from "../../SolarSystemModelsColors.js";
4+
import SolarSystemModelsColors, { zodiacGhostBarColor } from "../../SolarSystemModelsColors.js";
55
import { ZODIAC_STRIP_HEIGHT, ZODIAC_STRIP_WIDTH } from "../../SolarSystemModelsConstants.js";
66
import type { PtolemaicModel } from "../model/PtolemaicModel.js";
77

@@ -55,13 +55,8 @@ function addBar(shape: Shape, prevX: number, curX: number, top: number, bottom:
5555
}
5656

5757
/** Ghosting bar color from the apparent angular step (Flash lines 80–86). */
58-
function speedColor(deltaPx: number): string {
59-
let factor = 1 - deltaPx / 3;
60-
if (factor < 0) {
61-
factor = 0;
62-
}
63-
const g = Math.floor(216 - 112 * factor);
64-
return `rgb(${21 + g},${g},${g})`;
58+
function speedColor(deltaPx: number) {
59+
return zodiacGhostBarColor(deltaPx);
6560
}
6661

6762
export class PtolemaicZodiacStrip extends Node {

0 commit comments

Comments
 (0)