Skip to content

Commit 2ffddaf

Browse files
fix(constants): correct mislabeled hoist names and units
Rename digit/physics constants that were tagged as layout pixels and fix copy-pasted JSDoc left by the mechanical numeric-settings hoist. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent fa1f99b commit 2ffddaf

6 files changed

Lines changed: 52 additions & 46 deletions

File tree

‎src/ElectricFieldMapperConstants.ts‎

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ export const ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS = {
8282
NUMBER_CONTROL_SLIDER_TRACK_SIZE_HEIGHT: 3,
8383
/** Checkbox box width (px). */
8484
CHECKBOX_BOX_WIDTH: 16,
85-
/** Electric field mapper number control options scale (dimensionless). */
86-
ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_SCALE: 0.75,
87-
/** Electric field mapper number control options slider padding (px). */
88-
ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_SLIDER_PADDING: 4,
89-
/** Electric field mapper number control options arrow button spacing (px). */
90-
ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_ARROW_BUTTON_SPACING: 3,
91-
/** Electric field mapper number control options vertical spacing (px). */
92-
ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_VERTICAL_SPACING: 4,
93-
/** Electric field mapper checkbox options spacing (px). */
94-
ELECTRIC_FIELD_MAPPER_CHECKBOX_OPTIONS_SPACING: 4,
85+
/** NumberControl arrow-button scale (dimensionless). */
86+
NUMBER_CONTROL_SCALE: 0.75,
87+
/** NumberControl layout slider padding (px). */
88+
NUMBER_CONTROL_SLIDER_PADDING: 4,
89+
/** NumberControl layout arrow-button spacing (px). */
90+
NUMBER_CONTROL_ARROW_BUTTON_SPACING: 3,
91+
/** NumberControl layout vertical spacing (px). */
92+
NUMBER_CONTROL_VERTICAL_SPACING: 4,
93+
/** Checkbox label spacing (px). */
94+
CHECKBOX_SPACING: 4,
9595
} as const;
9696

9797
/** Settings for common/ElectricFieldMapperPanel.ts. */
@@ -188,8 +188,8 @@ export const FIELD_PHYSICS_SETTINGS = {
188188
FIELD_NULL_STOP_SCALE: 0.002,
189189
/** Field null step fraction (dimensionless). */
190190
FIELD_NULL_STEP_FRACTION: 0.45,
191-
/** Default count (count). */
192-
DEFAULT_COUNT: 12,
191+
/** Default field lines per nanocoulomb when tracing automatic lines (lines/nC). */
192+
LINES_PER_NANOCOULOMB_DEFAULT: 12,
193193
/** Potential saturation (V). */
194194
POTENTIAL_SATURATION: 40,
195195
/** Coarse spacing used to choose an automatic voltage scale from the visible board. */
@@ -240,24 +240,31 @@ export const ELECTRIC_FIELD_SENSOR_NODE_SETTINGS = {
240240

241241
/** Settings for explore/view/ExploreScreenView.ts. */
242242
export const EXPLORE_SCREEN_VIEW_SETTINGS = {
243-
NEXT_POSITION_X: 2.8, // px
244-
NEXT_POSITION_X_FACTOR: 0.35, // dimensionless
245-
NEXT_POSITION_Y_FACTOR: 0.2, // dimensionless
246-
CONSTRUCTOR_NEXT_POSITION_Y_FACTOR: 4, // dimensionless
247-
SENSOR_X_OFFSET: 0.2, // px
243+
/** Cap on keyboard-placed charge/sensor x (m). */
244+
NEXT_POSITION_X: 2.8,
245+
/** X stagger per keyboard-placed item (m per count). */
246+
NEXT_POSITION_X_FACTOR: 0.35,
247+
/** Y stagger per keyboard-placed item (m per count). */
248+
NEXT_POSITION_Y_FACTOR: 0.2,
249+
/** Modulus wrapping the Y stagger cycle (count). */
250+
NEXT_POSITION_Y_CYCLE: 4,
251+
/** Sensor offset from a newly placed charge (m). */
252+
SENSOR_X_OFFSET: 0.2,
248253
CONSTRUCTOR_TOP_OFFSET: 6, // px
249254
CONSTRUCTOR_BOTTOM_OFFSET: 4, // px
250255

251-
FINISH_SENSOR_DRAG_MARGIN: 0.1, // px
252-
VOLTMETER_MARGIN: 0.05, // px
256+
/** Margin kept from the field edge when a sensor drag ends (m). */
257+
FINISH_SENSOR_DRAG_MARGIN: 0.1,
258+
/** Margin kept from the field edge when the voltmeter is dragged (m). */
259+
VOLTMETER_MARGIN: 0.05,
253260
PANEL_ITEM_3_SPACING: 6, // px
254261
PANEL_ITEM_16_SPACING: 6, // px
255262

256263
/** Origin view position x (px). */
257264
ORIGIN_VIEW_POSITION_X: 369,
258265
/** Origin view position y (px). */
259266
ORIGIN_VIEW_POSITION_Y: 284,
260-
/** View pixels per metre (px). */
267+
/** View pixels per metre (px/m). */
261268
VIEW_PIXELS_PER_METRE: 83,
262269
/** Toolbox item top (px). */
263270
TOOLBOX_ITEM_TOP: 21,
@@ -273,8 +280,8 @@ export const EXPLORE_SCREEN_VIEW_SETTINGS = {
273280
TAPE_ICON_SCALE: 0.8,
274281
/** Tools column spacing (px). */
275282
TOOLS_COLUMN_SPACING: 12,
276-
/** Top top (px). */
277-
TOP_TOP: 8,
283+
/** Tools column top inset (px). */
284+
TOOLS_COLUMN_TOP: 8,
278285
/** Button max width (px). */
279286
BUTTON_MAX_WIDTH: 200,
280287
/** Check max width (px). */
@@ -301,8 +308,8 @@ export const FIELD_CANVAS_NODE_SETTINGS = {
301308
VOLTAGE_CELL: 0.05,
302309
/** Spacing of the sampled field arrows (metres); samples sit midway between major grid lines. */
303310
VECTOR_SPACING: 0.5,
304-
/** Line width line width (px). */
305-
LINE_WIDTH_LINE_WIDTH: 1.8,
311+
/** Equipotential / field-line stroke width (px). */
312+
LINE_WIDTH: 1.8,
306313
/** Draw field zeros radius (px). */
307314
DRAW_FIELD_ZEROS_RADIUS: 6.5,
308315
} as const;
@@ -319,9 +326,9 @@ export const FIELD_LINES_INFO_DIALOG_SETTINGS = {
319326
export const GRID_SCALE_NODE_SETTINGS = {
320327
LABEL_MAX_WIDTH_OFFSET: 24, // px
321328

322-
/** Arrow position x (px). */
329+
/** Preferred model x of the scale arrow's top-left (m). */
323330
ARROW_POSITION_X: 2,
324-
/** Arrow position y (px). */
331+
/** Preferred model y of the scale arrow's top-left (m). */
325332
ARROW_POSITION_Y: 2.2,
326333
} as const;
327334

@@ -389,11 +396,11 @@ export const VOLTMETER_NODE_SETTINGS = {
389396

390397
/** Settings for explore/view/arrowDisplay.ts. */
391398
export const ARROW_DISPLAY_SETTINGS = {
392-
/** Linear arrow reference vm (px). */
399+
/** |E| at which a clipped-linear arrow reaches full length (V/m). */
393400
LINEAR_ARROW_REFERENCE_VM: 30,
394-
/** Linear arrow max length (count). */
401+
/** Pixel length of a clipped-linear arrow at or above the reference field (px). */
395402
LINEAR_ARROW_MAX_LENGTH: 18,
396-
/** Linear arrow min length (px). */
403+
/** Minimum pixel length of a clipped-linear arrow (px). */
397404
LINEAR_ARROW_MIN_LENGTH: 3,
398405
/** Arrow display opacity (dimensionless). */
399406
ARROW_DISPLAY_OPACITY: 0.9,
@@ -429,9 +436,10 @@ export const ELECTRIC_FIELD_MAPPER_PREFERENCES_NODE_SETTINGS = {
429436
CONSTRUCTOR_FONT_SIZE: 18,
430437
} as const;
431438

432-
/** Component dimensions in px; ratios and control steps are dimensionless; precision counts digits. */
439+
/** Defaults for public query parameter `linesPerNanocoulomb`. */
433440
export const ELECTRIC_FIELD_MAPPER_QUERY_PARAMETERS_SETTINGS = {
434-
ELECTRIC_FIELD_MAPPER_QUERY_PARAMETERS_DEFAULT_VALUE: 12, // dimensionless
441+
/** Default field lines per nanocoulomb (lines/nC). */
442+
LINES_PER_NANOCOULOMB_DEFAULT: 12,
435443
} as const;
436444

437445
/** Initial positions and dimensions for explore/model/ExploreModel.ts (m). */

‎src/common/ElectricFieldMapperControlOptions.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,12 @@ export const ELECTRIC_FIELD_MAPPER_SLIDER_OPTIONS = {
4040
export const ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS = {
4141
arrowButtonOptions: {
4242
...FLAT_RECTANGULAR_BUTTON_OPTIONS,
43-
scale: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_SCALE,
43+
scale: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.NUMBER_CONTROL_SCALE,
4444
},
4545
layoutFunction: NumberControl.createLayoutFunction4({
46-
sliderPadding:
47-
ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_SLIDER_PADDING,
48-
arrowButtonSpacing:
49-
ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_ARROW_BUTTON_SPACING,
50-
verticalSpacing:
51-
ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS_VERTICAL_SPACING,
46+
sliderPadding: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.NUMBER_CONTROL_SLIDER_PADDING,
47+
arrowButtonSpacing: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.NUMBER_CONTROL_ARROW_BUTTON_SPACING,
48+
verticalSpacing: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.NUMBER_CONTROL_VERTICAL_SPACING,
5249
}),
5350
sliderOptions: {
5451
trackSize: NUMBER_CONTROL_SLIDER_TRACK_SIZE,
@@ -69,7 +66,7 @@ export const ELECTRIC_FIELD_MAPPER_NUMBER_CONTROL_OPTIONS = {
6966
*/
7067
export const ELECTRIC_FIELD_MAPPER_CHECKBOX_OPTIONS = {
7168
boxWidth: CHECKBOX_BOX_WIDTH,
72-
spacing: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.ELECTRIC_FIELD_MAPPER_CHECKBOX_OPTIONS_SPACING,
69+
spacing: ELECTRIC_FIELD_MAPPER_CONTROL_OPTIONS_SETTINGS.CHECKBOX_SPACING,
7370
checkboxColor: ElectricFieldMapperColors.textColorProperty,
7471
checkboxColorBackground: ElectricFieldMapperColors.panelBackgroundColorProperty,
7572
} satisfies CheckboxOptions;

‎src/explore/model/FieldPhysics.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function symmetricPairFieldLines(charges: readonly Charge[], bounds: FieldBounds
299299
export function automaticFieldLines(
300300
sourceCharges: readonly Charge[],
301301
bounds: FieldBounds,
302-
count: number = FIELD_PHYSICS_SETTINGS.DEFAULT_COUNT,
302+
count: number = FIELD_PHYSICS_SETTINGS.LINES_PER_NANOCOULOMB_DEFAULT,
303303
): Point[][] {
304304
const charges = combineCoincidentCharges(sourceCharges);
305305
const symmetricLines = symmetricPairFieldLines(charges, bounds, count);

‎src/explore/view/ExploreScreenView.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
CHARGE_TOOLBOX_ICON_INSET,
3434
CHARGE_TOOLBOX_ICON_Y,
3535
CHARGE_TOOLBOX_WIDTH,
36+
EXPLORE_MODEL_SETTINGS,
3637
EXPLORE_SCREEN_VIEW_SETTINGS,
3738
GRID_SPACING_M,
3839
INFO_BUTTON_POINTER_AREA_DILATION,
@@ -135,7 +136,7 @@ export class ExploreScreenView extends ScreenView {
135136
return;
136137
}
137138
// Charges follow the pointer into the toolbox, but settle inside the field when released elsewhere.
138-
const margin = model.snapToGridProperty.value ? GRID_SPACING_M : 0.18;
139+
const margin = model.snapToGridProperty.value ? GRID_SPACING_M : EXPLORE_MODEL_SETTINGS.KEYBOARD_DRAG_MARGIN;
139140
clampToBoard(charge.positionProperty, model.fieldBoundsProperty.value, margin);
140141
if (model.snapToGridProperty.value) {
141142
const snapped = model.snapPosition(charge.positionProperty.value);
@@ -286,7 +287,7 @@ export class ExploreScreenView extends ScreenView {
286287
2,
287288
-0.6 +
288289
EXPLORE_SCREEN_VIEW_SETTINGS.NEXT_POSITION_Y_FACTOR *
289-
(count % EXPLORE_SCREEN_VIEW_SETTINGS.CONSTRUCTOR_NEXT_POSITION_Y_FACTOR),
290+
(count % EXPLORE_SCREEN_VIEW_SETTINGS.NEXT_POSITION_Y_CYCLE),
290291
),
291292
});
292293
/**
@@ -442,7 +443,7 @@ export class ExploreScreenView extends ScreenView {
442443
});
443444
const toolBoxHeight = toolsColumn.height + 16;
444445
toolsColumn.centerX = CHARGE_TOOLBOX_WIDTH / 2;
445-
toolsColumn.top = EXPLORE_SCREEN_VIEW_SETTINGS.TOP_TOP;
446+
toolsColumn.top = EXPLORE_SCREEN_VIEW_SETTINGS.TOOLS_COLUMN_TOP;
446447
toolBox = new Node({
447448
children: [
448449
new Rectangle(0, 0, CHARGE_TOOLBOX_WIDTH, toolBoxHeight, {

‎src/explore/view/FieldCanvasNode.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class FieldCanvasNode extends CanvasNode {
118118
}
119119
ctx.strokeStyle = ElectricFieldMapperColors.fieldLineColorProperty.value.toCSS();
120120
ctx.fillStyle = ctx.strokeStyle;
121-
ctx.lineWidth = FIELD_CANVAS_NODE_SETTINGS.LINE_WIDTH_LINE_WIDTH;
121+
ctx.lineWidth = FIELD_CANVAS_NODE_SETTINGS.LINE_WIDTH;
122122
const arrowheads = this.model.fieldLineArrowheadsProperty.value;
123123
for (const line of lines) {
124124
this.drawLine(ctx, line, arrowheads);
@@ -193,7 +193,7 @@ export class FieldCanvasNode extends CanvasNode {
193193

194194
private drawEquipotentials(ctx: CanvasRenderingContext2D, charges: Charges, bounds: Bounds2): void {
195195
const color = ElectricFieldMapperColors.equipotentialLineColorProperty.value.toCSS();
196-
ctx.lineWidth = FIELD_CANVAS_NODE_SETTINGS.LINE_WIDTH_LINE_WIDTH;
196+
ctx.lineWidth = FIELD_CANVAS_NODE_SETTINGS.LINE_WIDTH;
197197
ctx.font = "13px sans-serif";
198198
ctx.textAlign = "center";
199199
ctx.textBaseline = "middle";

‎src/preferences/electricFieldMapperQueryParameters.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const electricFieldMapperQueryParameters = QueryStringMachine.getAll({
2121
fieldLineArrowheads: { type: "boolean", defaultValue: true, public: true },
2222
linesPerNanocoulomb: {
2323
type: "number",
24-
defaultValue: ELECTRIC_FIELD_MAPPER_QUERY_PARAMETERS_SETTINGS.ELECTRIC_FIELD_MAPPER_QUERY_PARAMETERS_DEFAULT_VALUE,
24+
defaultValue: ELECTRIC_FIELD_MAPPER_QUERY_PARAMETERS_SETTINGS.LINES_PER_NANOCOULOMB_DEFAULT,
2525
validValues: LINES_PER_NANOCOULOMB,
2626
public: true,
2727
},

0 commit comments

Comments
 (0)