summaryrefslogtreecommitdiff
path: root/apps/web/src/masks/definitions/text.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-29 18:31:24 +0200
committerMaze Winther <mazewinther@gmail.com>2026-05-02 03:27:23 +0200
commit97f8d1968f186028e41f83b04c0897130e6c69f4 (patch)
treecb951cbfcfa004f53ab3d7a06021fc43942ac04b /apps/web/src/masks/definitions/text.ts
parentae1292a14bf5c29544a5f7a49e65b994410f87de (diff)
downloadopencut-97f8d1968f186028e41f83b04c0897130e6c69f4.tar.gz
refactor: type mask handle identifiers
Made-with: Cursor
Diffstat (limited to 'apps/web/src/masks/definitions/text.ts')
-rw-r--r--apps/web/src/masks/definitions/text.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/apps/web/src/masks/definitions/text.ts b/apps/web/src/masks/definitions/text.ts
index aa786e78..db2af7e0 100644
--- a/apps/web/src/masks/definitions/text.ts
+++ b/apps/web/src/masks/definitions/text.ts
@@ -4,6 +4,7 @@ import type {
MaskParamUpdateArgs,
TextMask,
TextMaskParams,
+ MaskHandleId,
} from "@/masks/types";
import { DEFAULTS } from "@/timeline/defaults";
import { MIN_FONT_SIZE, MAX_FONT_SIZE } from "@/text/typography";
@@ -124,9 +125,9 @@ function measureTextMask({
function getScalePreferredEdges({
handleId,
}: {
- handleId: string;
+ handleId: MaskHandleId;
}): ScaleEdgePreference | undefined {
- if (handleId !== "scale") {
+ if (handleId.kind !== "scale") {
return undefined;
}
@@ -145,7 +146,7 @@ function computeTextMaskParamUpdate({
startCanvasY,
bounds,
}: MaskParamUpdateArgs<TextMaskParams>): Partial<TextMaskParams> {
- if (handleId === "position") {
+ if (handleId.kind === "position") {
return {
centerX: startParams.centerX + deltaX / bounds.width,
centerY: startParams.centerY + deltaY / bounds.height,
@@ -155,7 +156,7 @@ function computeTextMaskParamUpdate({
const pivotX = bounds.cx + startParams.centerX * bounds.width;
const pivotY = bounds.cy + startParams.centerY * bounds.height;
- if (handleId === "rotation") {
+ if (handleId.kind === "rotation") {
const startAngle =
(Math.atan2(startCanvasY - pivotY, startCanvasX - pivotX) * 180) /
Math.PI;
@@ -176,7 +177,7 @@ function computeTextMaskParamUpdate({
};
}
- if (handleId === "feather") {
+ if (handleId.kind === "feather") {
const angleRad = (startParams.rotation * Math.PI) / 180;
return computeFeatherUpdate({
startFeather: startParams.feather,
@@ -187,7 +188,7 @@ function computeTextMaskParamUpdate({
});
}
- if (handleId === "scale") {
+ if (handleId.kind === "scale") {
const startDistance = Math.hypot(
startCanvasX - pivotX,
startCanvasY - pivotY,
@@ -269,7 +270,7 @@ export const textMaskDefinition: MaskDefinition<"text"> = {
y: proposedParams.centerY * bounds.height,
};
- if (handleId === "position") {
+ if (handleId.kind === "position") {
const { snappedPosition, activeLines } = snapPosition({
proposedPosition: position,
canvasSize: bounds,
@@ -297,7 +298,7 @@ export const textMaskDefinition: MaskDefinition<"text"> = {
};
}
- if (handleId === "rotation") {
+ if (handleId.kind === "rotation") {
const { snappedRotation } = snapRotation({
proposedRotation: proposedParams.rotation,
});
@@ -310,7 +311,7 @@ export const textMaskDefinition: MaskDefinition<"text"> = {
};
}
- if (handleId === "scale") {
+ if (handleId.kind === "scale") {
const { snappedScale, activeLines } = snapScale({
proposedScale: proposedParams.scale,
position,