Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Redraw the helper character and the workshop room

Youssef0bc2c4a9b66d
diff --git a/src/app/home.css b/src/app/home.css
index c82c6e1..e958760 100644
--- a/src/app/home.css
+++ b/src/app/home.css
@@ -1100,7 +1100,15 @@
.scale-person {
height: 100%;
width: auto;
- fill: #e6e3dc;
+}
+/* the floor the pieces stand on: a skirting line and a soft floor below it */
+.sr-floor {
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: linear-gradient(180deg, #f3f1ec, #faf9f6 70%);
+ box-shadow: inset 0 1.5px 0 var(--line-2);
}
.sr-person span {
position: absolute;
diff --git a/src/components/art/Figure.tsx b/src/components/art/Figure.tsx
index fe28835..6e54a40 100644
--- a/src/components/art/Figure.tsx
+++ b/src/components/art/Figure.tsx
@@ -1,76 +1,136 @@
export type Pose = "stand" | "cheer" | "think" | "point" | "wave" | "read" | "lift";
-const ARMS: Record<Pose, [string, string]> = {
- stand: ["M22 34 Q15 46 16 58", "M38 34 Q45 46 44 58"],
- cheer: ["M22 34 Q13 23 12 9", "M38 34 Q47 23 48 9"],
- think: ["M22 34 Q15 46 16 58", "M38 34 Q49 36 41 21"],
- point: ["M22 34 Q15 46 16 58", "M38 34 Q48 33 58 30"],
- wave: ["M22 34 Q15 46 16 58", "M38 34 Q48 26 49 12"],
- read: ["M22 34 Q19 44 27 46", "M38 34 Q41 44 33 46"],
- lift: ["M22 34 Q15 26 14 15", "M38 34 Q45 26 46 15"],
+type Pt = [number, number];
+type Limb = [Pt, Pt, Pt];
+
+const INK = "var(--ink)";
+
+/** Shoulder, elbow and hand for each arm. */
+const ARMS: Record<Pose, [Limb, Limb]> = {
+ stand: [[[22.5, 33], [18.5, 45], [19.5, 56]], [[37.5, 33], [41.5, 45], [40.5, 56]]],
+ cheer: [[[22.5, 32], [15, 24], [12.5, 11]], [[37.5, 32], [45, 24], [47.5, 11]]],
+ think: [[[22.5, 33], [18.5, 45], [19.5, 56]], [[37.5, 33], [45.5, 37], [36, 23]]],
+ point: [[[22.5, 33], [18.5, 45], [19.5, 56]], [[37.5, 33], [47, 33], [57, 28]]],
+ wave: [[[22.5, 33], [18.5, 45], [19.5, 56]], [[37.5, 32], [46, 27], [47, 13]]],
+ read: [[[22.5, 33], [20, 44], [26.5, 46]], [[37.5, 33], [40, 44], [33.5, 46]]],
+ lift: [[[22.5, 32], [14, 27], [13.5, 15]], [[37.5, 32], [46, 27], [46.5, 15]]],
};
+const LEGS: [Limb, Limb] = [
+ [[26.4, 60], [25.6, 75], [25.2, 89]],
+ [[33.6, 60], [34.4, 75], [34.8, 89]],
+];
-/** The helper character: an original little builder drawn with outlined limbs. viewBox 0 0 60 100. */
-export function Figure({ pose = "stand", size = 80, className, bubble }: { pose?: Pose; size?: number; className?: string; bubble?: "?" | "!" | "check" }) {
+function Tube({ limb: [a, b, c], w, k, className }: { limb: Limb; w: number; k: number; className?: string }) {
+ const d = `M${a[0]} ${a[1]} Q${b[0]} ${b[1]} ${c[0]} ${c[1]}`;
+ return (
+ <g className={className}>
+ <path d={d} fill="none" stroke={INK} strokeWidth={w + 3.6 * k} strokeLinecap="round" />
+ <path d={d} fill="none" stroke="#fff" strokeWidth={w} strokeLinecap="round" />
+ </g>
+ );
+}
+
+const SHOE = "M33.2 88.4 h4.4 q4.9 0 4.9 3.3 q0 1.5 -1.5 1.5 h-8.2 q-1.4 0 -1.4 -1.7 z";
+
+function Face({ pose }: { pose: Pose }) {
+ if (pose === "cheer")
+ return (
+ <g>
+ <path d="M26.4 13.6 q1.3 -1.6 2.6 0 M32 13.6 q1.3 -1.6 2.6 0" fill="none" stroke={INK} strokeWidth={1.3} strokeLinecap="round" />
+ <path d="M27.4 17 q2.9 3.4 5.8 0 z" fill={INK} />
+ </g>
+ );
+ // thinking: eyes up, mouth flat
+ const up = pose === "think";
+ return (
+ <g>
+ <circle cx={up ? 28 : 27.6} cy={up ? 12 : 13.4} r={1.15} fill={INK} />
+ <circle cx={up ? 33.4 : 33} cy={up ? 12 : 13.4} r={1.15} fill={INK} />
+ {up ? <path d="M28.6 18.2 h3.4" stroke={INK} strokeWidth={1.3} strokeLinecap="round" /> : <path d="M28 17.2 q2.3 1.9 4.6 0" fill="none" stroke={INK} strokeWidth={1.3} strokeLinecap="round" />}
+ </g>
+ );
+}
+
+/** The builder, drawn in the same ink as the furniture. viewBox units: 60 wide, head at 4.6, soles at 93.2. `k` thins the outlines. */
+function Body({ pose, k = 1 }: { pose: Pose; k?: number }) {
const [l, r] = ARMS[pose];
- const limb = (d: string, key: string, cls?: string) => (
- <g key={key} className={cls}>
- <path d={d} fill="none" stroke="var(--ink)" strokeWidth={7.4} strokeLinecap="round" />
- <path d={d} fill="none" stroke="#fff" strokeWidth={3.6} strokeLinecap="round" />
+ return (
+ <g>
+ <Tube limb={LEGS[0]} w={5.4} k={k} />
+ <Tube limb={LEGS[1]} w={5.4} k={k} />
+ <path d={SHOE} fill={INK} transform="translate(60 0) scale(-1 1)" />
+ <path d={SHOE} fill={INK} />
+ <path
+ d="M23 30.5 Q30 27.6 37 30.5 Q39.6 31.6 39.2 35 L37.6 57.5 Q37.4 61.5 33.6 61.5 H26.4 Q22.6 61.5 22.4 57.5 L20.8 35 Q20.4 31.6 23 30.5 Z"
+ fill="#fff"
+ stroke={INK}
+ strokeWidth={2.2 * k}
+ strokeLinejoin="round"
+ />
+ <path d="M26.6 29.4 q3.4 3.4 6.8 0" fill="none" stroke={INK} strokeWidth={1.6 * k} strokeLinecap="round" />
+ <path d="M22.2 52.5 H37.8" stroke={INK} strokeWidth={1.4 * k} />
+ <rect x={31.4} y={38} width={4.6} height={5.2} rx={1} fill="var(--accent)" stroke={INK} strokeWidth={1.4 * k} />
+ {pose === "read" && (
+ <g transform="rotate(-6 30 44)">
+ <rect x={22} y={39} width={16} height={11.5} rx={1.6} fill="var(--accent-soft)" stroke={INK} strokeWidth={1.8} />
+ <path d="M30 39.6 v10.8" stroke={INK} strokeWidth={1.2} />
+ </g>
+ )}
+ <Tube limb={l} w={4.2} k={k} className="arm-l" />
+ <Tube limb={r} w={4.2} k={k} className="arm-r" />
+ <circle cx={l[2][0]} cy={l[2][1]} r={3.3} fill="#fff" stroke={INK} strokeWidth={1.8 * k} />
+ <circle cx={r[2][0]} cy={r[2][1]} r={3.3} fill="#fff" stroke={INK} strokeWidth={1.8 * k} />
+ <g className="head">
+ <path d="M21.5 13.8 q-2.6 0.6 -1.4 3.6 q0.7 1.2 2 1" fill="#fff" stroke={INK} strokeWidth={1.6 * k} strokeLinecap="round" />
+ <ellipse cx={30.3} cy={14.2} rx={8.9} ry={9.4} fill="#fff" stroke={INK} strokeWidth={2.2 * k} />
+ <path d="M21.6 12.8 Q21.6 4.6 30.4 4.6 Q38.8 4.6 39.1 12.2 Q35.6 8.6 30.2 9.2 Q25.4 9.6 21.6 12.8 Z" fill={INK} />
+ <Face pose={pose} />
+ </g>
</g>
);
+}
+
+/** The helper character: an original little builder. viewBox 0 0 60 100. */
+export function Figure({ pose = "stand", size = 80, className, bubble }: { pose?: Pose; size?: number; className?: string; bubble?: "?" | "!" | "check" }) {
return (
<svg viewBox="0 0 60 100" width={(size * 60) / 100} height={size} className={"figure " + (className ?? "")} aria-hidden="true" overflow="visible">
- {limb("M26 58 L23 91", "ll")}
- {limb("M34 58 L37 91", "lr")}
- <path d="M20 93 h7 M33 93 h7" stroke="var(--ink)" strokeWidth={4.6} strokeLinecap="round" />
- <rect x={20.5} y={27} width={19} height={34} rx={9} fill="#fff" stroke="var(--ink)" strokeWidth={2.2} />
- {limb(l, "al", "arm-l")}
- {limb(r, "ar", "arm-r")}
- {pose === "read" && <rect x={22} y={38} width={16} height={12} rx={1.5} fill="var(--accent-soft)" stroke="var(--ink)" strokeWidth={1.8} transform="rotate(-6 30 44)" />}
- <circle cx={30} cy={15} r={9.5} fill="#fff" stroke="var(--ink)" strokeWidth={2.2} className="head" />
+ <Body pose={pose} />
{bubble && (
<g transform="translate(46 -6)" className="bubble">
- <path d="M0 10 a12 11 0 1 1 6 9 l-7 4 l2 -6 a11 11 0 0 1 -1 -7 z" fill={bubble === "check" ? "var(--accent)" : "#fff"} stroke="var(--ink)" strokeWidth={2} strokeLinejoin="round" />
- {bubble === "?" && <text x={12} y={16} textAnchor="middle" fontSize={15} fontWeight={800} fill="var(--ink)" fontFamily="var(--font)">?</text>}
- {bubble === "!" && <text x={12} y={16} textAnchor="middle" fontSize={15} fontWeight={800} fill="var(--ink)" fontFamily="var(--font)">!</text>}
- {bubble === "check" && <path d="M6.5 10.5 l4 4 l7 -8" fill="none" stroke="var(--ink)" strokeWidth={2.6} strokeLinecap="round" strokeLinejoin="round" />}
+ <path d="M0 10 a12 11 0 1 1 6 9 l-7 4 l2 -6 a11 11 0 0 1 -1 -7 z" fill={bubble === "check" ? "var(--accent)" : "#fff"} stroke={INK} strokeWidth={2} strokeLinejoin="round" />
+ {bubble === "check" ? (
+ <path d="M6.5 10.5 l4 4 l7 -8" fill="none" stroke={INK} strokeWidth={2.6} strokeLinecap="round" strokeLinejoin="round" />
+ ) : (
+ <text x={12} y={16} textAnchor="middle" fontSize={15} fontWeight={800} fill={INK} fontFamily="var(--font)">
+ {bubble}
+ </text>
+ )}
</g>
)}
</svg>
);
}
-/** Two figures carrying a panel together. */
-export function TwoPeople({ size = 64, className }: { size?: number; className?: string }) {
+/** Head to sole and nothing else, for drawing a person to scale next to furniture. */
+export function ScaleFigure({ className }: { className?: string }) {
return (
- <svg viewBox="0 -2 120 100" width={(size * 120) / 100} height={size} className={className} aria-hidden="true">
- <rect x={12} y={2} width={96} height={9} rx={2} fill="var(--accent-soft)" stroke="var(--ink)" strokeWidth={2.2} />
- <g transform="translate(4 4)">
- <Mini />
- </g>
- <g transform="translate(62 4)">
- <Mini />
- </g>
+ <svg viewBox="8 4.4 44 88.8" className={className} preserveAspectRatio="xMidYMax meet" aria-hidden="true">
+ <Body pose="stand" k={0.62} />
</svg>
);
}
-function Mini() {
- const limb = (d: string) => (
- <>
- <path d={d} fill="none" stroke="var(--ink)" strokeWidth={7} strokeLinecap="round" />
- <path d={d} fill="none" stroke="#fff" strokeWidth={3.4} strokeLinecap="round" />
- </>
- );
+/** Two builders carrying a panel together. */
+export function TwoPeople({ size = 64, className }: { size?: number; className?: string }) {
return (
- <g>
- {limb("M26 58 L23 89")}
- {limb("M34 58 L37 89")}
- <rect x={20.5} y={27} width={19} height={34} rx={9} fill="#fff" stroke="var(--ink)" strokeWidth={2.2} />
- {limb("M22 34 Q15 22 18 4")}
- {limb("M38 34 Q45 22 42 4")}
- <circle cx={30} cy={18} r={8.5} fill="#fff" stroke="var(--ink)" strokeWidth={2.2} />
- </g>
+ <svg viewBox="0 -4 120 100" width={(size * 120) / 100} height={size} className={className} aria-hidden="true">
+ <g transform="translate(0 4)">
+ <Body pose="lift" />
+ </g>
+ <g transform="translate(60 4)">
+ <Body pose="lift" />
+ </g>
+ <rect x={10} y={10} width={100} height={8} rx={2} fill="var(--accent-soft)" stroke={INK} strokeWidth={2.2} />
+ </svg>
);
}
diff --git a/src/components/workshop/Workshop.tsx b/src/components/workshop/Workshop.tsx
index c6ed490..7b9bc5d 100644
--- a/src/components/workshop/Workshop.tsx
+++ b/src/components/workshop/Workshop.tsx
@@ -12,7 +12,7 @@ import type { Plan, ProductSpec } from "@/lib/types";
import { useMounted } from "@/lib/useMounted";
import { peekShot, shot, type Shot } from "@/engine/thumbs";
import Thumb from "../Thumb";
-import { Figure } from "../art/Figure";
+import { Figure, ScaleFigure } from "../art/Figure";
import { IArrowRight, IBox, ICheck, IClock, IClose, ILibrary, IPeople, WarnIcon } from "../art/Icons";
interface Row {
@@ -194,6 +194,8 @@ function Showroom({ rows }: { rows: Row[] }) {
[personX - 300, 0, 0],
[personX - 300, PERSON, 0],
[line.span[1] + 300, 0, 0],
+ // room under the floor line for the name tags
+ [line.span[0], -420, 0],
] as [number, number, number][],
}),
[personX, line],
@@ -227,11 +229,12 @@ function Showroom({ rows }: { rows: Row[] }) {
<div className="sr-stage" ref={wrap} style={{ height: h }}>
{s && (
<motion.div className="sr-img" initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ duration: 0.5 }}>
+ {feet && <div className="sr-floor" style={{ top: feet.y }} aria-hidden="true" />}
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={s.url} alt="" draggable={false} />
{feet && figH > 20 && (
<div className="sr-person" style={{ left: feet.x, top: feet.y, height: figH }}>
- <ScalePerson />
+ <ScaleFigure className="scale-person" />
<span>You, about 175 cm</span>
</div>
)}
@@ -252,20 +255,6 @@ function Showroom({ rows }: { rows: Row[] }) {
);
}
-/** A quiet scale figure, like the ones on architects' drawings. viewBox is 175 units tall, one per cm. */
-function ScalePerson() {
- return (
- <svg viewBox="0 0 60 175" className="scale-person" aria-hidden="true">
- <circle cx="30" cy="11.5" r="10.5" />
- <rect x="17" y="26" width="26" height="62" rx="11" />
- <rect x="8.5" y="28" width="7.5" height="60" rx="3.75" transform="rotate(4 12 28)" />
- <rect x="44" y="28" width="7.5" height="60" rx="3.75" transform="rotate(-4 48 28)" />
- <rect x="19" y="78" width="10.5" height="96" rx="5.25" />
- <rect x="30.5" y="78" width="10.5" height="96" rx="5.25" />
- </svg>
- );
-}
-
/* ---------- lists ---------- */
function GoingRow({ r, onRemove }: { r: Row; onRemove: () => void }) {