Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ export const createBezierCurve = (config: BezierCurveConfig) => {
const baseHue = p.hue(baseWeftColor);
const baseSat = p.saturation(baseWeftColor);
const baseBright = p.brightness(baseWeftColor);
// Darker start, lighter end -- luminance shift visible on any base color
const startColor = p.color(baseHue, Math.min(baseSat * 1.3, 100), baseBright * 0.55);
const endColor = p.color(baseHue, baseSat * 0.6, Math.min(baseBright * 1.4, 100));
// Subtle darker-to-lighter gradient along weft path
const startColor = p.color(baseHue, Math.min(baseSat * 1.15, 100), baseBright * 0.75);
const endColor = p.color(baseHue, baseSat * 0.8, Math.min(baseBright * 1.2, 100));
p.colorMode(p.RGB, 255);

const numSubdivisionsPerMainSegment = 15;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
const TILE_DOT_OFFSET = WEFT_DOT_SIZE + 2;
const TILE_TOGGLE_DURATION = 150; // hover preview animation duration (ms)
const TILE_GHOST_OPACITY = 130;
const RESET_BUTTON = { x: 30, y: 15, w: 60, h: 28 };
const RESET_BUTTON = { x: 30, y: 15, w: 82, h: 28 };

// Control limits
const MAX_WARP_SYSTEMS = 10;
Expand Down Expand Up @@ -451,6 +451,36 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
p.redraw();
}

// Clear only weft spline data, preserving warp structure and system assignments
function resetWeftSplines() {
editedWeftIds.clear();

for (const entity of canvasState.warpAndEdgeData) {
if (entity.type === 'warp') {
entity.topWeft = [];
entity.bottomWeft = [];
} else if (entity.type === 'edge') {
for (let i = 0; i < entity.edgeSys.length; i++) {
entity.edgeSys[i] = [];
}
entity.tileMode = new Array(entity.tileMode.length).fill(false);
}
}

canvasState.activeWeft = null;
canvasState.clickSequence = 0;
canvasState.pathsByWeft = {};
canvasState.selectedDots = [];
canvasState.hoveredDotIndex = -1;
canvasState.showDeleteButton = false;
canvasState.deleteButtonBounds = null;

rebuildRenderCache();
generateDraft();
updateCallback(canvasState);
p.redraw();
}

p.setup = function setup() {
p.createCanvas(SKETCH_CANVAS_WIDTH, SKETCH_CANVAS_HEIGHT);
p.textSize(14);
Expand Down Expand Up @@ -492,6 +522,7 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
drawDeleteButton();
drawResetButton();
drawWarpSystemBadges();
drawWarpIndexLabels();
drawWarpSystemButtons();
drawWarpCountButtons();
drawWeftSystemButtons();
Expand Down Expand Up @@ -851,7 +882,7 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
p.noStroke();
p.textAlign(p.CENTER, p.CENTER);
p.textSize(14);
p.text('Reset', RESET_BUTTON.x + RESET_BUTTON.w / 2, RESET_BUTTON.y + RESET_BUTTON.h / 2);
p.text('Reset Picks', RESET_BUTTON.x + RESET_BUTTON.w / 2, RESET_BUTTON.y + RESET_BUTTON.h / 2);
}

// ── Integrated Controls ──────────────────────────────────────
Expand Down Expand Up @@ -1067,6 +1098,21 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
}
}

function drawWarpIndexLabels() {
const { firstColumnX, spacingX } = computeBadgeLayout();
const labelY = SKETCH_CANVAS_HEIGHT - SKETCH_BOTTOM_MARGIN + 2;

p.fill(160);
p.noStroke();
p.textAlign(p.CENTER, p.TOP);
p.textSize(11);

for (let i = 0; i < effectiveNumWarps; i++) {
const cx = firstColumnX + spacingX * (i + 1);
p.text(i + 1, cx, labelY);
}
}

function isInsideResetButton(mx: number, my: number): boolean {
return mx >= RESET_BUTTON.x && mx <= RESET_BUTTON.x + RESET_BUTTON.w &&
my >= RESET_BUTTON.y && my <= RESET_BUTTON.y + RESET_BUTTON.h;
Expand Down Expand Up @@ -1202,7 +1248,7 @@ export const createP5Sketch = (config: CrossSectionViewSketchConfig) => {
p.mousePressed = function mousePressed() {
// Check reset button click
if (isInsideResetButton(p.mouseX, p.mouseY)) {
resetCanvas();
resetWeftSplines();
return;
}

Expand Down
Loading