[ui] PlanetGarden: Her round planet, the player's gardener, the ring of care, and care by gesture
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<svelte:options namespace="svg" />
|
||||
|
||||
<script lang="ts" module>
|
||||
/** What the gardener is doing (planet-garden.md G5). */
|
||||
export type Pose = 'stand' | 'walk' | 'pour' | 'pull' | 'sweep' | 'carry' | 'reach';
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Gardener } from '@rosea/schema';
|
||||
|
||||
/**
|
||||
* The player's gardener: a stand-in drawn in code until the art board's gardener sheets are
|
||||
* accepted. Feet at (0, 0), about 72 units tall, facing right. A child in a work apron, never
|
||||
* a scarf, coat, cape or crown (planet-garden.md §0). The pose bends the figure; the scene
|
||||
* moves it.
|
||||
*/
|
||||
let { look, pose = 'stand', tilt = 0 }: { look: Gardener; pose?: Pose; tilt?: number } = $props();
|
||||
|
||||
const SKIN: Record<Gardener['skin'], string> = {
|
||||
'skin-1': '#f6dcc8', 'skin-2': '#e8bf9c', 'skin-3': '#cf9a72', 'skin-4': '#a9714b', 'skin-5': '#7f5236', 'skin-6': '#553422'
|
||||
};
|
||||
const HAIR: Record<Gardener['hairColour'], string> = {
|
||||
black: '#2b2324', 'dark-brown': '#4a2f24', brown: '#7a4b2e', auburn: '#9a4a2a', red: '#b5532c', fair: '#d9b26a'
|
||||
};
|
||||
const CLOTHES: Record<Gardener['clothes'], string> = { sage: '#7fa07a', rose: '#c85a6e', honey: '#b98a5a', dusk: '#5b6fa6', plum: '#7a4f6e' };
|
||||
const INK = '#3a2730';
|
||||
const APRON = '#efe4d2';
|
||||
|
||||
const skin = $derived(SKIN[look.skin]);
|
||||
const hair = $derived(HAIR[look.hairColour]);
|
||||
const cloth = $derived(CLOTHES[look.clothes]);
|
||||
/** How far the body leans forward, by pose. */
|
||||
const lean = $derived({ stand: 0, walk: 4, pour: 10, pull: 28, sweep: 18, carry: 6, reach: 14 }[pose]);
|
||||
/** The near arm's angle from hanging down, by pose (degrees, forward is negative). */
|
||||
const arm = $derived({ stand: 8, walk: -12, pour: -70 - tilt * 25, pull: -150, sweep: -40, carry: -80, reach: -95 }[pose]);
|
||||
</script>
|
||||
|
||||
<g class="gardener {pose}" aria-hidden="true">
|
||||
<!-- Legs: a skirt-length tunic for a girl, trousers for a boy; both chosen by the player. -->
|
||||
{#if look.presentation === 'girl'}
|
||||
<path d="M-7 0 V -18 M7 0 V -18" stroke={skin} stroke-width="5" stroke-linecap="round" />
|
||||
{:else}
|
||||
<path d="M-7 0 V -20 M7 0 V -20" stroke={cloth} stroke-width="7" stroke-linecap="round" />
|
||||
{/if}
|
||||
<path d="M-10 0 h6 M4 0 h6" stroke={INK} stroke-width="4" stroke-linecap="round" />
|
||||
|
||||
<g transform="rotate({lean} 0 -20)">
|
||||
<!-- Body: shirt or tunic in the chosen colour, a cream work apron over it. -->
|
||||
{#if look.presentation === 'girl'}
|
||||
<path d="M-12 -44 Q -16 -24 -15 -16 H 15 Q 16 -24 12 -44 Z" fill={cloth} stroke={INK} stroke-width="2" />
|
||||
{:else}
|
||||
<path d="M-11 -44 Q -12 -30 -10 -20 H 10 Q 12 -30 11 -44 Z" fill={cloth} stroke={INK} stroke-width="2" />
|
||||
{/if}
|
||||
<path d="M-7 -36 H 7 V -18 Q 0 -15 -7 -18 Z" fill={APRON} stroke={INK} stroke-width="1.5" />
|
||||
|
||||
<!-- The far arm hangs; the near arm does the work. -->
|
||||
<path d="M-10 -42 l -4 16" stroke={skin} stroke-width="4.5" stroke-linecap="round" />
|
||||
<g transform="rotate({arm} 9 -42)">
|
||||
<path d="M9 -42 l 2 18" stroke={skin} stroke-width="4.5" stroke-linecap="round" />
|
||||
{#if pose === 'pour'}
|
||||
<!-- The watering can, tipped as the player tips it. -->
|
||||
<g transform="translate(11 -22) rotate({20 + tilt * 40})">
|
||||
<rect x="-7" y="-6" width="14" height="11" rx="3" fill="#7fa07a" stroke={INK} stroke-width="1.5" />
|
||||
<path d="M7 -2 l 9 -6" stroke={INK} stroke-width="2.5" stroke-linecap="round" />
|
||||
</g>
|
||||
{:else if pose === 'sweep'}
|
||||
<path d="M11 -24 l 3 16" stroke="#b98a5a" stroke-width="2.5" />
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- Head: skin, then the chosen hair, then the chosen hat. A tiny painted face. -->
|
||||
<circle cx="0" cy="-54" r="10" fill={skin} stroke={INK} stroke-width="2" />
|
||||
{#if look.hair === 'short'}
|
||||
<path d="M-10 -56 Q 0 -70 10 -56 Q 4 -61 -10 -56 Z" fill={hair} />
|
||||
{:else if look.hair === 'curly'}
|
||||
{#each [-8, -3, 2, 7] as x (x)}<circle cx={x} cy="-62" r="4.5" fill={hair} />{/each}
|
||||
{:else if look.hair === 'ponytail'}
|
||||
<path d="M-10 -55 Q 0 -70 10 -55 Q 0 -60 -10 -55 Z" fill={hair} /><path d="M-9 -58 q -8 6 -5 16" stroke={hair} stroke-width="4" fill="none" stroke-linecap="round" />
|
||||
{:else if look.hair === 'braids'}
|
||||
<path d="M-10 -55 Q 0 -70 10 -55 Q 0 -60 -10 -55 Z" fill={hair} /><path d="M-9 -54 v 14 M9 -54 v 14" stroke={hair} stroke-width="3.5" stroke-linecap="round" />
|
||||
{:else if look.hair === 'bob'}
|
||||
<path d="M-11 -50 Q -12 -68 0 -66 Q 12 -68 11 -50 L 8 -50 Q 0 -60 -8 -50 Z" fill={hair} />
|
||||
{:else}
|
||||
<path d="M-10 -55 Q 0 -70 10 -55 Q 0 -60 -10 -55 Z" fill={hair} /><circle cx="0" cy="-66" r="4.5" fill={hair} />
|
||||
{/if}
|
||||
{#if look.hat === 'straw-hat'}
|
||||
<ellipse cx="0" cy="-61" rx="16" ry="3.5" fill="#e6c98a" stroke={INK} stroke-width="1.5" /><path d="M-7 -61 Q 0 -72 7 -61 Z" fill="#e6c98a" stroke={INK} stroke-width="1.5" />
|
||||
{:else if look.hat === 'cap'}
|
||||
<path d="M-9 -60 Q 0 -70 9 -60 Z" fill={cloth} stroke={INK} stroke-width="1.5" /><path d="M7 -60 h 8" stroke={INK} stroke-width="2.5" stroke-linecap="round" />
|
||||
{/if}
|
||||
<circle cx="3" cy="-55" r="1.2" fill={INK} /><circle cx="7" cy="-55" r="1.2" fill={INK} />
|
||||
<path d="M3 -50 q 2 1.5 4 0" stroke={INK} stroke-width="1.2" fill="none" stroke-linecap="round" />
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<style>
|
||||
.gardener g {
|
||||
transition: transform 0.35s ease;
|
||||
}
|
||||
|
||||
.walk {
|
||||
animation: step 0.5s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
@keyframes step {
|
||||
to {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,177 @@
|
||||
<script lang="ts">
|
||||
import { GARDENER_FIELDS, GARDENER_OPTIONS, type Gardener as Look } from '@rosea/schema';
|
||||
import { untrack } from 'svelte';
|
||||
import { en } from '../copy/en.js';
|
||||
import Gardener from './Gardener.svelte';
|
||||
import { FIRST_LOOK } from './look.js';
|
||||
|
||||
/**
|
||||
* *Who tends her?* (planet-garden.md §1): the player chooses and dresses their gardener from
|
||||
* fixed lists, with a preview that follows every choice. Nothing typed, nothing sent.
|
||||
*/
|
||||
let {
|
||||
current = null,
|
||||
onchoose,
|
||||
oncancel
|
||||
}: { current?: Look | null; onchoose: (look: Look) => void; oncancel?: () => void } = $props();
|
||||
|
||||
// A copy of what was given: the choice changes it freely until *This is me*.
|
||||
let look = $state<Look>({ ...(untrack(() => current) ?? FIRST_LOOK) });
|
||||
const uid = $props.id();
|
||||
let heading = $state<HTMLHeadingElement>();
|
||||
$effect(() => {
|
||||
if (current) heading?.focus();
|
||||
});
|
||||
|
||||
const label = (field: keyof Look, value: string): string => (en.gardener.values[field] as Record<string, string>)[value] ?? value;
|
||||
</script>
|
||||
|
||||
<section class="choice" aria-labelledby="{uid}-q">
|
||||
<h2 id="{uid}-q" tabindex="-1" bind:this={heading}>{en.gardener.question}</h2>
|
||||
<p class="why">{en.gardener.why}</p>
|
||||
<svg class="preview" viewBox="-40 -90 80 96" role="img" aria-label={en.gardener.preview}>
|
||||
<ellipse cx="0" cy="2" rx="26" ry="5" fill="#a9c48e" />
|
||||
<Gardener {look} />
|
||||
</svg>
|
||||
<form
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault();
|
||||
onchoose({ ...look });
|
||||
}}
|
||||
>
|
||||
{#each GARDENER_FIELDS as field (field)}
|
||||
<fieldset>
|
||||
<legend>{en.gardener.labels[field]}</legend>
|
||||
<div class="options">
|
||||
{#each GARDENER_OPTIONS[field] as value (value)}
|
||||
<label>
|
||||
<input type="radio" name="{uid}-{field}" {value} checked={look[field] === value} onchange={() => (look = { ...look, [field]: value })} />
|
||||
<span>{label(field, value)}</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</fieldset>
|
||||
{/each}
|
||||
<div class="actions">
|
||||
<button type="submit" class="primary">{en.gardener.done}</button>
|
||||
{#if oncancel}<button type="button" class="quiet" onclick={oncancel}>{en.scene.close}</button>{/if}
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.choice {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
justify-items: center;
|
||||
max-width: 28rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h2:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.why {
|
||||
margin: 0;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.preview {
|
||||
width: 7rem;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
form {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
legend {
|
||||
font-weight: 600;
|
||||
padding: 0;
|
||||
margin-bottom: var(--space-1);
|
||||
}
|
||||
|
||||
.options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
label span {
|
||||
padding: var(--space-1) var(--space-2);
|
||||
border-radius: 999px;
|
||||
border: 1px solid color-mix(in srgb, var(--ink-soft) 40%, transparent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input:checked + span {
|
||||
border-color: var(--rose);
|
||||
background: color-mix(in srgb, var(--rose) 14%, var(--paper));
|
||||
}
|
||||
|
||||
input:focus-visible + span {
|
||||
outline: 2px solid var(--rose);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
padding: var(--space-2) var(--space-4);
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--rose);
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.primary {
|
||||
background: var(--rose);
|
||||
color: var(--paper);
|
||||
}
|
||||
|
||||
.quiet {
|
||||
border: none;
|
||||
text-decoration: underline;
|
||||
color: var(--rose);
|
||||
}
|
||||
|
||||
button:focus-visible {
|
||||
outline: 2px solid var(--rose);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,419 @@
|
||||
<script lang="ts" module>
|
||||
/** What the gardener is busy with; `idle` stands beside her. */
|
||||
export type Activity = 'idle' | 'pour' | 'weeds' | 'petals' | 'shade' | 'touch';
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Light } from '@rosea/engine';
|
||||
import type { Gardener as Look } from '@rosea/schema';
|
||||
import { untrack } from 'svelte';
|
||||
import { en } from '../copy/en.js';
|
||||
import Gardener, { type Pose } from './Gardener.svelte';
|
||||
import { inside, isPull, isSweep, strokeOf, tiltOf, type Sample } from './gestures.js';
|
||||
|
||||
/**
|
||||
* Her planet (planet-garden.md): a small round world under the real sky, with her bed, the
|
||||
* gardener, and the things of her care, each answering the player's hand. It decides nothing:
|
||||
* every gesture is handed to the rose, whose rules are the engine's.
|
||||
*/
|
||||
let {
|
||||
picture,
|
||||
alt,
|
||||
turned = false,
|
||||
light = 'day',
|
||||
look,
|
||||
weeds = 0,
|
||||
petals = 0,
|
||||
wind = false,
|
||||
pouring = false,
|
||||
tilt = 0,
|
||||
ringOpen = false,
|
||||
roseTarget = $bindable(),
|
||||
onrose,
|
||||
onstroke,
|
||||
onpourstart,
|
||||
onpourtilt,
|
||||
onpourend,
|
||||
onweeds,
|
||||
onpetals,
|
||||
onshade
|
||||
}: {
|
||||
picture: string;
|
||||
alt: string;
|
||||
turned?: boolean;
|
||||
light?: Light;
|
||||
look: Look;
|
||||
weeds?: number;
|
||||
petals?: number;
|
||||
wind?: boolean;
|
||||
pouring?: boolean;
|
||||
tilt?: number;
|
||||
ringOpen?: boolean;
|
||||
roseTarget?: SVGElement | undefined;
|
||||
onrose: () => void;
|
||||
onstroke: () => void;
|
||||
onpourstart: () => void;
|
||||
onpourtilt: (tilt: number) => void;
|
||||
onpourend: () => void;
|
||||
onweeds: () => void;
|
||||
onpetals: () => void;
|
||||
onshade: () => void;
|
||||
} = $props();
|
||||
|
||||
// --- The world's geometry: a planet of radius R, the rose on its top ---------
|
||||
const CX = 180;
|
||||
const CY = 285;
|
||||
const R = 105;
|
||||
const TOP = CY - R;
|
||||
/** A point on the surface at `deg` from the top (positive is to the right). */
|
||||
const surface = (deg: number, lift = 0): { x: number; y: number } => {
|
||||
const a = (deg * Math.PI) / 180;
|
||||
return { x: CX + (R + lift) * Math.sin(a), y: CY - (R + lift) * Math.cos(a) };
|
||||
};
|
||||
const WEED_AT = [9, -9, 15, -15];
|
||||
const PETAL_AT = [22, 26, 30, 34, 38];
|
||||
const CAN_AT = -42;
|
||||
const WINDBREAK_AT = 48;
|
||||
/** Where the windbreak must be dropped: her windward (left) side, the wind's side. */
|
||||
const DROP: { x0: number; y0: number; x1: number; y1: number } = { x0: 112, y0: 110, x1: 172, y1: 200 };
|
||||
|
||||
// --- What the gardener is doing ---------------------------------------------
|
||||
let activity = $state<Activity>('idle');
|
||||
let activityTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
/** The gardener walks over and does it, then goes back to stand beside her. */
|
||||
export function act(kind: Activity, ms = 1600): void {
|
||||
activity = kind;
|
||||
clearTimeout(activityTimer);
|
||||
if (kind !== 'pour') activityTimer = setTimeout(() => (activity = 'idle'), ms);
|
||||
}
|
||||
$effect(() => () => clearTimeout(activityTimer));
|
||||
$effect(() => {
|
||||
// Only `pouring` drives this; the activity it sets is read without tracking.
|
||||
if (pouring) act('pour');
|
||||
else if (untrack(() => activity) === 'pour') activity = 'idle';
|
||||
});
|
||||
const STATION: Record<Activity, { at: number; pose: Pose }> = {
|
||||
idle: { at: -28, pose: 'stand' },
|
||||
pour: { at: -15, pose: 'pour' },
|
||||
weeds: { at: 4, pose: 'pull' },
|
||||
petals: { at: 20, pose: 'sweep' },
|
||||
shade: { at: -18, pose: 'carry' },
|
||||
touch: { at: -10, pose: 'reach' }
|
||||
};
|
||||
const station = $derived(STATION[activity]);
|
||||
|
||||
// --- The player's hand ------------------------------------------------------
|
||||
type Drag =
|
||||
| { kind: 'rose'; samples: Sample[] }
|
||||
| { kind: 'can'; samples: Sample[] }
|
||||
| { kind: 'weed'; index: number; samples: Sample[] }
|
||||
| { kind: 'sweep'; samples: Sample[] }
|
||||
| { kind: 'windbreak'; samples: Sample[] };
|
||||
let drag: Drag | null = null;
|
||||
let svg = $state<SVGSVGElement>();
|
||||
let pulled = $state<ReadonlySet<number>>(new Set());
|
||||
let windbreakAt = $state<{ x: number; y: number } | null>(null);
|
||||
let said = $state('');
|
||||
|
||||
// A new day's weeds start whole: forget the pulled ones when the count changes.
|
||||
$effect(() => {
|
||||
void weeds;
|
||||
pulled = new Set();
|
||||
});
|
||||
|
||||
/** The pointer in the scene's own units. Without a layout (a test), client units are scene units. */
|
||||
function point(e: PointerEvent): Sample {
|
||||
const t = e.timeStamp || performance.now();
|
||||
const ctm = svg?.getScreenCTM?.();
|
||||
if (!svg || !ctm) return { x: e.clientX, y: e.clientY, t };
|
||||
const p = new DOMPoint(e.clientX, e.clientY).matrixTransform(ctm.inverse());
|
||||
return { x: p.x, y: p.y, t };
|
||||
}
|
||||
|
||||
function start(e: PointerEvent, next: Drag): void {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
try {
|
||||
svg?.setPointerCapture?.(e.pointerId);
|
||||
} catch (error) {
|
||||
// A synthetic pointer (a test) has nothing to capture; the gesture still works.
|
||||
void error;
|
||||
}
|
||||
drag = next;
|
||||
if (next.kind === 'can') onpourstart();
|
||||
if (next.kind === 'windbreak') windbreakAt = next.samples[0] ?? null;
|
||||
}
|
||||
|
||||
function move(e: PointerEvent): void {
|
||||
if (!drag) return;
|
||||
const p = point(e);
|
||||
drag.samples.push(p);
|
||||
if (drag.kind === 'can') onpourtilt(tiltOf(drag.samples[0]!, p));
|
||||
if (drag.kind === 'windbreak') windbreakAt = p;
|
||||
}
|
||||
|
||||
function end(e: PointerEvent): void {
|
||||
if (!drag) return;
|
||||
const d = drag;
|
||||
drag = null;
|
||||
d.samples.push(point(e));
|
||||
switch (d.kind) {
|
||||
case 'rose': {
|
||||
const kind = strokeOf(d.samples);
|
||||
if (kind === 'stroke') {
|
||||
act('touch');
|
||||
said = en.scene.did.touch;
|
||||
onstroke();
|
||||
} else if (kind === 'tap') onrose();
|
||||
break;
|
||||
}
|
||||
case 'can':
|
||||
onpourend();
|
||||
said = en.scene.did.water;
|
||||
break;
|
||||
case 'weed':
|
||||
if (isPull(d.samples) && !pulled.has(d.index)) {
|
||||
pulled = new Set([...pulled, d.index]);
|
||||
act('weeds', 900);
|
||||
said = en.scene.did.weed;
|
||||
if (pulled.size >= weeds) onweeds();
|
||||
}
|
||||
break;
|
||||
case 'sweep': {
|
||||
const xs = PETAL_AT.slice(0, petals).map((a) => surface(a).x);
|
||||
if (petals > 0 && isSweep(d.samples, Math.min(...xs), Math.max(...xs))) {
|
||||
act('petals');
|
||||
said = en.scene.did.petals;
|
||||
onpetals();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'windbreak': {
|
||||
const at = d.samples[d.samples.length - 1]!;
|
||||
windbreakAt = null;
|
||||
if (inside(at, DROP)) {
|
||||
act('shade');
|
||||
said = en.scene.did.shade;
|
||||
onshade();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const SKY: Record<Light, [string, string]> = { day: ['#a9cbe0', '#e8f0ec'], golden: ['#f2b860', '#e9846a'], night: ['#2e3561', '#46557a'] };
|
||||
const sky = $derived(SKY[light]);
|
||||
const rose = surface(0);
|
||||
const can = surface(CAN_AT);
|
||||
const resting = surface(WINDBREAK_AT);
|
||||
const chair = surface(62);
|
||||
</script>
|
||||
|
||||
<div class="planet" class:reduced>
|
||||
<svg
|
||||
bind:this={svg}
|
||||
viewBox="0 0 360 400"
|
||||
role="group"
|
||||
aria-label={en.scene.planet}
|
||||
onpointerdown={(e) => {
|
||||
if (petals > 0) start(e, { kind: 'sweep', samples: [point(e)] });
|
||||
}}
|
||||
onpointermove={move}
|
||||
onpointerup={end}
|
||||
onpointercancel={() => {
|
||||
if (drag?.kind === 'can') onpourend();
|
||||
drag = null;
|
||||
windbreakAt = null;
|
||||
}}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id="planet-sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color={sky[0]} />
|
||||
<stop offset="1" stop-color={sky[1]} />
|
||||
</linearGradient>
|
||||
<radialGradient id="planet-ground" cx="0.4" cy="0.3" r="0.8">
|
||||
<stop offset="0" stop-color="#b9d39c" />
|
||||
<stop offset="1" stop-color="#7fa07a" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<!-- The sky follows the real sun (engine lightAt). Stars are never invented here (STYLE.md S5). -->
|
||||
<rect width="360" height="400" fill="url(#planet-sky)" />
|
||||
|
||||
{#if wind}
|
||||
<g class="gust" aria-hidden="true">
|
||||
{#each [70, 95, 120] as y (y)}<path d="M10 {y} q 40 -14 80 0 t 70 -6" fill="none" stroke="#fbf6f1" stroke-width="3" stroke-linecap="round" opacity=".7" />{/each}
|
||||
</g>
|
||||
{/if}
|
||||
|
||||
<!-- Her small round world: meadow over warm earth, a low dry-stone wall, her bed, the chair. -->
|
||||
<circle cx={CX} cy={CY} r={R} fill="url(#planet-ground)" stroke="#3a2730" stroke-width="3" />
|
||||
<path d="M{CX - 70} {CY + 40} q 70 50 140 0" fill="none" stroke="#8a6248" stroke-width="10" opacity=".25" />
|
||||
{#each [-58, -52, -46, 46, 52] as a (a)}
|
||||
{@const s = surface(a, 3)}
|
||||
<ellipse cx={s.x} cy={s.y} rx="6" ry="4" fill="#c9bcae" stroke="#3a2730" stroke-width="1.5" transform="rotate({a} {s.x} {s.y})" />
|
||||
{/each}
|
||||
<ellipse cx={rose.x} cy={TOP + 2} rx="34" ry="8" fill="#8a6248" stroke="#3a2730" stroke-width="2" />
|
||||
<g transform="translate({chair.x} {chair.y}) rotate(62)" aria-hidden="true">
|
||||
<rect x="-9" y="-26" width="18" height="16" rx="2" fill="#b98a5a" stroke="#3a2730" stroke-width="1.5" />
|
||||
<rect x="-10" y="-12" width="20" height="4" fill="#f2b5be" stroke="#3a2730" stroke-width="1.5" />
|
||||
<path d="M-8 -8 v 8 M8 -8 v 8" stroke="#b98a5a" stroke-width="2.5" />
|
||||
</g>
|
||||
|
||||
<!-- The rose: her picture stands on top of the world; a tap opens her care, a slow stroke touches her. -->
|
||||
<image href={picture} x={rose.x - 24} y={TOP - 128} width="48" height="128" role="img" aria-label={alt} class:turned />
|
||||
<rect
|
||||
bind:this={roseTarget}
|
||||
x={rose.x - 28}
|
||||
y={TOP - 132}
|
||||
width="56"
|
||||
height="132"
|
||||
fill="transparent"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label={en.rose.care}
|
||||
aria-expanded={ringOpen}
|
||||
class="target"
|
||||
onpointerdown={(e) => start(e, { kind: 'rose', samples: [point(e)] })}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
if (!e.repeat) onrose();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<!-- Weeds in her bed: swipe each one up and out. -->
|
||||
{#each WEED_AT.slice(0, weeds) as a, i (a)}
|
||||
{#if !pulled.has(i)}
|
||||
{@const s = surface(a, 1)}
|
||||
<g
|
||||
class="weed target"
|
||||
transform="translate({s.x} {s.y}) rotate({a})"
|
||||
role="img"
|
||||
aria-label={en.scene.weed}
|
||||
onpointerdown={(e) => start(e, { kind: 'weed', index: i, samples: [point(e)] })}
|
||||
>
|
||||
<rect x="-10" y="-22" width="20" height="26" fill="transparent" />
|
||||
<path d="M0 0 l -6 -14 l 5 4 l 1 -10 l 3 8 l 4 -6 l -2 18 z" fill="#7fa07a" stroke="#3a2730" stroke-width="1.5" />
|
||||
</g>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
<!-- Fallen petals on the grass: sweep across them. -->
|
||||
{#each PETAL_AT.slice(0, petals) as a (a)}
|
||||
{@const s = surface(a, 2)}
|
||||
<ellipse cx={s.x} cy={s.y} rx="5" ry="3" fill="#c85a6e" stroke="#3a2730" stroke-width="1" transform="rotate({a + 30} {s.x} {s.y})" role="img" aria-label={en.scene.petals} />
|
||||
{/each}
|
||||
|
||||
<!-- The windbreak, only on a windy hour: drag it to her windward side. -->
|
||||
{#if wind}
|
||||
<rect x={DROP.x0} y={DROP.y0} width={DROP.x1 - DROP.x0} height={DROP.y1 - DROP.y0} rx="10" fill="#fbf6f1" opacity={windbreakAt ? 0.25 : 0} aria-hidden="true" />
|
||||
{@const at = windbreakAt ?? resting}
|
||||
<g
|
||||
class="windbreak target"
|
||||
transform="translate({at.x} {at.y}) rotate({windbreakAt ? 0 : WINDBREAK_AT})"
|
||||
role="img"
|
||||
aria-label={en.scene.windbreak}
|
||||
onpointerdown={(e) => start(e, { kind: 'windbreak', samples: [point(e)] })}
|
||||
>
|
||||
<rect x="-16" y="-24" width="32" height="26" fill="transparent" />
|
||||
{#each [-12, -6, 0, 6, 12] as x (x)}<path d="M{x} 0 v -20" stroke="#b98a5a" stroke-width="4" stroke-linecap="round" />{/each}
|
||||
</g>
|
||||
{/if}
|
||||
|
||||
<!-- The watering can by the bed: press it and tilt to pour. -->
|
||||
{#if !pouring}
|
||||
<g
|
||||
class="can target"
|
||||
transform="translate({can.x} {can.y}) rotate({CAN_AT})"
|
||||
role="img"
|
||||
aria-label={en.scene.can}
|
||||
onpointerdown={(e) => start(e, { kind: 'can', samples: [point(e)] })}
|
||||
>
|
||||
<rect x="-14" y="-22" width="28" height="24" fill="transparent" />
|
||||
<rect x="-9" y="-14" width="18" height="14" rx="4" fill="#7fa07a" stroke="#3a2730" stroke-width="1.5" />
|
||||
<path d="M-9 -9 l -8 -6" stroke="#3a2730" stroke-width="2.5" stroke-linecap="round" />
|
||||
</g>
|
||||
{:else}
|
||||
{@const p = surface(-6, 40)}
|
||||
<g aria-hidden="true">
|
||||
{#each [0, 1, 2] as i (i)}<circle cx={p.x + 4 + i * 3} cy={p.y + 8 + i * 9} r={1.5 + tilt} fill="#9cc3d8" />{/each}
|
||||
</g>
|
||||
{/if}
|
||||
|
||||
<!-- The gardener: walks round the world to where the work is. -->
|
||||
<g class="walker" style:transform="rotate({station.at}deg)" style:transform-origin="{CX}px {CY}px">
|
||||
<g transform="translate({CX} {TOP})">
|
||||
<Gardener {look} pose={station.pose} {tilt} />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<p class="sr-only" aria-live="polite">{said}</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.planet {
|
||||
width: min(100%, 26rem);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: 1.25rem;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.target {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.target:focus-visible {
|
||||
outline: 3px solid var(--rose);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
image.turned {
|
||||
transform-box: fill-box;
|
||||
transform-origin: 50% 100%;
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
|
||||
.walker {
|
||||
transition: transform 0.9s ease-in-out;
|
||||
}
|
||||
|
||||
.reduced .walker {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.gust path {
|
||||
animation: gust 2.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes gust {
|
||||
from {
|
||||
transform: translateX(-20px);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
to {
|
||||
transform: translateX(40px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { Gardener } from '@rosea/schema';
|
||||
|
||||
/** The gardener the choice starts from, and who tends her if the device could not keep a choice. */
|
||||
export const FIRST_LOOK: Gardener = { presentation: 'girl', skin: 'skin-3', hair: 'braids', hairColour: 'brown', clothes: 'sage', hat: 'straw-hat' };
|
||||
Reference in New Issue
Block a user