diff --git a/curveEditor.js b/curveEditor.js index 489c192..2e589a9 100644 --- a/curveEditor.js +++ b/curveEditor.js @@ -312,22 +312,6 @@ export class CurveEditor { } - - // getPositionAtTime(timeInSeconds, curve, valueToX, transform) { - // // Convert time to pixel X position - // const targetX = valueToX(timeInSeconds); - - // // Transform control points - // const p0 = transform(curve.startPoint); - // const h0 = transform(curve.startPointHandle); - // const h1 = transform(curve.endPointHandle); - // const p1 = transform(curve.endPoint); - - - // const t = solveTForX(targetX, p0, h0, h1, p1); - // return cubicBezier(t, p0, h0, h1, p1); - // } - getMotorPositionAtTime(motorID, timeInFrames) { if (this.curveSets[motorID] === undefined || this.curveSets[motorID].length === 0) { console.log("THIS"); @@ -636,20 +620,32 @@ export class CurveEditor { this.isPanning = false; }); - this.canvas.addEventListener('wheel', e => { - e.preventDefault(); - const mouse = { x: e.offsetX, y: e.offsetY }; - const zoomFactor = e.deltaY < 0 ? 1.1 : 0.9; + this.canvas.addEventListener('wheel', e => { + e.preventDefault(); + const mouse = { x: e.offsetX, y: e.offsetY }; + const zoomFactor = e.deltaY < 0 ? 1.1 : 0.9; - const before = this.inverseTransform(mouse); - this.scale *= zoomFactor; - const after = this.inverseTransform(mouse); + const before = this.inverseTransform(mouse); - this.offset.x += (after.x - before.x) * this.scale; - this.offset.y += (after.y - before.y) * this.scale; + // Apply zoom based on modifier keys + if (e.ctrlKey && !e.altKey) { + this.scaleX *= zoomFactor; + } else if (e.altKey && !e.ctrlKey) { + this.scaleY *= zoomFactor; + } else { + // Default: uniform zoom + this.scaleX *= zoomFactor; + this.scaleY *= zoomFactor; + } + + const after = this.inverseTransform(mouse); + + this.offset.x += (after.x - before.x) * this.scaleX; + this.offset.y += (after.y - before.y) * this.scaleY; + + this.draw(); +}); - this.draw(); - }); this.canvas.addEventListener('dblclick', e => { const mouse = this.inverseTransform({ x: e.offsetX, y: e.offsetY }); diff --git a/index.html b/index.html index f84822a..84724f5 100644 --- a/index.html +++ b/index.html @@ -155,7 +155,7 @@