CharacterMarkMirror
把已经在运行的角色再画一遍,画到别处。
source
mirror
mirror
mirror
mirror
一个引擎,五个角色,五种墨色。镜像是指向源根分组的 <use href> 元素。
换墨色不必再跑一份动画
墨色是可继承的 CSS 自定义属性,所以它在 <use> 所在处解析,而不是在源的定义处。每个镜像设置自己的 --aora-fg,共享几何会捡起来。
尺寸同理——它设在外层,而不是 SVG 内部。
一页里 id 必须唯一
sourceId 会变成 DOM id,<use href="#id"> 解析到文档里的第一个匹配。同一页上两个相同 id 的源,意味着每个镜像都指向第一个。
优先使用 MarkStageProvider,它用 useId 推导 id,不会碰撞——即使一页上有好几个 Provider,而这正是带多个示例的文档站点会产生的情况。
API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
sourceId* | string | — | Id of a mounted `CharacterMark`'s root group. |
children | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | null | — | — |
className | string | — | — |
color | "black" | "brown" | "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "violet" | "magenta" | "pink" | "gray" | 'black' | — |
eyeColor | string | — | — |
face | "cute" | "eyes" | "line" | — | Face style of the source, echoed as `data-face`. The geometry itself comes from the source. |
lineWeight | number | — | Stroke weight of the source, echoed as `data-line-weight`. |
nose | "slant" | "angular" | "hook" | "long" | "curve" | "bow" | null | — | Nose of the source, echoed as `data-nose`. `null` means the source draws none. |
sizeCss | string | number | — | — |
sizePx | number | — | — |
state | "idle" | "sleeping" | "drowsy" | "bored" | "waking" | "powering-down" | "listening" | "thinking" | "searching" | "reading" | "writing" | "working" | "loading" | "progress" | "radar" | "orbit" | "dictating" | "uploading" | "sending" | "receiving" | "messaging" | "waiting" | "spawning" | "composing" | "dragging" | "happy" | "excited" | "laughing" | "playful" | "proud" | "celebrate" | "bouncing" | "shy" | "sad" | "angry" | "confused" | "suspicious" | "surprised" | "scared" | "curious" | "humming" | "alerting" | "notifying" | "refusing" | 'idle' | — |
style | CSSProperties | — | — |
styleId | StyleId | — | Style series of the source, echoed as `data-style`. |
styleOptions | Record<string, unknown> | — | Style parameters of the source, echoed as `data-style-options`. |
variant | StyleVariant | — | Variant of the source, echoed as `data-variant`. |
接下来
- MarkStageProvider——按外观共享引擎
- 性能——怎样渲染上百个角色