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
29 changes: 29 additions & 0 deletions components/plotter/primitives-construction-motion.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import {
morphCycleDuration,
morphHoldDuration,
morphKeyTimes,
morphStageDuration,
} from "./primitives-morph-timing";
Expand Down Expand Up @@ -70,3 +71,31 @@ export function ConstructionAnnotation({
</g>
);
}

export function ConstructionStage({
children,
stage,
}: {
children: ReactNode;
stage: number;
}) {
return (
<g opacity="0">
<animate
attributeName="opacity"
begin={`${stage * morphStageDuration}s`}
dur={`${morphCycleDuration}s`}
keyTimes={morphKeyTimes(
0,
0.18,
2.2,
morphHoldDuration,
morphCycleDuration,
)}
repeatCount="indefinite"
values="0;1;1;0;0"
/>
{children}
</g>
);
}
45 changes: 45 additions & 0 deletions components/plotter/primitives-grid-label-mask.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
ConstructionAnnotation,
ConstructionStage,
} from "./primitives-construction-motion";
import {
SwitchRadiusVisibility,
SwitchThumbVisibility,
} from "./primitives-switch";

// Clear only the grid segments behind each stage’s visible annotations.
const labelGaps = [
// Avatar radius and angle.
"M324 132V163 M283 164H354",
// Pill radius and width.
"M172 164H200 M284 298V320",
// Switch width; its thumb radius follows a separate timeline below.
"M284 298V320",
// Button padding.
"M164 240V260 M140 244H168",
// Card inset and inner width.
"M374 204H394 M284 298V320",
// Slider travel and percentage labels.
"M284 121V142 M273 124H295 M124 298V320 M284 298V320 M444 298V320",
];

export function PrimitivesGridLabelMask() {
return (
<g fill="none" stroke="black" strokeOpacity="1" strokeWidth="1.3">
{labelGaps.map((d, stage) => (
<ConstructionStage key={d} stage={stage}>
<ConstructionAnnotation stage={stage}>
<path d={d} />
</ConstructionAnnotation>
</ConstructionStage>
))}
<g opacity="0">
<SwitchThumbVisibility />
<g opacity="0">
<SwitchRadiusVisibility />
<path d="M324 164H354" />
</g>
</g>
</g>
);
}
41 changes: 9 additions & 32 deletions components/plotter/primitives-morph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useEffect, useId, useRef } from "react";
import { BlueprintDrawing } from "./blueprint-drawing";
import { ConstructionStage } from "./primitives-construction-motion";
import { PrimitivesGridLabelMask } from "./primitives-grid-label-mask";
import { MorphDetails, morphDetailIds } from "./primitives-morph-details";
import { secondaryLine } from "./primitives-morph-style";
import {
Expand Down Expand Up @@ -122,22 +124,8 @@ const tangentIds = [
] as const;

const gridPaths = [
"M124 68V298 M124 320V348",
"M164 68V240 M164 260V348",
"M204 68V348",
"M244 68V348",
"M284 68V121 M284 142V298 M284 320V348",
"M324 68V132 M324 163V348",
"M364 68V348",
"M404 68V348",
"M444 68V298 M444 320V348",
"M104 84H464",
"M104 124H273 M295 124H464",
"M104 164H172 M200 164H283 M354 164H464",
"M104 204H374 M394 204H464",
"M104 244H140 M168 244H464",
"M104 284H464",
"M104 324H464",
...Array.from({ length: 9 }, (_, index) => `M${124 + index * 40} 68V348`),
...Array.from({ length: 7 }, (_, index) => `M104 ${84 + index * 40}H464`),
];

export function PrimitivesMorph({ paused }: { paused: boolean }) {
Expand Down Expand Up @@ -212,6 +200,7 @@ export function PrimitivesMorph({ paused }: { paused: boolean }) {
strokeOpacity="1"
/>
<SliderGridMask />
<PrimitivesGridLabelMask />
</mask>
{/* Origin at the circle center aligns a hatch line with its 45° radius. */}
<pattern
Expand Down Expand Up @@ -295,22 +284,10 @@ export function PrimitivesMorph({ paused }: { paused: boolean }) {
</g>
<PrimitivesMorphTransitions />
{morphDetailIds.map((stage, index) => (
<g data-construction={stage} key={stage} opacity="0">
<animate
attributeName="opacity"
begin={`${index * morphStageDuration}s`}
dur={`${morphCycleDuration}s`}
keyTimes={morphKeyTimes(
0,
0.18,
2.2,
morphHoldDuration,
morphCycleDuration,
)}
repeatCount="indefinite"
values="0;1;1;0;0"
/>
<MorphDetails hatchId={hatchId} stage={stage} />
<g data-construction={stage} key={stage}>
<ConstructionStage stage={index}>
<MorphDetails hatchId={hatchId} stage={stage} />
</ConstructionStage>
</g>
))}
<g fill="currentColor" fontSize="10" opacity="0.52" stroke="none">
Expand Down
48 changes: 30 additions & 18 deletions components/plotter/primitives-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ export function SwitchConstruction() {
export function SwitchThumb() {
return (
<g data-construction="switch-thumb" opacity="0">
<animate
attributeName="opacity"
begin="0s"
calcMode="linear"
dur={`${duration}s`}
keyTimes={keyTimes(0, 5.42, 5.6, 8.6, 8.8, duration)}
repeatCount="indefinite"
values="0;0;1;1;0;0"
/>
<SwitchThumbVisibility />
<g transform="translate(204 204)">
{/* Geometry resets after the whole thumb is hidden. */}
<animateTransform
Expand All @@ -82,15 +74,7 @@ export function SwitchThumb() {
/>
</circle>
<g opacity="0">
<animate
attributeName="opacity"
begin="0s"
calcMode="linear"
dur={`${duration}s`}
keyTimes={keyTimes(0, 7.4, 7.58, 8.82, 8.86, duration)}
repeatCount="indefinite"
values="0;0;1;1;0;0"
/>
<SwitchRadiusVisibility />
<path
{...secondaryLine}
d={`M0 0L${radiusEndpoint} ${radiusEndpoint} M${radiusEndpoint - 3} ${radiusEndpoint + 3}l6-6`}
Expand All @@ -112,3 +96,31 @@ export function SwitchThumb() {
</g>
);
}

export function SwitchThumbVisibility() {
return (
<animate
attributeName="opacity"
begin="0s"
calcMode="linear"
dur={`${duration}s`}
keyTimes={keyTimes(0, 5.42, 5.6, 8.6, 8.8, duration)}
repeatCount="indefinite"
values="0;0;1;1;0;0"
/>
);
}

export function SwitchRadiusVisibility() {
return (
<animate
attributeName="opacity"
begin="0s"
calcMode="linear"
dur={`${duration}s`}
keyTimes={keyTimes(0, 7.4, 7.58, 8.82, 8.86, duration)}
repeatCount="indefinite"
values="0;0;1;1;0;0"
/>
);
}
Loading