Snapshot of the Umamo working tree as it is

Uploaded as-is from /home/litruv/dev/vtsmaker/umamo on 2026-11-03. 1347 files.
Includes the uncommitted work in progress in :edit, :runtime, and :ui, and the
untracked files under module/edit/src/jvmAndroidMain/.

History is not carried over. The source repo is https://github.com/umamoorg/umamo.
This commit is contained in:
litruv
2026-11-03 18:20:25 +11:00
commit 8bd8fa7a0b
1347 changed files with 246161 additions and 0 deletions
+340
View File
@@ -0,0 +1,340 @@
# CLAUDE.md — Umamo
## What This Is?
Umamo is an open-source cross-platform rigging editor for 2D puppet animation, with first class pen and touch support, built as a drop-in replacement for the Live2D Cubism Editor.
- **Language:** Kotlin, Kotlin Multiplatform (shared core across desktop + Android).
- **Package root:** `org.umamo` (reverse-DNS of the `umamo.org` domain). Shared library modules are flat — `org.umamo.format`, `org.umamo.runtime`, `org.umamo.interop`, `org.umamo.render`, `org.umamo.ui`, `org.umamo.reimport`. App code carries product + platform — `org.umamo.editor.desktop`, `org.umamo.editor.android` (a future viewer takes `org.umamo.viewer.*`); the headless diagnostic tool is `org.umamo.cli` (JVM-only). The editor's Android `applicationId` is `org.umamo.editor`, keeping bare `org.umamo` a clean umbrella.
- **Platforms:** Windows, macOS, Linux (keyboard/mouse/pen) **and Android tablets** (pen/touch — e.g. Wacom MovinkPad). Rigging is a first-class workflow on **all** of these, not desktop-only.
- **Headline workflow:** draw in Clip Studio Paint (or Photoshop), save/export, switch to Umamo, and the rig **refreshes against the updated art** without losing rigging work.
- **Compatibility is the product:** read and write the existing Cubism source format so riggers can adopt incrementally and interoperate with the official editor.
## The Thesis (do not let this drift)
v1's win condition is **a CMO3-native rigging editor that interoperates with the official Cubism Editor**:
1. **Read and write `.cmo3`** (editor source) → a rigger can bounce the same project between Umamo and the official Cubism Editor without burning bridges. This bidirectional interop is the primary adoption wedge.
2. **Ingest source art** (PSD, CLIP, KRA with robust layer ID matching — see Re-import) and keep the rig live against art changes.
3. **GPU-accelerated, trustworthy preview** — the viewport deformation must match what a rigger would see in Cubism so they can trust what they're authoring.
Runtime concerns (MOC3 emit, SDK/Core replacement) are a work in progress — see Format Support. If a proposed change trades away source-format compatibility or the refresh workflow for internal elegance, it is wrong by definition. Raise it, don't silently take it.
## Format Support (priority order)
- **UMA — read AND write, and the app's Open/Save.** Native Umamo format: a ZIP of per-domain JSON entries (the puppet graph with its bulk arrays in a buffer entry, the atlas with its pixel entries, the linked source art) under a manifest whose compatibility rules open a newer file read-only or carry what this reader cannot interpret byte for byte. `object Uma : FormatCodec<UmaModel>` lives in `:format` `uma/`; `UmaDocumentBridge` in `:interop` `uma/` maps a document to and from `PuppetModel`; `UmaDocument` (`:ui` jvmAndroidMain `document/`) is what File > Open loads and `writeUmaDocument` is what Save writes, laid over the file as opened so unknown keys and held tiles survive; the save target lives in a `DocumentFile` beside the session, not on the document. Editor state (`editor/state.json`, never an input to the model) rides each save as a merge patch: per-area view state and cameras through `AreaViewStates` (`:ui` `workspace/`), keyed by the layout's area ids, and the session's pose, selection, mode, cursors, and tool settings through `SessionViewState` (`:edit`), laid into the session's first snapshot so nothing restored is an undo step. Spec: `docs/format/UMA.md`; decisions and roadmap: `docs/plan/uma-format.md`.
- **CMO3 — read AND write, with edit-to-CMO3 lowering.** A CMO3 is the native format for the Cubism editor, and an interop boundary for Umamo: the UI offers it as Import/Export (Open/Save is reserved for UMA). `Cmo3.write` round-trips an unedited file's **decompressed `main.xml` byte-for-byte** — not the whole file; see the Fidelity contract. Export is a **state-based reconcile**: `Cmo3Export.apply` (`:interop` jvmAndroidMain) re-imports the retained graph as a baseline, diffs the session's model against it, and patches only what changed — flat fields, base geometry/UVs, the keyform grid web (re-bundled via `refinedToUnion`), blend shapes, and structural create/delete for every entity category. A MOC3-origin document (no retained graph) exports through **fresh-graph synthesis**: `Cmo3Conversion.freshCmo3` builds a blank BareMinimum-shaped skeleton plus a per-page image chain and runs the SAME reconcile against the empty baseline. Anything unrepresentable surfaces as an `ExportNotice`, never a silent drop. See `docs/format/CMO3.md` § Export.
- **PSD — read.** Layered-art ingestion. Re-import join key is the lyid layer id when present (Photoshop-written, stable across rename/reorder), else layer name/path + order (lossy; some exporters omit lyid, so CLIP/KRA with always-present stable ids stay more robust). See `docs/format/PSD.md`.
- **CLIP (Clip Studio Paint) — read.** Layered-art ingestion, proprietary (SQLite-based container). Implemented: layer tree + raster decode, registered in `FormatRegistry` with corpus-backed tests. See `docs/format/CLIP.md`.
- **KRA (Krita) — read.** Layered-art ingestion, open source format. See `docs/format/KRA.md`.
- **MOC3 — read AND write.** Serialized C structs (memory-cast, so byte-exact layout). See `docs/format/MOC3.md`.
- **JSON family**: `model3` (manifest), `physics3`, `cdi3`, `pose3`, `exp3`, `motion3`, `userdata3`, texture atlas.
PSD/CLIP/KRA (and flat rasters, wrapped as one layer) come in through **File > Import > Artwork…** (or the Sources space's button — one command, `file.importArtwork`), which ADDS the file's layers to the OPEN document as one undo step, Blender-style, rather than replacing it: the editor always has a document, starting with the empty one it opens into. `SourceArtImport` (`:interop` `org.umamo.interop.art`) is the source-art → `PuppetModel` bridge — one drawable per raster layer over a quad birth mesh, one part per folder, the source-layer binding persisted on the tile (`AtlasTile.source`) with the file and its layer inventory on `PuppetModel.sources`. A rig's FIRST artwork also gives it the file's canvas, the world origin at that canvas's center, and the parameters of the `import.parameterTemplate` setting (Humanoid by default); a later file is placed on that canvas by the import's Align anchor and Offset rows on the operation strip (its record keeps the offset as `ArtSource.offsetX/Z`, x right and z up like the viewport, and every later read of the file is placed by it before the model sees the art), packed into the gaps with existing art held fixed, and redefines neither. A CMO3 export of such a document runs the fresh-graph synthesis with the document's own rasters, so the CMO3 carries the real layers and folders and reopens keyed by lyid (Phase H1); a CMO3-origin document's reloaded and added art is written into its retained graph the same way (H2); a MOC3-origin export still slices its layers out of the pages. See `docs/plan/art-sourcing-pipeline.md` Phase E.
**Unified codec contract.** Every binary container format presents the same face to the rest of the project: a `FormatCodec<TModel>` in `:format` (`kind`/`matches`/`read(ByteArray)`/`write(TModel)`, tied to `FileKind`), with `FormatRegistry` doing detect-by-magic and resolve-by-kind. CMO3 (`object Cmo3`, in `jvmAndroidMain` — JDOM/reflection are JVM-only) and MOC3 (`object Moc3`, `commonMain`) both implement it; the in-memory model type differs per format and shares no supertype (hence the generic). The **JSON sidecars are `String`-shaped, not bytes**, so they deliberately sit *outside* the codec contract as plain helpers on `Moc3` (`readModel3`/`writeModel3`/…). Add a format by implementing the interface and registering it — never by growing a bespoke read/write facade.
## Architecture
### UI: Compose Multiplatform + Embedded GPU Viewport
The editor UI is **Compose Multiplatform** — Jetpack Compose on Android, Compose Desktop (Skiko) on Win/Mac/Linux. One UI codebase, idiomatic pen/touch/gesture input. **Not ImGui** (desktop/mouse-only, no Android pen story). **Not Swing/JavaFX** as UI.
The puppet canvas is a **GPU surface composited into Compose**:
- Desktop (shipped): LWJGL renders offscreen through a hidden GLFW context; the frame is copied into a Compose `Image` — there is no Swing/AWT interop in this path. See `OffscreenPuppetService` / `:desktop` in the module graph.
- Android (not yet implemented): the target is a GLES surface composited the same way; today `:android` mounts the shared shell with a null viewport factory, so viewport areas render placeholders. See `:android` in the module graph.
**Pen input (design target, not yet implemented):** no stylus/pressure/tilt code exists anywhere in the repo yet. The intended split is Android stylus (`MotionEvent` pressure/tilt/hover) as the easier target, desktop JVM pen as the harder one (plan for JPen or Wintab/Windows Ink).
### Panels & docking
**One interface, desktop and tablet.** The same edge-docked UI runs everywhere, modeled on Krita and Clip Studio Paint's desktop mode — both run their full desktop UI on Android tablets, and that is sufficient. There is **no separate slim tablet UI to maintain.** The tablet gets a touch-tuned _skin_ of the same interface, not a second front-end: larger hit targets, more panels collapsed-to-rail by default, the pen radial menu carrying tool switching, and the menubar folded into an overflow rather than a top strip.
**Blender-style area tree, not free-floating**:
- The window content is a **recursive binary-split tree of areas**. Each area hosts exactly one **editor space** — the ten `SpaceKind`s are 2D viewport, UV editor, sources (the source-art linking table), outliner, parameters, keyform sheet, properties, tool details, history (undo stack, click an entry to jump to that state; deformers live in the outliner/parameters, not a separate space), and logs — and the space is **agnostic and switchable at runtime** via a dropdown in the area's top-left header — any area can become any space (turn the outliner into a tiny viewport if you like, exactly like Blender).
- Areas split along any edge into nested areas and merge/close; **splitters are draggable** with a min-size clamp; a Blender-style **corner-drag gesture joins two adjacent areas** back into one.
- A window holds **multiple named workspaces as tabs** (create/duplicate/rename/reorder/reset), each with its own area tree; a single workspace or the whole layout can be exported/imported as text.
- Each area also has a **right-click context menu** mirroring its header actions plus "Change Editor Type."
- **Free-floating / tear-off windows remain out of scope** — everything is tiled inside the window; this keeps the layout engine small.
- An area's shape does not restrict which space it may host (no "tall panels left/right, wide panels top/bottom" rail constraint).
Concretely the shell is `org.umamo.ui.workspace`: a sealed `AreaNode` (split/leaf) tree per `Workspace`, rendered by a recursive Compose layout (`AreaTree`/`SplitContainer` + a draggable `Splitter`) — a tractable custom layout, not an IDE-grade free-float dock manager. Row drag-and-drop inside a space (the outliner, the parameters panel, the Sources table) is one shared kit in `org.umamo.ui.workspace.rowdrag`: the drag controller and hit-test, the Escape cancel seam, the long-press pickup, the cursor chip, and the drop-target ring; a space adds only its payload type and its drop rule. The 2D GL viewport stays platform code in the app, injected into a leaf via a `ViewportHost` seam (per-area surface kept alive across tree mutations with `movableContentOf`).
**Defaults carry the opinion.** Each workspace ships a curated default area tree (Modelling = parameters, a viewport over the keyform sheet, and outliner over properties; Texture = stacked UV editors, a viewport, and a sources/outliner/properties column); user rearrangement is the customization layer on top, persisted to settings `interface.layout`; "reset layout" reseeds the defaults. This is how the tool stays focused while configurable — the workspaces own the good arrangements, so configurability is the escape hatch, not the primary interaction.
### The tool surface is small and bounded
2D rigging is not a tool-complex process. So the panel inventory is knowable up front:
- **Canvas / viewport** — the GPU work surface.
- **Parts** — drawable + deformer hierarchy (with a Project view: source-image → model-image binding).
- **Parameters** — the rigging cockpit (sliders, multi-key 2D pad, keyform binding).
- **Properties** — a tabbed mega-panel over the document and the selected item: Document (canvas, runtime targets), Object (transform, relations), Data (type-specific — mesh/texture/blend, deformer, part), with a header search that filters to matching rows. Tabs come from an extensible `PropertyTabRegistry`, so a section is registered, never wired into a render switch.
- **Keyform sheet** — per-(item, channel) tracks over the parameter targeted in the Parameters panel. Its track widgets live in `org.umamo.ui.tracks` and are **domain-agnostic on purpose** (`TrackAxis` is the only place a domain appears), so the later time-based animation dope sheet reuses them; nothing about parameters, keyform grids, or `PuppetModel` may appear in that package. The `dopesheet` serialization key is deliberately left free for that editor.
- **Tool details** — context for the active tool.
- **History** — undo-history stack; click an entry to jump to that state.
- **Sources** — the source-art linking table: artwork file → layer (inventory as of the last read) → tile → drawables, each row tinted by status (present/missing file, bound/bound-by-name/unbound, placed/unplaced) with a filter. Dragging a layer row onto a tile row (or the reverse) rebinds it; Import Artwork…, Reload, Replace Artwork…, and Match Automatically each land as one undo step, with a Match Threshold row on the operation strip where matching applies. An unbound layer's chip can ignore it (a reload then never re-mints it). See § Re-import below for the reconcile/matcher mechanics.
- **Logs** — the diagnostic console.
Animation later adds wide, bottom-docked panels (timeline, keyframe/graph editors). Because the set is small and known, the dock shell can be defined early without churn — but get the core rigging working in the default layout first; freeform rearrangement is a fast follow, not a prerequisite.
### Commands, key bindings & input
A central **action registry** is the spine of input: every operation is a named command (`mesh.subdivide`, `param.addKeyform`, `view.fit`, …). Menus, the toolbar, the pen radial menu, and keyboard shortcuts **all dispatch through it** — nothing hardcodes a handler. Design this in early; it's cheap up front and painful to retrofit after handlers are wired directly.
- **Editable, persisted keymaps** with presets — default, a **Cubism-like** preset (so migrants keep their muscle memory), and a **Blender-like** one (matches the editing model we're borrowing). Detect conflicts; scope bindings per mode/context where a key's meaning differs.
- **Bindable inputs are not just the keyboard, in principle:** the design allows stylus barrel buttons, tablet express keys, and mouse buttons to bind to actions too, so a keyboardless tablet can still reach every command. Not yet wired — today only keyboard chords resolve through the keymap.
- Store a logical **primary modifier** (→ Cmd on macOS, Ctrl elsewhere), not a literal "Ctrl"; bind by **key position**, not character, so shortcuts survive non-QWERTY layouts.
- A searchable **command palette** falls out almost free from the registry — a strong discoverability / onboarding aid for rigging's harder abstractions.
- **Pie/radial menus** (`PieMenuKind` — pivot mode, snap, merge-target, …) are a second dispatch mechanism alongside the palette, built for pen/touch reach rather than search.
Implemented (`:ui`'s `org.umamo.ui.action`): `Command`/`CommandHandler`/`CommandRegistry` (as `LocalCommands`), chords via `KeyChord`/`parseKeyChord` resolved through a `Keymap` (key position + a logical primary modifier). `org.umamo.ui.workspace.commands` holds every command table, one file per domain, each a builder returning `List<Command>` registered through `registerAll` (which returns the matching cleanup, so registration and unregistration can't drift apart). A `Command` also declares the spaces it belongs to (`spaces: CommandSpaces`, read off what its handler's routing really does, never narrower) and an optional short status-bar `hint`; both filter the palette and the status bar only — dispatch and the keymap never read them. A `Command(...)` built anywhere else is a bug — the table is the declaration, the handler just a lambda; that split is why the app's `file.*` tables stay in this commonMain package while the document loader behind them lives in `jvmAndroidMain` (`org.umamo.ui.app`'s controllers); `logs.export` and the `workspace.*` file commands need only a picker, so the settings-backed shell registers them.
`commands/CommandRouting.kt` is the one place a command resolves "which area does the pointer mean," backed by a single hovered-surface resolver (`Modifier.stampsHoveredSurface`, installed once by `AreaLeaf` so every space kind is covered automatically). There is no viewport-only fallback: a command needing a viewport that finds none does nothing rather than reaching back to one the pointer has left (Blender's hovered-area rule). A request that must execute in one specific area carries that area in its payload instead (`SnapRequest`, `SelectLinkedRequest`, `UvSnapRequest`), so each overlay collector gates on its own id.
`handleShellKey` is the live dispatch path (`KeyChord` → `Keymap.commandFor` → `registry.invoke`); `CommandPalette` lists `registry.all()`. New operations register a `Command` and bind a chord — never wire a handler into a widget. The keymap itself is editable and persisted via `KeymapPersistence` (`default`/`cubism`/`blender` presets plus per-command overrides, reactive), with a keybindings editor in Settings.
### Localization (EN/JA/KO)
The audience is heavily Japanese and the primary developer is bilingual — so **EN + JA are first-class from day one**, not retrofitted. Compose Multiplatform's resources system (`stringResource`, per-locale resources) is the mechanism.
- **Externalize every UI string** from the start; no hardcoded literals. Build the pipeline for *N* locales, not just two.
- **Localize chrome and display names — never format-level identifiers.** Parameter IDs like `ParamAngleX` are part of the CMO3/Cubism data model and stay verbatim for interop; `cdi3.json` display names and the user's own part names are user data, not ours to translate. Two layers: Umamo's UI (we localize) vs the document's names/IDs (we don't).
- **CJK gotchas to test deliberately:** Skiko font fallback must cover JA glyphs on desktop *and* Android (bundle a CJK-capable font). Don't assume EN string widths in the dock/panel layout.
- RTL is out of scope for v1, but don't structurally preclude it.
### Settings, storage & the app shell
The **settings/storage foundation is built first** — it backs keymaps, layout, theme, and recent files, so nothing hardcodes config that has to be ripped out later. Two modules:
- **`:storage`** — per-OS config/data directories + file IO over **okio** (Kotlin's stdlib has no common `File`; `java.io.File` is JVM-only), and a `FilePicker` open/save-dialog contract backed by **FileKit** — one commonMain `FileKitFilePicker` over each OS's native dialog (Win32 `IFileDialog`, Cocoa, GTK/portal) plus Android SAF, replacing the old desktop-only AWT `FileDialog`. Because FileKit already spans platforms there is no per-platform picker impl: desktop is done, and Android needs only `FileKit.init(activity)` in its `Activity` (it owns the result registry) — no separate SAF implementation. The contract returns FileKit's `PlatformFile`, not an okio `Path`: Android SAF hands back a `content://` URI with no real filesystem path that a `Path` cannot model. Platform factories `desktopAppStorage` / `androidAppStorage` resolve the dirs.
- **`:settings`** — a JSON tree of **bundled defaults ← user overrides** (← vendor extension defaults, later), addressed by **dotted keys** (`getString("interface.theme")`). No caller passes a default — `defaultSettings.json` (a Compose-MP resource in `:ui`, shared cross-platform) is the single baseline. Writes hit the *user* layer only, persist via `:storage`, and emit the changed key on a `changes: SharedFlow` (the reactive spine the UI / keymap / undo-History collect). Held as a dynamic `JsonObject`, not typed `@Serializable` classes (settings are open-ended + merged); typed per-domain views layer on later. Namespaces in use today: `interface.*` (theme, the undo-step cap pushed into `EditorSession.historyLimit`, the workspace area-tree layout, window geometry, viewport toolbar/sidebar visibility), `input.keybinding.*` (the keymap preset + overrides), `viewport.*` (zoom steps, selection/warning/pinned colors, grid, the `meshEdit.*` mesh-edit colors), `localization.locale`, and `import.*` (`parameterTemplate`, `alignment`, `watchMode`, `deleteArtIgnoresLayer`, `layerPositionsFromWorldAxes` — see § Re-import). See `defaultSettings.json` for the exact key list; `app.launchCount` and `input.pen.backend` are reserved there but genuinely unread/unwritten today.
Apps load settings at startup and provide the instance through a `LocalSettings` composition local — the desktop loads **synchronously** so the saved window state is ready before the (unconditional) window opens; `application {}` exits if it ever has zero windows, so an async settings gate would close it. The **app shell is shared in `:ui`** (`org.umamo.ui.app`, jvmAndroidMain - `EditorApp` is wiring only, over one controller per responsibility: save, open, export, artwork, the source watcher): the File / Edit / Workspace / Help menu bar, a Preferences window (`edit.preferences`, holds the keybindings editor and other settings sections), Help Credits/About, the `Document` layer (CMO3/MOC3 import and CMO3 export via FileKit — Open/Save is reserved for UMA — recent files, the dirty-replace confirm, the export report alert), live locale switching, live keymap reload on preset/rebind, and the per-document session wiring. `:desktop` owns the window (geometry persisted to settings, title dirty-marker, the LWJGL offscreen render service); `:android` owns the Activity and mounts the same shell with a null viewport factory until the GLES renderer lands — Android does have renderer groundwork (`GpuRenderer.android.kt`: GLES20/30 grid + axis shaders), just not a puppet-deformation renderer or the Compose-image bridge yet.
**Use the foundation, don't reinvent it:** new config (a keymap preset, a panel layout, a pen binding) is a settings key under its namespace via `Settings`; file open/save goes through `FilePicker`; app-data paths come from `AppStorage`.
### Deformation (the core math)
Parameter-driven morph blending, **not** skeletal: `p = base + Σ wᵢ·Δᵢ`, multilinear interpolation across an N-dimensional grid of keyforms. Warp deformers are FFD lattices; rotation deformers are a nesting pivot-transform hierarchy. Weights are computed CPU-side per frame (cheap; depend only on parameters); the per-vertex weighted delta-sum runs in a vertex shader. None of this maps onto any engine's built-in rig — it is ours.
### Mesh-editing interaction model
Mesh and keyform-deformation editing should feel like **sculpting, not CAD**, adopting Blender's UV-editor interactions.
- **Proportional editing — shipped.** Moving one vertex drags its neighbours within an adjustable radius, with six selectable **falloff curves** (smooth / sphere / root / sharp / linear / constant) plus a geodesic "connected only" mode that follows mesh edges instead of screen-space distance (`module/edit/.../ProportionalEditing.kt`).
- **Brush radius for grab / smooth / relax — not yet implemented.** The only existing brush-radius tool today is circle-select, a selection brush, not a vertex-manipulation one; there are no grab/smooth/relax sculpt operators yet.
- **Pen-pressure-driven brush radius / falloff strength — not yet implemented.** No pressure/tilt input is wired anywhere in the codebase yet (see the Pen input note above); this stays the target pen-first advantage over Cubism's click-drag-per-vertex model once it lands.
### Project format & source model
CMO3 does **not** store the original `.psd`. On import Cubism **decomposes** the PSD into an editable, equivalent representation: a `CLayeredImage` tree of `CLayerGroup`/`CLayer` nodes, each layer's pixels stored as a separate embedded PNG (`CImageResource` → `imageFileBuf*.png`), positionally mapped. PSD is still the privileged *source* throughout the Cubism pipeline (mesh and model-image derive from it). That privilege is incompatible with first-class **CLIP** and **Krita (.kra)** support, so:
- Umamo's **native project format is source-agnostic.** PSD, CLIP, and KRA are peer sources, each retaining its own **stable layer identity** (CLIP / Krita layer IDs; PSD's lyid layer id when present, else name + order).
- **CMO3 is an interop boundary, not the native format.** A shim unwraps CMO3's decomposed layer images (the `CLayeredImage` tree + per-layer PNGs) on import and synthesizes that decomposed, PSD-derived shape on export, so CMO3 round-trip still works.
- **Do not shim CLIP/Krita down to PSD on import.** That discards the stable layer IDs that make non-destructive re-import reliable — i.e. it throws away the exact reason CLIP support is worth having. The source-agnostic native model is what preserves them.
This refines the thesis: CMO3 read/write stays primary (Cubism interop), but it is a *conversion at the boundary* layered over a custom native format — not the format you work in. The container is specified in `docs/format/UMA.md`, and File > Open/Save read and write it — see Format Support.
### Re-import / source-art binding (the headline feature's hard problem)
"File refreshes" = **non-destructive re-import keyed on stable layer identity**. Each drawable is bound to a source layer by a stable key (CLIP/Krita layer ID, or PSD's lyid when present; else PSD name/path + heuristics). On a watched-file change, reconcile:
- **Matched layer:** update its atlas region; preserve mesh/deformers/keyforms where topology still fits.
- **Moved/resized art:** adjust extents/UVs if possible; otherwise flag for re-mesh.
- **Added layer:** new unbound drawable.
- **Removed/renamed layer:** **never silently delete rig work** — flag, fuzzy-match, and make reconciliation reviewable (a diff/merge step).
This is where Live2D's own reimport is lossy; doing it well is a competitive feature.
**Status: Phase F is complete** — the binding is persisted and editable, and the reconcile by key (F1), the watcher (F2), and the fuzzy matcher with its review states (F3) are all built. The identity is ONE representation: the reader's `LayerId.raw` is the key and the reader says how strong it is (`SourceLayer.idIsStable`); it persists on the tile as `AtlasTile.source: SourceLayerRef`, and the document lists its artwork files with their pixel-free layer inventories as `PuppetModel.sources: List<ArtSource>` (the baseline a reconcile diffs against). `:reimport` holds the pipeline: `KeyReconciler` classifies bindings by key and `ArtworkReloadPlanner` turns the matched/added layers into an `ArtworkReload` the session applies and the UI packs and commits — a changed layer's tile is superseded by a new tile rather than mutated (pixels are immutable per tile id, so undo and the CMO3 export both follow the lineage root), and a removed layer is left alone, flagged for review, never dropped. `PollingSourceWatcher` + `SourceWatchCoordinator` (F2) settle a save, hash the file so an unchanged save costs nothing, and dispatch a reload under the `import.watchMode` setting (auto/notify/off); a file edited while the document was closed is reported at open, never auto-reloaded. `InventoryLayerMatcher` (F3) ranks a lost binding's candidates over the inventory (name, folder, bounds, size, content hash, and pixel similarity when the file was read) to drive the Sources space's review chips and Match Automatically. Still absent: a reader and watcher for Android's SAF uris. See `docs/plan/art-sourcing-pipeline.md` § Phase F for the full mechanics.
### Module graph (Gradle, Kotlin DSL; KMP)
```
:format commonMain — Cubism file family + art I/O. CMO3 (read/write), PSD (read),
CLIP (read), KRA (read), MOC3, JSON family.
:reimport commonMain — non-destructive reconcile over the model's source bindings: the
key reconciler, the reload planner (a changed layer's tile is
superseded, never mutated), the okio polling file watcher, the watch
coordinator (settle, hash, idle gate), and the inventory matcher with its
suggestions (names, folders, bounds, hashes, pixels). All commonMain -
nothing JVM-bound.
→ :format, :interop, :storage, :runtime (api), kotlinx-coroutines (api)
:storage commonMain — app config/data dirs + file IO (okio) + native open/save dialogs
(FileKit, one commonMain FilePicker impl); platform factories in
jvmMain/androidMain (no expect/actual). → okio, FileKit
:settings commonMain — JSON settings engine: bundled defaults ← user overrides, dotted-key
get/set, persistence, change-event Flow. → :storage, kotlinx-serialization
:runtime commonMain — the pure puppet runtime: the immutable PuppetModel + typed ids, the
keyform grid algebra, the sampling eval, and the atlas domain (PuppetAtlas:
pages + tiles, each tile's AtlasPlacement, plus the uv-affine algebra that
maps between the art's frame and a page's). The placement lives here, not
in :render, because it is authored state every consumer needs — including
the CMO3 export lowering, whose module deliberately cannot see :render.
Zero format knowledge and zero project deps — CMO3/MOC3 conversion lives
in :interop.
:interop commonMain — format↔runtime conversion: CMO3/MOC3 ingest (Cmo3Import / Moc3Import →
PuppetModel), the model diff (diffPuppetModels), export notices, and the
RuntimeTarget↔format-version mapping; jvmAndroidMain hosts the CMO3
export reconcile (Cmo3Export: diff-driven lowering onto the retained
graph) and the fresh-graph synthesis (Cmo3Conversion: blank skeleton +
image chain for MOC3-origin export). Future import/export formats and
format↔format conversions (each pivoting through PuppetModel) land
here too — including each format's atlas-page walk (`cmo3AtlasPages` /
`moc3AtlasPages` → a neutral `AtlasPageSet`), so :render never sees a
container format. `art/` is the source-art → PuppetModel bridge
(`SourceArtImport`: an UNPACKED model the app packs at open, the blend
table, the import notices; it seeds the parameter list it is handed and
knows no template).
→ :format (api), :runtime (api)
:edit commonMain — the editing session over the immutable PuppetModel: EditorSession
(snapshot-based undo History, selection + mode state, tool latches,
request buses), the sealed Change hierarchy, the pure edit ops
(mesh topology/transforms, parameter edits, proportional editing), and
the seed catalogs a new model starts from (`seed/`: ParameterTemplate +
the humanoid standard set).
→ :runtime (api), kotlinx-coroutines (api)
:render commonMain — deformation eval (CPU) + the puppet renderer + morph-blend shaders,
+ GL impl over a `RenderDevice` backend seam. → :runtime (api), :format (api).
The whole renderer is backend-neutral commonMain now: the eval, the pure
render logic (`puppet/`: glue layout, pose resolve, model diff, delta
texels, bounds), the GL-family GLSL (`glsl/`, shared by GL 3.3 + GLES 3.0
via a `GlslDialect`), the `RenderDevice` API (`device/`: handles, specs,
uniform structs, frame/pass encoders), and `PuppetRenderer` itself, which
makes ZERO GL calls — every GPU op goes through `RenderDevice`. A backend
is one `RenderDevice` impl: `GlRenderDevice` (jvmMain, LWJGL/GL 3.3 core)
ships; GLES 3.0 (android) + Metal (iOS) are ports of it, stubbed. `:render`
is zero `expect`/`actual` AND has no jvmAndroidMain — outside the backend
impls it is all commonMain. PNG decode goes through :format's `PngCodec`
(the old `decodePngToRgba` expect/actual is retired). :format is a
direct commonMain api dep — but for the NEUTRAL raster layer only
(RasterImage in the RenderDevice upload surface, PngCodec behind the atlas
decode). :render knows no CONTAINER format: the CMO3/MOC3 walks that
produce a document's atlas pages live in :interop and hand back a neutral
`AtlasPageSet` (page bytes + a drawable→page map), which the document
loader feeds to `buildPuppetTextures` here with its format's
`UndecodablePagePolicy` — CMO3 skips a bad page, MOC3 fails the import.
LWJGL is DESKTOP-ONLY.
The CPU eval (`eval/`) depends on nothing in :render and would move to
:runtime cleanly — it stays here ON PURPOSE, paired with the GPU deform
shaders it mirrors and that the differential oracle diffs it against.
That is why :ui, not :edit, owns the world-space transform helpers
(`org.umamo.ui.transform`): :edit and :render are siblings over :runtime.
:ui commonMain — Compose Multiplatform editor UI (panels, tree, timeline, parameter
grid) AND the shared app shell: the viewport composables + gizmo overlay
(`org.umamo.ui.viewport`, over the `PuppetViewportService` seam) in
commonMain, and a jvmAndroidMain (same pattern as :format) hosting the
document/file layer + shared `org.umamo.ui.app.EditorApp` — the
JDOM-backed CMO3 codec forces those off commonMain.
EDITING LOGIC OVER `EditorSession` DOES NOT LIVE HERE — an `EditorSession`
extension belongs in `:edit` (that is what the module is), and :ui keeps only
the pointer/composition bookkeeping that feeds it plain data. The ONE
exception is `org.umamo.ui.transform`, which needs :render's eval and so
cannot sit in :edit (see the :render note above). Reference split:
`KeyformCommands.kt` (:ui, resolves the hover) over `KeyformAimEdits.kt`
(:edit, decides what the edit means).
→ :render (api), :runtime, :interop, :edit, :settings, :storage, :format (jvmAndroid).
:desktop jvm — thin desktop entrypoint over the shared EditorApp: the window, settings
gate, and the LWJGL offscreen `PuppetViewportService` (GLFW hidden
context → Compose Image; no SwingPanel/AWTGLCanvas interop remains).
:android android — thin Android entrypoint (Activity) over the same shared EditorApp;
the GLES `PuppetViewportService` implementation is pending — viewport
areas render placeholders until it lands.
:cli jvm — headless diagnostic tool: dump / extract / atlas / convert / diff over
cmo3, moc3, and source artwork files. An operator's tool, not a
shipping app target, so it skips :ui and :edit entirely.
→ :interop (api brings :format, :runtime), :render
```
**On disk:** library modules live under `module/`, application targets under `app/` (e.g. `module/format`, `app/desktop`); everything else at the repo root is intentionally non-module. A module's Gradle path (`:format`, `:desktop`) is kept **flat and decoupled from its folder** via `projectDir` in `settings.gradle.kts`, so dependency declarations stay terse (`project(":format")`) and *path ≠ directory ≠ package*. Stretch-phase modules follow the same scheme.
Keep `:format`, `:reimport`, `:runtime`, `:interop`, `:edit`, `:ui` in `commonMain` so Android and desktop share them verbatim. Platform-specific code (GPU contexts, FFI, pen, windowing) lives in `jvmMain` / `androidMain`.
**Build logic that more than one module needs is a convention plugin, not a copied block.** `gradle/build-logic` is an included build (not `buildSrc` — the configuration cache is on, and a `buildSrc` edit invalidates the whole build) exposing three plugins a module opts into by id:
- **`umamo.kmp-jvmandroid`** — creates the `jvmAndroidMain` source-set group shared by the desktop-JVM and Android targets, and wires `androidMain` onto it explicitly (the hierarchy template's `withAndroidTarget()` matches the LEGACY android target, not AGP 9's KMP android-library target, so without the edge Android silently cannot see the group). Applied by `:format`, `:interop`, and `:ui`.
- **`umamo.kmp-ios-gate`** — makes `check` depend on `compileKotlinIosArm64` AND `compileTestKotlinIosArm64`. A device target has no runnable test task, so neither compile joins `check` on its own and the commonMain-purity guarantee silently stops firing. Applied by every module with an `iosArm64()` target.
- **`umamo.test-corpus`** — the golden-corpus / `-D` forwarding for sample-gated tests, declared per module in a `umamoTestCorpus { }` block. Explicit `-D` wins (resolved against the REPO ROOT, and a path that does not exist fails the build); the local gitignored corpus is the default; absent both, the test self-skips and CI stays green. The shared default table lives in `org.umamo.buildlogic.sharedCorpusDefault` — add a property there only when it means the same thing in every module.
The failure mode these guard against is the same one throughout: a gated test that cannot find its input prints and returns, so it reports PASSED while covering nothing. Never let a module hand a Test task a sample path by hand.
## Fidelity contract
Two tiers — conflating them is the classic mistake.
- **Semantic validity — CMO3 (v1 primary).** Emit a valid CAFF container whose `main.xml` encodes the same object graph; the official editor's XML deserializer rebuilds it. Whole-file byte-identity is **not** the bar and is not achieved: re-emitting an unedited corpus model differs from the original (one 4-byte field per CAFF entry), and an edit would change the bytes by construction anyway. What IS asserted, and what the tests actually check, is **decompressed-content identity**: `main.xml` inflated out of a re-emitted file is byte-for-byte the `main.xml` inflated out of the original (`Cmo3FacadeTest`, `ModelDocumentTest`, `AllVersionsGateTest`), with zero unmodeled tags (`CoverageGateTest`). Do not "restore" a whole-file byte-identity claim here — it was checked against the corpus and is false. Neither writer is byte-reproducible, ours included, and that is on purpose: the editor stamps a local wall clock into each compressed blob's zip timestamp (the corpus sample reads 2022-06-06 17:03:30) and **we stamp one too**. Pinning that field to a constant would buy us determinism, but the official editor's reader is fragile and does a lot for cross-version compatibility — **when in doubt, write what the editor writes**; a convenience of ours never outranks matching its bytes. See `docs/format/CMO3.md` §1. **Round-trip is the bar:** open a corpus model, re-save, reopen in the official Cubism Editor, assert no semantic loss (mangled physics or a dropped deformer subtree kills the migration promise).
- **Preview parity — geometry (v1 primary).** The viewport deformation must visually match the Cubism Editor's own preview within tolerance. Computed geometry is **bounded ULP / visually identical**, never bit-identical (scalar vs SIMD vs GPU diverge by construction).
Maintain a **golden corpus** of real `.cmo3` (and later `.moc3`) models. Never add a format version to the supported set without a corpus sample exercising it.
## Tech stack (and why)
- **Kotlin + Kotlin Multiplatform + Gradle (Kotlin DSL).** Android reuse; large accessible contributor pool; JVM reflection + JDOM make the CMO3 XML serializer (read *and* write) tractable on both desktop and Android.
- **Compose Multiplatform** for UI (Android + Desktop, pen/touch native). See Architecture.
- **FileKit** for native open/save dialogs — one Kotlin Multiplatform API over each OS's native picker (Win32 `IFileDialog`, Cocoa, GTK/portal) plus Android SAF, behind `:storage`'s `FilePicker` contract.
- **GPU:** LWJGL on desktop (GL/Vulkan + GLFW, behind interop); GLES/Vulkan on Android. **Baseline:** GL 3.3 core (desktop, `#version 330 core` shaders, GLFW core-profile context) / GLES 3.0 (Android, needed for VAOs).
- **CMO3:** CAFF container codec + reflection-driven XML serializer (JDOM 1.x, Kotlin reflection); JVM-and-Android (`jvmAndroidMain`)
- **C++ Core FFI (stretch):** `:core-bridge` behind one interface — Panama (`java.lang.foreign`) on desktop, **JNI/NDK on Android** (Android does NOT ship the FFM API). Never put `java.lang.foreign` in shared/Android code paths.
## Build & run
See README.md for build instructions.
The official Cubism Core/SDK/Editor are **external dependencies of the harness only** — never committed, vendored, or linked into shipping artifacts. Never attempt to reverse engineer the official Cubism Core, SDK, or Editor.
## Code style
- **Indentation: tabs.** Set `.editorconfig` `indent_style = tab` and configure ktlint to match (overrides Kotlin's space default).
- **Naming:** `lowerCamelCase` functions/values, `PascalCase` types (matches Kotlin convention). Naming for functions and variables (including local variables, function parameters, and loop counters) is verbose and descriptive: `bitFlip`, never `bf` or `bFlip`. Single-letter names are NOT acceptable for loop counters (`i`/`j`/`k`) — use a name that reflects what's being iterated (`pageIndex`, `slotIndex`, `wordIndex`, `lineIndex`). Single-letter dimensions are NOT acceptable: `h` could be `height` or `hue`, so write `width`, `height`. Single-letter aliases for locals inside function bodies are NOT acceptable either (e.g. `b` for `backend`, `s` for `status`, `v` for a register value, `p` for a pointer) — give the local a descriptive name. Some abbreviation is okay as long as it is not ambiguous, such as `rect` for `rectangle`. Permitted short names: `x`, `y`, `z` for coordinates (universal graphics idiom); `r`, `g`, `b` for color channels ONLY when the enclosing function/struct name disambiguates (e.g. `paletteRgbToGrbi(uint8_t r, uint8_t g, uint8_t b, ...)` — the `Rgb` in the name makes the parameters self-documenting). Use US English for spelling, example: "Color", not "Colour".
- **World axis names:** the viewport convention is X right, Y forward, Z up, so a name that says it is world space calls its vertical axis Z (`worldOriginZ`, `Cursor2d.worldZ`, `screenToWorldZ`), never `worldY`. Space-agnostic math (`[x, y]` arrays, `MeshBounds`, GLSL `vec2`), canvas / screen / UV / NDC names, and the deform eval's pre-negation space keep y. See `PuppetModel.worldOriginX`.
- **Comments:** English; about *why*, not *what*.
- **Format-citation discipline:** any code reading/writing a format field MUST cite the spec location, e.g. `// CMO3: <className> field <name>` or `// MOC3 v4 §3.2 @ +0x18`. This is the format analogue of register-citation discipline — every byte traceable to docs, and it protects the clean-room story.
- Model format versions and deformer kinds as **sealed classes/enums**; match exhaustively so the compiler enforces coverage. No accidental nullability.
- Prefer `expect`/`actual` over `if (platform)` for desktop/Android splits.
- Braces are MANDATORY on EVERY `if`, `else if`, and `else` — including single-statement bodies. The body always goes on its own line inside `{ }`. The brace-less one-liner form is NOT allowed under any circumstances.
### Comments & documentation
- Public API doc comments and any non-obvious logic.
- Don't use Markdown bold and italic formating in comments and Docblocks. Purely visual formatting is fine such as spaces, line breaks, indentation, and lists.
- Oxford(Serial) comma, two spaces after a period at the end of a sentence.
- **Every function gets exactly one docblock**, PHP/PHPDoc-style.
- Open with `/**` (two stars) and close with ` */`; every interior line starts with ` * ` (leading space, star, space). This is what distinguishes a docblock from an ordinary `/* ... */` comment — reserve `/**` for documentation, use `/* */` for inline notes.
- Structure: a one-line summary sentence, then (optionally) a blank ` *` line and a longer prose description, then the tag block. Order of tags: `@param` (one per parameter, in signature order), `@return`, then any of `@note` / `@warning` / `@see` / `@pre` / `@post` as needed. Omit `@return` for `void` functions. Omit `@param` when there are no parameters (`void`).
- `@param type variable description`
- Indent with tabs, consistent with the rest of the file.
- Example 1:
```kotlin
/**
* Clears the current GL framebuffer to the given color. Assumes a context is current.
*
* @param Float red Red Color
* @param Float green Green Color
* @param Float blue Blue Color
* @param ByteArray bytes Raw bytes from the file
* @return ReturnedVariable
*/
actual fun clear(red: Float, green: Float, blue: Float, alpha: Float) { }
```
## Guardrails (hard rules — contributors and AI assistants)
- **Re-import never destroys rig work.** Removals/renames are flagged and reviewable, never silently applied.
- **Docking is a Blender-style area tree:** the window is a recursive split tree of areas; each area hosts one editor space and is switchable to any space via its header dropdown; splitters are draggable. No free-floating windows. One shared desktop/tablet interface with a touch-tuned skin — never a second front-end.
- **All input dispatches through the action registry** — menus, toolbar, radial menu, and shortcuts never hardcode handlers, so a rebind takes effect everywhere.
- **All UI strings externalized; localize chrome/display, never format-level IDs** — `ParamAngleX` and the rest of the CMO3 identifiers stay verbatim for interop.
- **CMO3 round-trip must pass before any format-write change merges.** (Open → re-save → reopen in official editor → no semantic loss.)
- **Binary formats implement the shared `FormatCodec` contract** (`kind`/`matches`/`read`/`write`, dispatched via `FormatRegistry`); JSON sidecars stay text helpers. No bespoke per-format read/write facade.
- **Two fidelity tiers respected:** semantic-validity for CMO3, bounded-ULP for geometry, byte-exact only for MOC3 binary. Never relax format correctness; never chase bit-identical geometry.
- **No `java.lang.foreign` in shared/Android paths** (absent on Android). FFI only behind `:core-bridge`.
- **No Swing/JavaFX as UI** (Compose only). The desktop GL viewport is not Swing interop either — it renders offscreen via a hidden GLFW context into a Compose `Image`.
- **MOC3 version policy:** read v1–v6.
## Glossary
- **Drawable / art mesh** — textured triangle mesh with draw/render order, masks, blend mode, opacity, multiply/screen color.
- **Warp deformer** — FFD lattice; **Rotation deformer** — nesting pivot transform.
- **Parameter** — animation axis (e.g. `ParamAngleX`); **Keyform** — captured state at specific parameter values; runtime blends across the N-D keyform grid.
- **Source-art binding** — the stable-identity link from a rig drawable to a source layer; basis of non-destructive re-import.
- **File family** — `.cmo3` (editor source: CAFF container + XML-serialized object graph + embedded PNGs) · `.moc3` (runtime, C structs) · `model3/physics3/cdi3/pose3/exp3/motion3/userdata3.json` · texture atlas.
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# Blocks any Claude Code tool call that touches /mnt
input=$(cat)
# Pull out the fields that might contain a path
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
command=$(echo "$input" | jq -r '.tool_input.command // empty')
notebook_path=$(echo "$input" | jq -r '.tool_input.notebook_path // empty')
# Check each for /mnt (with or without leading slash variants, and case just in case)
for candidate in "$file_path" "$command" "$notebook_path"; do
if echo "$candidate" | grep -qE '(^|[[:space:]/])/mnt(/|$| )'; then
echo "Blocked: this tool call references /mnt, which is off-limits in this project." >&2
exit 2
fi
done
exit 0
+15
View File
@@ -0,0 +1,15 @@
{
"hooks": {
"PreToolUse": [
{
"matcher": "Read|Write|Edit|Bash|NotebookEdit",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/block-mnt.sh"
}
]
}
]
}
}
+185
View File
@@ -0,0 +1,185 @@
---
description: Sweep a branch's changed files against a base ref and fix comments/docblocks that no longer describe current code — stale claims, leftover planning/phase language, bug-narrative diary comments, irrelevant comparisons to unrelated tools/projects, wrong CMO3/MOC3 field citations, and incomplete docblocks. Batches large branches across parallel background agents. Use when asked to "clean up comments," "fix comments on this branch," or before merging a branch that accumulated debugging-session comment cruft.
argument-hint: [base-ref]
---
# Comment cleanup
Reviews every comment and docblock touched by a branch (compared against `$1`, default `master`)
and fixes the ones that no longer tell the truth about the code below them. This is a text-only
pass: never change code logic. Suspected actual code bugs get flagged for the user, not silently
fixed — this skill's job is the comments, not the implementation, except where explicitly asked
to also apply a flagged fix.
## 1. Scope the diff
```
git merge-base <base-ref> HEAD
git diff --name-status -M <base-ref>...HEAD
```
Always pass `-M` (rename detection) — without it, a renamed-with-edits file shows as a spurious
delete+add pair, and pathspec-glob queries on the raw file list can double-count or miss renamed
paths. Cross-check any manually-assembled file list against `git diff --name-only` with a
set-difference (`comm -13`/`comm -23`) before trusting it's complete and non-overlapping.
If the user says "second round" or references prior cleanup work on the same branch, scope to
`<last-cleanup-commit>..HEAD` instead of the whole branch — that's usually a much smaller, more
targeted diff, and re-reviewing already-clean content wastes the pass.
## 2. Decide solo vs. delegated
- **Under ~30 changed files**: review directly, file by file, using `Read` and `git diff <base>...HEAD -- <path>`
per file. Keep a `TodoWrite` list per file cluster so progress survives context compaction.
- **Larger** (a big feature branch, a multi-week history sweep): batch by **module/directory
boundary**, not by commit range — a file's *final* state is what matters, not which commit last
touched it. Dispatch each batch as a background `Agent` (`subagent_type: general-purpose`,
`run_in_background: true`) so batches run in parallel. Aim for batches of roughly 5–20 files or
~1000–2000 diff lines; split a single very large file (500+ lines) into its own batch if it's
dense.
- Before delegating, personally read and fix ONE representative example yourself first (see §5) —
it gives you a concrete before/after to paste into every agent prompt, which is what keeps
agent output consistent instead of six different interpretations of "stale."
Every delegated agent prompt must include, verbatim or adapted:
- The exact file list for its batch (absolute repo-relative paths).
- The seven categories from §3, each with the concrete calibration example from §5.
- The explicit "what not to do" list from §4.
- An instruction to flag suspected real code bugs as `POSSIBLE CODE BUG: file:line — reason`
instead of fixing them.
- A word budget on the final report (400–700 words depending on batch size) so N parallel reports
don't blow the orchestrating session's context on consolidation.
## 3. What counts as a fix (seven categories)
**(A) Staleness.** A comment/docblock describes behavior, a signature, a nullability, a module
location, or a control-flow path that no longer matches the code beneath it. Includes dangling
cross-references (`[FormerName]`, a package that moved to another module, a docblock enumerating
fields that no longer match a `when` below it). Fix to describe the code as it stands now.
**(B) Planning/phase language.** Leftover roadmap-numbering that reads like a project-plan label
rather than a description of what a step *does* — `Phase 1` / `Phase 2` inside a function that
runs both steps unconditionally every time, `(M2)`/`(M4)` milestone tags, `Slice A`, `Part 2 of`,
"placeholder pending a future step" for something that's actually wired, "dedicated follow-up" for
work already done in the same branch. Fix by renaming to what the step IS, not by deleting the
structure. Example fix applied in this project:
```
- // Phase 1 - set membership: identity shells for creations, source removal for deletions.
+ // Structural pass - set membership: identity shells for creations, source removal for deletions.
```
**Do not touch legitimate roadmap citations** — `docs/plan/art-sourcing-pipeline.md § Phase G` is a
real, still-open phase in a real design doc; a comment citing it accurately is not planning-language
cruft. The test is whether the *cited plan* still exists and is still pending, not whether the word
"Phase" appears.
**(C) Bug-narrative / debugging-diary comments.** Rewrite comments that narrate a bug's discovery
story in a way that needs hidden context — "used to X, which caused Y, so now Z," "never showed the
bug," "one desync was observed (date) where..." — into either a direct atemporal statement of the
current invariant, or counterfactual "would" framing explaining what the guard prevents. Example:
```
- // one desync was observed (2026-08-03) where a second MOC3 exported the first model's rig
- // onto the second's atlas pages, which reads as a wall of drawable notices...
+ // a session from a stale composition pass would export the PREVIOUS document's rig onto this
+ // document's atlas pages, surfacing as a wall of drawable notices...
```
**Exception — test docblocks only:** a regression test MAY reference a historical bug if the
mechanism is fully and concretely spelled out in the comment itself (not left as an opaque "the
bug"). That's normal regression-test practice, not narrative cruft — don't over-correct it.
**Exception — dated "KNOWN GAP" / investigative documentation:** a long, precise, dated note that
documents a real, currently-open limitation (what's broken, why, what's been ruled out, where the
real fix lives) is valuable "why" documentation, not diary cruft — even when it's long and reads
like it came out of a debugging session. Only fix it if a claim in it is factually wrong or has
been superseded by a later change; never trim it just for length.
**(D) Format-citation discipline.** Any comment touching a binary/serialized format field must cite
it per the project convention (`// CMO3: <ClassName> field <name>`, `// MOC3 §N ...`). Fix a
missing/wrong citation only if you can verify the correct one by reading the actual field/class
definition — never guess a citation.
**(E) Docblock completeness.** Per the project's docblock style, an *existing* docblock needs one
`@param` per parameter (signature order) and `@return` for non-void functions. If a parameter was
added later without updating the docblock, add the tag. **Never add a docblock to a function that
never had one** — that's a different task, not this one.
**(F) Formatting/whitespace artifacts.** Heavy debugging-session editing sometimes leaves stray
indentation (a nested function at 4 tabs instead of 1, relative to its scope) or a duplicate
comment block sitting next to the new one that replaced it. Cheap to spot with `cat -A` on the
touched region; fix as pure whitespace, zero semantic risk.
**(G) Irrelevant tool/project comparisons.** A comment justifies a file's or function's existence
or design by contrasting it with what some unrelated tool or project does or doesn't do — "this is
the pipeline node Umamo owns and Blender does not," "unlike Photoshop," "which no other rigging
tool does" — where the comparison itself carries no technical information about this code's actual
behavior. A comment describes the purpose of the code in front of the reader, not a scorecard
against unrelated software. Fix by deleting the comparison and keeping only the real technical
rationale; if the comparison was the entire reason given, replace it with the actual reason (read
the surrounding code or the relevant `docs/plan/`/`docs/format/` doc to find it) rather than
leaving a bare, now-shorter claim. Example fix applied in this project:
```
- * This is the pipeline node Umamo owns and Blender does not - because the 2D source art hands us
- * each piece's opaque silhouette before packing, the atlas can be generated rather than authored
- * by hand and reconciled.
+ * Because the 2D source art hands us each piece's opaque silhouette before packing, the atlas can
+ * be generated rather than authored by hand and reconciled.
```
**Do not touch a comparison that names an actual compatibility or fidelity target** — "matches the
official Cubism Editor's export ordering," "unlike the CMO3 v3 schema, v4 adds a blend-shape
table" — those name a concrete constraint the code is built to satisfy (per the Fidelity contract
in CLAUDE.md), not a rhetorical aside about an unrelated project. The test is whether the named
project is the thing this code interoperates with or is bounded by (Cubism/CMO3/MOC3 for this
codebase), not whether a proper noun appears in the sentence.
## 4. What not to do
- No code-logic changes. Comment, docblock, and pure-whitespace text only.
- Don't add new comments/docblocks to undocumented functions.
- Don't "improve" already-accurate comments for style alone.
- Don't shorten legitimate dated investigative documentation just because it's long (see the (C)
exception above).
- Don't touch files outside the assigned scope/batch.
- Don't touch a project's own scratch/notes file above whatever heading marks it off-limits, if the
project's memory or CLAUDE.md says so (this repo: `TODO.md` above `# Claude Notes` is Alexia's
personal pad).
## 5. Calibrate before delegating
Read one file yourself, find one real instance of category (A) or (B), fix it, and keep the exact
before/after diff. Paste that verbatim into every batch's agent prompt as "here's a fix I already
made for calibration — read the file yourself since it won't show in `git diff` yet." This is what
keeps parallel agents from either being too aggressive (rewriting fine comments for style) or too
timid (leaving real staleness because it wasn't a 100% textual match to the example).
## 6. Consolidate and verify
- Every `POSSIBLE CODE BUG` an agent reports gets personally verified before it goes in the final
report — read the actual code, trace the call graph, confirm the claim with `grep`/`git log -L`
as needed. Never forward an unverified agent claim as a finding.
- Run a final repo-wide sweep for residual patterns the agents might have missed individually:
```
git diff --name-only <base-ref>...HEAD -- '*.kt' | while read -r f; do
grep -noE 'Phase [A-Za-z0-9]+|\(M[0-9]+\)|Step [0-9]+|Slice [A-Z]|for now\b' "$f"
done
```
- Sanity-check the aggregate diff: `git diff --stat` should show a comment-sized insert/delete
ratio (roughly 1:1, small numbers) — a large net line-count change means something drifted into
code edits.
- If a fix touches control flow that a report only weakly implied should change (e.g. a stale
comment that was ALSO a real duplicate-notice bug), don't fix the logic unasked — report it, and
wait for explicit approval before removing/changing behavior (see the `Cmo3PropertyLowering`
redundant-notice example from this project's history: flagged first, fixed only after the user
said "go ahead").
## 7. Report format
Group findings by theme, not by batch — the user doesn't care which agent found what. Lead with
the most consequential fixes (wrong logic implied by a comment, swapped comment blocks, a
misleading user-facing string), then the routine staleness/phase-language sweep, then any verified
`POSSIBLE CODE BUG` flags left for the user's own triage. Keep it scannable: file references, one
line of before → after gist each, no prose padding.
+44
View File
@@ -0,0 +1,44 @@
# EditorConfig — shared formatting rules across editors AND ktlint (which reads this file).
# CLAUDE.md mandates TAB indentation, overriding Kotlin's space default.
root = true
[*]
charset = utf-8
end_of_line = lf
# HOLY FUCKING SHIT THIS TOOK SO FUCKING LONG TO FIND. FUCK THIS NEWLINE AT THE END OF FILES SHIT. IT'S 2026! Stop doing lazy as fuck programming.
insert_final_newline = false
trim_trailing_whitespace = true
indent_style = tab
[*.{kt,kts}]
indent_style = tab
# Tell ktlint to use the official ruleset but honour tab indentation above.
ktlint_code_style = ktlint_official
# Bilingual EN/JA comments push some lines long; relax the line-length rule rather than
# fight it (CLAUDE.md cares about *why*-comments, not column counts).
ktlint_standard_max-line-length = disabled
# Allow single-line call chains like `libs.versions.x.get().toInt()` (ubiquitous in Gradle
# Kotlin DSL + version-catalog access); the forced-newline form hurts more than it helps.
ktlint_standard_chain-method-continuation = disabled
# Same reasoning for constructor and function signatures: these wrapping rules key off
# max-line-length (disabled above), so with it off they over-wrap. Authors choose single- vs
# multi-line by readability. The valuable structural rules (imports, spacing, trailing commas,
# naming, no-wildcard-imports) remain enforced.
ktlint_standard_class-signature = disabled
ktlint_standard_function-signature = disabled
# @Composable functions are PascalCase by Compose convention; exempt them from the
# lowerCamelCase function-naming rule (the rule still applies to ordinary functions).
ktlint_function_naming_ignore_when_annotated_with = Composable
# Compose Resources generates ONE top-level extension property per UI string (Res.string.menu_file,
# …) in org.umamo.ui.resources, a set that grows unbounded with the catalog. Allow an on-demand
# (wildcard) import for that single generated package so consumers write `import …resources.*`
# instead of one line per string; no-wildcard-imports stays strict for every other package. This is
# the precise form of the gen/ subtree's blanket disable — exempt the generated package, not the file.
ij_kotlin_packages_to_use_import_on_demand = org.umamo.ui.resources.**
[*.{yml,yaml,json,toml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
+15
View File
@@ -0,0 +1,15 @@
# These are supported funding model platforms
github: Alexia
patreon: c/Azxiana
open_collective: # Replace with a single Open Collective username
ko_fi: azxiana
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+38
View File
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+30
View File
@@ -0,0 +1,30 @@
# Continuous integration: runs the shared verification suite on every push/PR.
# The suite itself lives in verification.yml so release.yml can run the identical thing — see the
# comment at the top of that file for why it is factored out rather than inlined here.
name: CI
on:
push:
branches: [master, develop]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# Least-privilege default: checkout is all this workflow needs. GitHub reports each
# job's pass/fail as a PR status check natively, no extra `checks`/`statuses` scope required.
permissions:
contents: read
# Cancel superseded runs on the same ref to save runner minutes.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
# Skip draft PRs to avoid burning runner minutes on WIP; ready_for_review re-triggers it.
# This guard lives here rather than in verification.yml because the release workflow calls the
# same suite with no pull-request context at all.
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
uses: ./.github/workflows/verification.yml
permissions:
contents: read
+433
View File
@@ -0,0 +1,433 @@
# Release: pushing a semver tag verifies the version, runs the full test suite, and publishes
# self-contained app images plus runnable uber jars for all five supported desktop targets.
#
# Deliberately out of scope until alpha: code signing, notarization, native installers
# (.msi/.dmg/.deb/.rpm) and auto-update. What ships here is an unzip-and-run app image with a
# bundled JRE, plus a jar for people who already have a JVM. See RELEASING.md.
name: Release
on:
push:
# These are GitHub filter patterns, not regex: `+` means "one or more of the preceding
# character", so `[0-9]+` is one-or-more digits and `.` is a literal dot. Two patterns rather
# than one trailing `*` so it is obvious that prerelease tags are supported ON PURPOSE —
# ProjectInfo.kt declares 0.1.0-dev today, so `v0.1.0-dev` has to be a legal release tag, and
# gradle/project-version.gradle.kts already strips the suffix for jpackage. The verify job
# re-checks the tag against a strict semver regex, so these globs are only a coarse filter.
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
# Dry run. Builds and tests everything and uploads all five targets as workflow artifacts, but
# publishes nothing — so the whole pipeline can be exercised from a branch before any tag exists.
workflow_dispatch:
# Least privilege at the workflow level; only the `release` job widens it, and only to contents:write.
permissions:
contents: read
# Serialise per ref, but NEVER cancel in progress: unlike CI, a cancelled run here can leave a
# half-uploaded release behind. A superseded release run is cheap; a torn one is not.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
# -----------------------------------------------------------------------------------------------
# 1. The version gate. ProjectInfo.kt IS the version (its docblock forbids a second definition),
# so this workflow VERIFIES the tag against it and never injects a version. Runs first and
# alone: a mismatch should cost ~30 seconds, not a five-way packaging matrix.
# -----------------------------------------------------------------------------------------------
verify:
name: Verify version
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.resolve.outputs.version }}
tag: ${{ steps.resolve.outputs.tag }}
prerelease: ${{ steps.resolve.outputs.prerelease }}
publish: ${{ steps.resolve.outputs.publish }}
steps:
- uses: actions/checkout@v7
- name: Resolve and cross-check the version
id: resolve
shell: bash
run: |
set -euo pipefail
project_info="module/ui/src/commonMain/kotlin/org/umamo/ui/help/ProjectInfo.kt"
# The same constant gradle/project-version.gradle.kts parses. POSIX sed with a
# bracket-expression for whitespace, so this needs nothing installed and behaves the same
# on every runner image.
declared="$(sed -n 's/.*VERSION[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' "${project_info}" | head -n1)"
if [ -z "${declared}" ]; then
echo "::error file=${project_info}::VERSION constant not found — the build derives its version from it"
exit 1
fi
echo "ProjectInfo.VERSION = ${declared}"
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
tag="${GITHUB_REF_NAME}"
publish=true
else
# workflow_dispatch: no tag exists. Synthesise the one this commit WOULD ship under, so a
# dry run produces identically-named artifacts, and publish nothing.
tag="v${declared}"
publish=false
fi
echo "tag = ${tag} (publish=${publish})"
case "${tag}" in
v*) version="${tag#v}" ;;
*) echo "::error::tag '${tag}' must start with 'v'"; exit 1 ;;
esac
# Strict semver. The push filter above is a glob and would happily accept 'v1.2.3nonsense'.
if ! printf '%s' "${version}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
echo "::error::tag '${tag}' is not a semantic version"
exit 1
fi
# THE gate. Fail loudly and say exactly what to do, because the fix is never "re-run".
if [ "${version}" != "${declared}" ]; then
echo "::error file=${project_info}::tag '${tag}' does not match ProjectInfo.VERSION '${declared}'. Bump the constant (and CHANGELOG.md), commit, delete the tag, and re-tag. This workflow never injects a version."
exit 1
fi
# A semver prerelease is anything with a '-' after MAJOR.MINOR.PATCH. 0.1.0-dev qualifies,
# which is correct: everything before alpha should be marked as such on the release page.
case "${version}" in
*-*) prerelease=true ;;
*) prerelease=false ;;
esac
{
echo "version=${version}"
echo "tag=${tag}"
echo "prerelease=${prerelease}"
echo "publish=${publish}"
} >> "${GITHUB_OUTPUT}"
# -----------------------------------------------------------------------------------------------
# 2. The quality gate — literally the same suite every push and PR runs, called as a reusable
# workflow so the two cannot drift. Nothing is packaged until this is green.
# -----------------------------------------------------------------------------------------------
test:
name: Verification suite
needs: verify
uses: ./.github/workflows/verification.yml
permissions:
contents: read
# -----------------------------------------------------------------------------------------------
# 3. Packaging, one leg per shipped target. Each leg produces exactly two files:
# umamo-<target>-<version>.{tar.gz|zip} — self-contained app image (bundled JRE)
# umamo-<target>-<version>.jar — uber jar, needs a JDK/JRE 21 on the machine
# Every leg builds ON its own OS/arch: an app image jlinks the HOST JDK into itself, so unlike
# the uber jar it genuinely cannot be cross-produced.
# -----------------------------------------------------------------------------------------------
package:
name: Package ${{ matrix.target }}
needs: [verify, test]
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
# One platform failing should not hide whether the other four work — on a release run that is
# the difference between one fix-and-retag and four.
fail-fast: false
# appImage gates createDistributable and the archive/assert steps that depend on it. It is
# false on macOS ONLY because of a jpackage bug, not anything about the app:
# jdk.jpackage.internal.CFBundleVersion rejects a CFBundleVersion whose first component is
# zero, so any 0.x version fails createDistributable on macOS alone. JDK-8380634 deleted that
# check on 2026-03-30, but it landed after JDK 26 forked — 21, 25 (LTS) and 26 (latest GA) all
# still carry it, so there is no released JDK to move to. Rather than mangle the version or
# ship an early-access runtime, the macOS legs publish the uber jar only until JDK 27 is GA
# (~September 2026). TO RESTORE: set these two back to true. Nothing else needs to change.
matrix:
include:
- { target: linux-x64, runner: ubuntu-latest, appImage: true }
- { target: linux-arm64, runner: ubuntu-24.04-arm, appImage: true }
- { target: windows-x64, runner: windows-latest, appImage: true }
- { target: macos-arm64, runner: macos-latest, appImage: false }
# macos-15-intel is the last x86-64 macOS image GitHub will offer; it retires in August
# 2027, after which this leg has to go and Intel Mac users fall back to the uber jar under
# an x64 JDK. (The older macos-13 label was retired in December 2025 — do not resurrect it.)
- { target: macos-x64, runner: macos-15-intel, appImage: false }
env:
UMAMO_VERSION: ${{ needs.verify.outputs.version }}
UMAMO_TARGET: ${{ matrix.target }}
UMAMO_APP_IMAGE: ${{ matrix.appImage }}
steps:
- uses: actions/checkout@v7
# jlink and jpackage come from the JVM the Gradle DAEMON runs on, not from jvmToolchain(21) —
# the Compose plugin defaults its javaHome to the `java.home` system property, and
# gradle/gradle-daemon-jvm.properties pins the daemon to 21. Temurin specifically: the plugin's
# checkRuntime task hard-errors on a Homebrew JDK, which is what a bare `brew install` leaves
# on PATH.
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
# No Android SDK step here, unlike the verification suite. Every KMP library module applies
# AGP's com.android.kotlin.multiplatform.library and Gradle configures all projects even for a
# :desktop-only task graph, so this looked like it would be required — but it measurably is
# not: `env -u ANDROID_HOME -u ANDROID_SDK_ROOT ./gradlew :desktop:createDistributable
# --dry-run --no-configuration-cache` configures all seven android targets and resolves the
# task graph cleanly. Skipping it saves ~40 s per leg and avoids the arm64-Linux problem that
# Google ships only x86-64 build-tools binaries.
- name: Set up Gradle (with caching)
uses: gradle/actions/setup-gradle@v6
with:
# A tag build is read-only by default (it is not the default branch), but say so
# explicitly: five legs racing to write one cache is pure waste, and a release must never
# be the run that poisons the cache every PR then reads.
cache-read-only: true
# -Pumamo.target is passed EXPLICITLY rather than left to host detection, for two reasons:
# * the uber jar's name embeds it (see :desktop's archiveFileName override), so artifact
# names become a function of the matrix instead of a function of what the runner reported;
# * paired with -Pumamo.requireTargetIsHost it turns a runner-image surprise — an unexpected
# os.arch — into a build failure rather than a jar full of the wrong natives.
#
# Do NOT add `check` or `build` to this job. `check` pulls compileKotlinIosArm64 in :format,
# :runtime, and :render, and ubuntu-24.04-arm is not a supported Kotlin/Native host. The
# verification suite above is where testing happens.
#
# The heap overrides are not cosmetic: gradle.properties asks for a 4 GB Gradle daemon and the
# Kotlin daemon mirrors it, which is ~8 GB against the arm64 macOS runner's ~7 GB. 2 GB each
# fits every runner in the matrix and is ample for a :desktop-only task graph.
- name: Build the app image and the uber jar
shell: bash
run: |
set -euo pipefail
tasks=":desktop:packageUberJarForCurrentOS"
if [ "${UMAMO_APP_IMAGE}" = "true" ]; then
tasks=":desktop:createDistributable ${tasks}"
else
echo "::notice::${UMAMO_TARGET}: app image skipped, publishing the uber jar only (see the matrix comment in this workflow)"
fi
# shellcheck disable=SC2086 # tasks is a deliberate word-split list of Gradle task paths.
./gradlew --stacktrace \
-Dorg.gradle.jvmargs="-Xmx2g -Dfile.encoding=UTF-8" \
-Pkotlin.daemon.jvmargs=-Xmx2g \
-Pumamo.target="${UMAMO_TARGET}" \
-Pumamo.requireTargetIsHost=true \
${tasks}
# jlink writes a `release` descriptor listing MODULES into every runtime image and jpackage
# copies it into the app image verbatim, so this is a launch-free check that :desktop's
# modules(...) list still covers what the app actually uses. Without it a missing module is
# invisible until a user hits NoClassDefFoundError, because nothing in CI ever starts the
# packaged binary. The descriptor's depth differs per OS (macOS nests the runtime inside the
# .app bundle), so find it rather than hard-coding a path.
- name: Assert the bundled runtime carries the modules the app needs
if: matrix.appImage
shell: bash
run: |
set -euo pipefail
root="app/desktop/build/compose/binaries/main/app"
release_file="$(find "${root}" -maxdepth 8 -type f -name release | head -n1)"
if [ -z "${release_file}" ]; then
echo "::error::no jlink release descriptor under ${root} — did createDistributable actually run?"
exit 1
fi
echo "runtime descriptor: ${release_file}"
modules_line="$(grep '^MODULES=' "${release_file}")"
echo "${modules_line}"
for module in java.base java.desktop java.instrument java.logging java.sql java.xml jdk.security.auth jdk.unsupported; do
case "${modules_line}" in
*"${module}"*) ;;
*)
echo "::error::bundled runtime is missing ${module} — add it to nativeDistributions.modules in app/desktop/build.gradle.kts"
exit 1
;;
esac
done
# tar, not zip, on Linux: it is the only one of the three archivers here that preserves the
# execute bit on bin/umamo and the runtime's helper binaries. -C so the archive root is
# `umamo/` rather than the whole build path.
- name: Archive the app image (Linux)
if: matrix.appImage && runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
mkdir -p dist
tar -C "app/desktop/build/compose/binaries/main/app" \
-czf "dist/umamo-${UMAMO_TARGET}-${UMAMO_VERSION}.tar.gz" umamo
# Currently inert — matrix.appImage is false on both macOS legs (see the matrix comment). Kept
# rather than deleted so restoring macOS app images at JDK 27 GA is only a matrix flip.
#
# ditto, not zip: a .app is a bundle of symlinks, execute bits and extended attributes, and
# /usr/bin/zip flattens enough of that to produce something Finder refuses to open.
# `-c -k --keepParent` is Apple's own recipe and keeps `umamo.app` as the archive root.
- name: Archive the app image (macOS)
if: matrix.appImage && runner.os == 'macOS'
shell: bash
run: |
set -euo pipefail
mkdir -p dist
ditto -c -k --keepParent \
"app/desktop/build/compose/binaries/main/app/umamo.app" \
"dist/umamo-${UMAMO_TARGET}-${UMAMO_VERSION}.zip"
# 7z, not Compress-Archive: the app image is ~230 MB spread over several thousand files, a
# shape Compress-Archive takes minutes on. 7z ships on the windows runner image.
#
# Push-Location into the app-image directory first and archive the bare "umamo" name — 7z's
# default is to preserve whatever relative path you hand it inside the archive, so pointing it
# at the full build path bakes app\desktop\build\compose\binaries\main\app\umamo\ into every
# entry, which is what a user then has to click through after unzipping. cd'ing there first
# keeps the archive root flat, matching the Linux (`tar -C`) and macOS (`ditto --keepParent`)
# legs, which already avoid this.
- name: Archive the app image (Windows)
if: matrix.appImage && runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
New-Item -ItemType Directory -Force -Path dist | Out-Null
$distPath = (Resolve-Path dist).Path
Push-Location "app\desktop\build\compose\binaries\main\app"
try {
7z a -tzip -mx=5 "$distPath\umamo-$env:UMAMO_TARGET-$env:UMAMO_VERSION.zip" umamo | Out-Null
} finally {
Pop-Location
}
# An exact path, not a glob: the name is pinned by :desktop's archiveFileName override, so if
# that convention ever changes this fails here instead of shipping a release with a hole in it.
- name: Collect the uber jar
shell: bash
run: |
set -euo pipefail
mkdir -p dist
cp "app/desktop/build/compose/jars/umamo-${UMAMO_TARGET}-${UMAMO_VERSION}.jar" dist/
ls -lh dist/
- name: Upload this target's artifacts
uses: actions/upload-artifact@v7
with:
# Must be unique per matrix leg — the action errors rather than merging same-named uploads.
# The release job re-merges them with `pattern` + `merge-multiple`.
name: umamo-${{ matrix.target }}
path: dist/*
# A leg that produced nothing must fail here, not quietly ship a four-asset release.
if-no-files-found: error
# Everything in dist/ is already a compressed archive or a jar (itself a zip); re-deflating
# incompressible bytes would cost minutes per leg and save nothing.
compression-level: 0
# These are intermediates — the release page is the durable copy. Long enough to debug a
# failed publish, short enough not to hoard ~1.4 GB per run.
retention-days: 7
# -----------------------------------------------------------------------------------------------
# 4. Publish. Uses the gh CLI rather than a marketplace action on purpose: gh is preinstalled on
# every GitHub-hosted runner, so this — the only job holding contents:write — hands that token
# to no third-party code. It is also one less action version to pin and audit, and the
# behaviour on a re-run is ours to define rather than something to discover.
# -----------------------------------------------------------------------------------------------
release:
name: Publish GitHub release
needs: [verify, package]
# Dry runs stop after `package`: the artifacts are on the run page, nothing is published, and
# there is nothing to clean up afterwards.
if: needs.verify.outputs.publish == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
# The only elevated permission anywhere in this workflow, scoped to the one job that needs it.
# Creating a release and uploading its assets is all contents:write buys; nothing here wants
# packages:, id-token: or actions:.
contents: write
steps:
- uses: actions/checkout@v7
- name: Download every target's artifacts
uses: actions/download-artifact@v8
with:
pattern: umamo-*
merge-multiple: true
path: dist
# Computed here, once, on one machine, in one format — rather than five per-OS variants of
# sha256sum/shasum/Get-FileHash that would then have to agree on output shape. The explicit
# `umamo-*` prefix keeps the checksum file from ever hashing itself.
- name: Generate SHA-256 checksums
working-directory: dist
run: |
set -euo pipefail
sha256sum umamo-* | tee SHA256SUMS.txt
ls -lh
- name: Create the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.verify.outputs.tag }}
VERSION: ${{ needs.verify.outputs.version }}
PRERELEASE: ${{ needs.verify.outputs.prerelease }}
run: |
set -euo pipefail
# The unsigned-build warnings are not boilerplate: without them the first thing most users
# meet is an OS refusing to run the download. Unsigned is a deliberate pre-alpha choice, so
# the consequence belongs at the point of download.
notes="$(mktemp)"
cat > "${notes}" <<'NOTES'
## Downloads
| File | Note |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `umamo-<target>-<version>.zip` / `.tar.gz` | Java SDK not required, just run it directly. |
| `umamo-<target>-<version>.jar` | You will need Java SDK 21 or higher to run. Either open through the file browser or through the command line. `java -jar umamo-...jar` |
Targets: `linux-x64`, `linux-arm64`, `windows-x64`, `macos-arm64`, `macos-x64`.
Verify your download against `SHA256SUMS.txt`.
**MacOS ships as the jar only for now.** A jpackage bug rejects any app version starting with `0`, and the fix is not in any released JDK yet, so there is no macOS app image until JDK 27 arrives. Install a JDK 21 or newer and run `java -jar umamo-….jar`.
## These builds are not signed
Code signing and notarization arrive at alpha. Until then:
* Windows: SmartScreen shows "Windows protected your PC". Choose *More info* → *Run anyway*.
* MacOS: The JAR is unaffected by Gatekeeper quarantine, so nothing extra is needed while MacOS ships as a JAR.
* Linux: No equivalent prompt. Extract `tar xzf umamo-*.tar.gz` and run `umamo/bin/umamo`.
There are no installers yet and no auto-update: to upgrade, delete the old folder and unpack the new one.
## Status
Umamo is early alpha. Keep backups of your project files and work on copies.
NOTES
assets=(dist/*)
# A re-run of a failed publish must converge, not collide.
if gh release view "${TAG}" > /dev/null 2>&1; then
echo "release ${TAG} already exists — replacing its assets"
gh release upload "${TAG}" "${assets[@]}" --clobber
else
args=(
--title "Umamo ${VERSION}"
--notes-file "${notes}"
# Appends the auto-generated commit/PR list after the hand-written notes above.
--generate-notes
# DRAFT on purpose. A draft is invisible to non-collaborators, notifies nobody, stays
# out of the releases Atom feed, and is never "latest" — so a bad build can be deleted
# as though it had never existed. Publishing is one click, or:
# gh release edit <tag> --draft=false
--draft
)
if [ "${PRERELEASE}" = "true" ]; then
args+=(--prerelease)
fi
gh release create "${TAG}" "${args[@]}" "${assets[@]}"
fi
gh release view "${TAG}"
+71
View File
@@ -0,0 +1,71 @@
# The verification suite: lint + build + test on JDK 21 with a real headless GL context.
#
# This is a reusable workflow (`workflow_call`) rather than a job inside ci.yml, because two things
# need to run EXACTLY this and must not be allowed to drift apart: every push/PR (ci.yml) and every
# release (release.yml). A release that ran a subtly different suite than the branch gate is a
# release whose green tick means less than it looks like it does.
name: Verification
on:
workflow_call:
# Least-privilege default: checkout is all this workflow needs. GitHub reports each
# job's pass/fail as a PR status check natively, no extra `checks`/`statuses` scope required.
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
# Provides ANDROID_HOME + sdkmanager; needed for the :android app + android targets.
# `packages` is overridden because the action's default list includes the legacy `tools`
# package, which current cmdline-tools no longer resolve, and sdkmanager exits 1 on it.
- name: Set up Android SDK
uses: android-actions/setup-android@v4
with:
packages: platform-tools
- name: Install Android SDK packages
run: sdkmanager "platforms;android-36" "build-tools;36.0.0"
- name: Set up Gradle (with caching)
uses: gradle/actions/setup-gradle@v6
# :render's GL tests drive a real GLFW / OpenGL 3.3 core context and assert on read-back pixels,
# so without a display they cover exactly nothing. Xvfb + Mesa's llvmpipe give the runner a real
# context. libgl1-mesa-dri is the load-bearing one — it carries swrast/llvmpipe, and Mesa cannot
# do software GL without it. The GLFW X11 libs are listed explicitly rather than trusted to the
# runner image, so an image change fails here instead of silently degrading the suite.
- name: Install headless OpenGL (Xvfb + Mesa software GL)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
xvfb libgl1 libgl1-mesa-dri libglx-mesa0 libegl1 \
libxrandr2 libxinerama1 libxcursor1 libxi6 libxext6
# umamo.requireGl turns the GL tests' missing-context skip into a hard failure (HeadlessGlGate),
# so if this Xvfb setup ever stops yielding a context, CI says so instead of going green on a
# suite that ran nothing. That is the whole point of the step above — without this flag a broken
# Xvfb is indistinguishable from a pass. LIBGL_ALWAYS_SOFTWARE pins Mesa to llvmpipe, since the
# runner has no GPU.
#
# NOTE: the golden corpus (test/corpus/, gitignored) is absent here, so every corpus-gated test
# either skips or — for the ~76 print-and-return sites — reports PASSED while asserting nothing.
# This suite therefore proves markedly less than the same command does locally. See
# RELEASING.md § "What this gate does not prove".
- name: Build, test, and lint
env:
LIBGL_ALWAYS_SOFTWARE: "1"
run: >
xvfb-run -a --server-args="-screen 0 1280x1024x24"
./gradlew build --stacktrace -Dumamo.requireGl=true
+61
View File
@@ -0,0 +1,61 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
# Kotlin Gradle plugin data, see https://kotlinlang.org/docs/whatsnew20.html#new-directory-for-kotlin-data-in-gradle-projects
.kotlin/
# --- Gradle ---
.gradle/
build/
# The blanket `*.jar` rule above would also drop the committed Gradle wrapper jar.
# That jar MUST be tracked (it is how `./gradlew` bootstraps), so re-include it.
!gradle/wrapper/gradle-wrapper.jar
# --- Android / machine-local ---
local.properties
.cxx/
*.apk
*.aab
captures/
# --- IDE ---
.idea/
*.iml
*.ipr
*.iws
.vscode/*
!.vscode/settings.json
#Get fucked, Git.
/docs/formats
/docs/plans
/docs/format
/docs/plan
#Don't commit my personal models.
/test/corpus
/test/relive
/test/tools
/test/work
+199
View File
@@ -0,0 +1,199 @@
# Changelog
All notable changes to Umamo will be documented in this file.
Umamo is early alpha.
(Unreleased changes)
### Added
* Format: New native UMA file format!
* Format: A UMA document remembers each panel's open branches, filters, tab, and the UV Editor's texture choice, per area.
* Format: A UMA document reopens to the pose, selection, mode, cursors, pivot and proportional editing settings, and each viewport's pan and zoom it was saved with.
* Format: The `.uma` file type is now declared for desktop packages and Android along with freedesktop files in the Linux build to register it per user.
* UI: The unsaved-changes prompts when replacing a document or quitting now offer Save, Don’t Save, and Cancel.
* UI: Added save confirmation for dirty files when closing the application.
* UI: Opens to a new document by default with New and Open file menu operations available.
* UI: Can now drag and drop files on the window. Model files are opened and artworkd is added to the open document.
* UI: When a text entry box is active the mouse cursor now displays the text entry cursor everywhere to indicate that text entry is currently active.
* UI: Previous Workspace and Next Workspace added to Workspace menu.
* UI: Add hover tooltips to the Properties area and Operation Strip.
* Parameters: The parameters are now searchable.
* Source Artwork: The operation strip now offers to adjust the canvas placement of imported artwork to an existing document. The alignment and offset can be changed.
* Source Artwork: Hovering a layer, art, or drawable row in the Sources panel previews its art.
* Source Artwork: A new Import preference shows the Sources panel's layer positions measured from the world axes instead of the art file's top-left corner.
* Export: Image export of the current 2D Viewport with options for transparent, solid, and grid backgrounds.
### Changed
* UI: The CTRL+O keybinding was changed to file open instead of import CMO3.
* UI: Add Artwork and Import Artwork have been standardized to just import and add artwork to the open document.
* UI: Confirmation dialogs now take arguments for button names and actions along with a new third button.
* UI: Clicking away from all text input fields should now commit the change.
* UI: Clicking away from all text input fields should now end text entry input preventing other inputs from being eaten.
* UI: The command palette now lists only the commands that apply to the editor area under the pointer. For example, Mirror UVs no longer shows while editing a mesh in the 2D viewport.
* UI: The status bar's shortcut suggestions now follow the editor area under the pointer. This is the first iteration of this feature and will be improved in the future.
* UI: The popup overlap picker now uses the drawable name with the part name in parenthesis.
* UI: Buttons now use the accent color when pressed.
* UI: Positions in the Properties panel are now measured from the world axes, and the Origin fields place those axes from the canvas's bottom-left corner.
* UI: Before the 2D cursor is placed, the 2D Cursor pivot now turns about the world origin, the same point the cursor snaps already used, instead of the selection's median.
* UV Editor: Clicking inside a UV island in Object mode now selects it even where its texture is transparent. Where islands overlap, the one with visible art under the cursor still wins.
* UV Editor: Switching to another page or layer for the first time refits the camera then remembers the camera position from there on.
* UV Editor: Fit View now also frames meshes that sit past the edge of the atlas page.
* Texture Atlas: Repack Atlas is now available on CMO3 models saved with "Show source artwork" turned on.
### Fixed
* UI: Modal key ladder issue with escape closing the preferences window first instead of the confirmation dialog.
* UI: Dirty documents were obliterated when opening a new document since the dirty check was broken.
* UI: Panel state(open branches, filters, the UV Editor's texture choice) no longer resets when switching workspace tabs.
* UI: Pressing Escape while rebinding a key would close the preferences instead of just cancelling the rebind.
* UI: The keybindings editor's clear button no longer sits underneath the scrollbar.
* UI: Double-clicking a workspace tab after reordering the tabs now renames the tab that was clicked instead of the tab that used to be in that spot.
* Source Artwork: Removed the singleton that could be accidentally be shared across documents.
* Format: An artwork file whose magic bytes are missing now routes to its reader by extension.
* Format: Performance optimizations for the PNG CODEC resulting in up to 50% less memory usage and up to 50% faster loads.
* Viewport: Camera fitting now falls back to the canvas bounds when there are no drawables.
* Viewport: Changing an area between the UV Editor and the 2D Viewport no longer leaves the previous editor's contents and camera behind.
* Outliner: A CTRL+Left Click or Shift+Left Click followed quickly by a plain click on the same row no longer opens rename.
* Source Artwork: "Show source artwork" no longer draws layers misshaped, misplaced, and cut off on CMO3 models whose drawables use Cubism's reduced resolution texture copies.
* Source Artwork: Reloading or relinking a layer in a CMO3 whose drawables use Cubism's reduced resolution copies now points them at the new art on export, so Cubism shows the reloaded layer instead of the stale copy.
* Texture Atlas: Rebuilding the atlas after a reload, Replace Artwork, added artwork, or a repack no longer smears stretched pixels around art that touches the edge of its layer.
* Texture Atlas: CMO3 models saved in Cubism with "Show source artwork" turned on now load the texture atlas as the atlas pages instead of loading every individual layer as an atlas page.
* Viewport: Meshes that reach past the edge of their texture no longer smear the edge pixels across the overhang in the atlas display and clicking that overhang no longer selects the drawable.
## 0.3.0-dev - 2026-09-15
### Added
* Internationalization: Initial 한국어/Korean translation - Thank you to Nyaro for the translation.
* Export: Rework Cmo3AtlasUndedup to use the shared packer when exporting a fresh CMO3.
* Export: Generate layered art preview thumbnails for CMO3 export.
* Export: A document imported from source artwork(PSD, CLIP, or KRA) now writes its real layers and folders into the CMO3 instead of a synthesized stand-in, so the exported file reopens with every drawable's layer binding intact.
* Texture Authoring: The UV Editor now has object mode. Click an UV island to select the drawable it belongs to, box select multiple, and Alt+Left=Click through overlapping islands, mirroring how object selection already works in the 2D viewport.
* Texture Authoring: A Texture Page selector in the UV Editor header lets you pin the view to a specific atlas page(with its dimensions and mesh count shown) instead of always following the current selection, plus new Next/Previous/Follow Selection commands for stepping through pages from anywhere.
* Texture Authoring: The UV Editor can now show and edit a drawable's mapping directly over its original source layer artwork instead of only the packed atlas page, with a searchable "Find by Artwork" picker to jump straight to a layer's drawable. The cursor, pivot mode, snaps, and proportional editing all carry over to this view exactly as they work on the atlas page.
* Texture Authoring: A new "Show source artwork" document property switches the puppet between rendering from its packed texture atlas and rendering straight from each drawable's individual source layer, for checking the atlas mapping by eye before it's finalized.
* Texture Atlas: A new Repack Atlas command repacks every used piece of source artwork onto fresh atlas pages with Umamo's own packer. Art that can't be packed, too large for a page, empty, or unreadable, cancels the whole repack with a report naming each piece.
* Texture Atlas: Exporting a CMO3 that has been converted from a MOC3 and then had its atlass repacked should now write a fully consistent CMO3. Repacked layers should now properly target the renumbered pages.
* Texture Authoring: Turning on "Show source artwork" for a document whose artwork can't actually be displayed(nothing recoverable, or none of it decodes) now shows a notice instead of silently showing from the atlas instead.
* UI: A new Operation Strip modal will appear after the last operation in the focused 2D or UV viewport to make adjustments.
* Texture Atlas: Artwork placed on an atlas page can now be Grabbed, Rotated, and Scaled directly in the UV Editor's object mode, exactly like moving objects in the viewport. Moving a piece of art carries every drawable mapped to it along with it and the page recomposes around the new arrangement. Overlapping or off-page placements are flagged with an exact warning based on the art's actual painted pixels and mesh coverage, not just a bounding box.
* Texture Atlas: Placed artwork can now be pinned(P / Alt+P in the UV Editor's object mode, or the Data > Texture panel's checkbox) to protect it from being moved. Pinned art is left alone by a hand Grab/Rotate/Scale(which refuses with a clear message if every selected tile is pinned) and by Repack Atlas, whose settings strip has a Keep Pinned Tiles option to override that for a single run. Pinned-tile and warning highlight colors are now configurable in Settings > Colors.
* Texture Atlas: Repack Atlas's options(Max Page Size, rotation, gutter, extrusion, Alpha Threshold, and the square/power-of-two/shrink-to-fit flags) can now be adjusted after it runs from a small settings strip in the corner of the viewport or UV editor(or F9), which re-runs the repack instantly from where it started instead of asking for them in a dialog up front. Add Artwork, Reload, Match Automatically, and moving/rotating/scaling placed artwork get the same adjustable strip for their own settings(Alpha Threshold, Birth Mesh Margin, Match Threshold, and the move/rotate/scale amounts).
* Parameters: New default seed parameters are applied when import artwork for the first time.
* Source Artwork: A new Sources space lists every artwork file behind a document, each file's layers with a bound/bound-by-name/unbound status shown as a traffic-light colored icon, the tiles and drawables under each bound layer, and an Unbound Art group for anything left over, with a filter for Unbound, Missing, or Needs Review.
* Source Artwork: A new File > Import > Artwork… command opens a PSD, CLIP, or Krita(.kra)file, or a flat PNG/BMP/JPEG/WebP/TIFF, straight in as an editable rig.
* Source Artwork: An automatic birth mesh is created for every new drawable on a fresh import.
* Source Artwork: The Sources space's header Reload button re-reads every artwork file still present on disk and folds in whatever changed: a matched layer's tile gets the new pixels, an untouched area is simply re-cut from the new art, and a hand-edited mesh keeps its vertices and keeps sampling the same spot on the canvas. A layer that's gone missing or been renamed is never silently dropped from the rig, it's left alone and flagged for review instead. A CMO3-imported document can still relink and reload from its own original layers even when the source file isn't at its recorded path, or fails to read, by falling back to the layer images embedded in the CMO3 itself.
* Source Artwork: Artwork files can now be watched for changes for automatic reload or notify to reload(See: Setings -> Import).
* Source Artwork: A new Match Automatically command scores every layer that went missing from a reload against the rest of the file(by name, folder, position, size, and pixel content)and proposes a match right on its Sources row.
### Changed
* Texture Atlas: Where each piece of source artwork sits on the atlas is now part of the document rather than something re-derived every time it's opened, so it can be edited, undone, and written back out.
* MOC3 to CMO3 conversion: The stand-in source document rebuilt from a MOC3's atlas pages now also opens and renders correctly in the official Cubism Editor, including switching between its layered-art and texture-atlas display modes. The export notice wording was updated to describe what's actually still lost this way(the layers are baked-atlas slices, not the original editable artwork) instead of claiming the file wouldn't render at all.
* Source Artwork: The Sources space's relink and file-action menus, and the UV Editor's "Find by Artwork" layer picker, were rebuilt on the app's standard menu component, gaining grouped section headings and a searchable filter for long lists.
### Fixed
* UV Editor: Committing an edit could report vertices nobody moved as changed, because the display round trip wasn't bit-exact; this triggered spurious weld-divergence warnings on mappings that were never touched.
* MOC3 to CMO3 conversion: Reimported drawables were bound to a duplicate of the atlas page resource instead of the shared one the editor itself writes, which made every one of them look never packed and draw the wrong crop in the source layer view.
* Opening a document while another was already open could, for one frame, pair the new document with the previous document's editing session, so an export, the File menu, or the atlas page resolver could briefly act on stale data.
* Texture Atlas: Repack Atlas could apply a stale pack if a mesh was edited while the repack was still computing; it now cancels instead.
* Keyboard shortcuts could stop responding after using a dropdown chip, checkbox, number field, or section header that then disappeared from the screen while it still held focus; these now properly release focus back to the application.
* CMO3 Export: An artwork-imported document's parameters weren't placed in the export's parameter group hierarchy, and any part, drawable, or deformer with no authored keyforms at all exported with a missing keyform grid, both of which the official Cubism Editor refuses to open. Both are now written the way the editor expects.
* CMO3 Export: A CMO3-origin document's reloaded or newly added artwork kept the old pixels showing in the editor's layered-art view even after the texture atlas had already picked up the new art; it's now written into the document's own retained layer tree too, so both display modes match.
## 0.2.1-dev - 2026-08-11
### Added
* Diagnostic CLI: A new `:cli` module(`./gradlew :cli:run`) exposes headless `dump`, `convert`, `diff`, and `extract` for inspecting CMO3 and MOC3 files.
* MOC3 export: A new Export Options dialog for choosing MOC3 export granularity.
* History: The number of history steps is now configurable.
* Area Header Controls: Controls in area headers now overflow into a "...>" pop up instead of disappearing.
### Changed
* CMO3 import and export are now at beta level status. Numerous bugs have been corrected especially on the export side.
* MOC3 import to CMO3 export conversion is now alpha level status. Texture atlases are now automatically cut up into source artwork layers and the produced CMO3 now displays properly in the Cubism editor. While a cut up texture atlas won't be original layered artwork quality this makes it easier to manually reconcile the source artwork layers and also get a functional CMO3.
* Deformers imported from a MOC, which never have a display name in the MOC3, are now labeled with the drawable they deform when that's unambiguous(e.g. "Warp40 (ArtMesh5)") instead of just the raw identifier.
* Export notices, the report shown after an import or export finishes, are now localized instead of always appearing in English.
* The pointer is now properly tracked across all hovered areas and the old "active area ID" was removed. This fixes a lot of hotkey fighting between areas.
* Outliner: After searching then selecting an item in a collapsed branch, the branch is expanded with `revealTarget()` when clearing the search term.
* Viewport/UV HUD Overlay: Now shows the part, drawable, and deformer name in the upper left.
### Fixed
* Switch a part composite from isolated to anything else stops rendering composite effects. Originally for Umamo it was intended that opacity could be applied to have a part and have it cascade down to drawables to make it quick to change the opacity of all drawables in a part. However, reconciling Cubism behavior with Umamo desires would create too many problems.
* MOC3 export: Identifiers were being deduplicated before being truncated. This means the truncated identifier could then immediately become a duplicate again. Now they are truncated, deduplicated, and properly written into the MOC3 and sidecars.
* MOC3 export: Blend shape deltas under a deformer chain were computed in the wrong point space, looking up the entity's own space instead of its parent's, producing incorrect deltas for any blend shape nested under a deformer.
* MOC3 export no longer silently overwrites existing sidecar files(textures, model3.json, cdi3.json, and the rest) already present at the destination; it now warns and lists every file that would be overwritten before you confirm.
* Windows OS: Workaround for AWT not sending a resize event when cancelling a window resize on Windows causing the Compose around to be stuck at the wrong size until resizing without cancelling.
* Accessibility: Various semantics/contentDescription spots were fixed and visual tooltips added.
## 0.2.0-dev - 2026-08-03
### Added
* CMO3 export: Alpha level support of writing Cubism 5.4 compliant CMO3 files.
* MOC3 to CMO3 conversion: Development level support of writing Cubism 5.4 complient CMO3 files converted from MOC3. Source artwork reconciliation is not implemented yet so converted files will not display textures in the official Cubism editor.
* New :interop module that serves as the import and exporting interoperability border between the :format and :runtime modules.
* Keyform Sheet: New editor area for editing key forms and blend shapes for all keyable properties.
* Document > Runtime Target selection: Can now select the runtime target for the puppet including Ayagami and Cubism 3.0 through 5.4. Selecting a target will automatically hide features in the UI that are not available for that runtime.
* Right-click context menu(Cut/Copy/Paste/Select All) on text input fields throughout the UI. This replaces the built-in Compose menu that was blocking some context menus.
* Viewport rendering settings: Super sampling options to toggle off for performance improvements.
### Changed
* Properties Panel: Expanded and updated for the Keyform Sheet. Missing properties implemented and the ability to hover over a property then press a shortcut to key it was added.
### Fixed
* Dragging a panel splitter gutter no longer lags out and fails to work on slow systems. This was due to an issue with how the movement input was accumulated.
* Dragging a panel splitter gutter only writes up the layout settings after a debounce period.
## 0.1.0-dev - 2026-07-27
### Added
* Properties panel: A new editable, tabbed panel(Document/Object/Data) replacing the old read-only Inspector, with a header search that filters down to matching rows and switches tabs automatically. This brings in being able to edit many more puppet properties such as blend modes, alpha modes, compositing, and more.
* Logs panel: A new space showing the diagnostic output, color-coded by severity, with Copy to Clipboard and Export to File actions.
* Tagged releases: pushing a `vX.Y.Z` tag builds, tests, and publishes desktop artifacts for `linux-x64`, `linux-arm64`, `windows-x64`, `macos-arm64`, and `macos-x64` which are self contained application images with a bundled JRE plus a runnable uber jar per target. Unsigned, no installer, no auto-update yet. See [RELEASING.md](RELEASING.md).
### Changed
* Composite(part/group) rendering is faster: An isolated part whose blend is pose-identity Normal/Over over an all-Normal/Over subtree now draws inline instead of through its own offscreen layer, and each composite layer's clear/snapshot/draw is scissored to its subtree's posed bounds instead of the full viewport.
* Undo history entries for Grab/Scale/Rotate gestures are now labeled per domain and per operation(e.g. "Scale Vertices", "Rotate UVs", "Scale Objects") instead of collapsing to a generic "Move..." label regardless of what actually happened.
* The legacy "Add (Before 5.3)" / "Multiply (Before 5.3)" blend modes are relabeled "(Legacy)" and sorted to the bottom of the blend-mode picker; their properties no longer show the Alpha Blend field, which never applied to them. They might be renamed again in the future.
### Fixed
* Deformer opacity and multiply/screen color keyforms are now applied and cascade down the deformer hierarchy, so keying a deformer's opacity to show/hide a subtree, or its tint color to color a group animates correctly instead of being ignored.
* CMO3 artwork that wasn't packed into a texture atlas rendered enlarged with its outer margin clipped because its UVs weren't remapped through the image's logical frame transform.
* The legacy "Add"/"Multiply" blend modes rendered with incorrect, non-premultiplied math whenever Alpha Blend was set to anything other than "Over".
* The "Out" alpha blend mode cut a hole in the wrong layer(source instead of destination) inverting the intended silhouette effect.
* Extended blend modes(Multiply, Screen, Overlay, etc.) mis-blended under Conjoint/Disjoint alpha blending because the blend mix weight ignored the selected alpha mode; unpremultiplied colors are now also clamped to avoid out of range artifacts.
* MOC3-imported drawables' multiply/screen tint keyforms were silently dropped when rest mesh geometry was rebased to canvas space.
## 2026-07-14 – 2026-07-20
### Added
* Source-art format support: readers for **BMP, JPEG, PNG, TIFF, and WebP**, alongside the existing PSD/CLIP/KRA support, broadening what art files Umamo can ingest.
* Alpha Shape Analysis: Pass that traces and simplifies the silhouette of a layer's alpha channel which is early groundwork toward automatic mesh generation from source art.
* MOC3 Import: Umamo can now load existing `.moc3` runtime files directly (not just `.cmo3` editor projects), converting them into an editable puppet.
* Blend Shape Support: Corrective blend shapes implemented end-to-end: decode/encode in the MOC3 format, CPU/GPU evaluation, and rendering, matching Cubism behavior.
* Offscreen/Composite Rendering: Parts can now render to an offscreen buffer and be composited with correct opacity and blend modes across nested groups, matching Cubism's part-level offscreen drawing feature in the viewport.
* Active/Selected object is now highlighted in a distinct color in the outliner and viewport.
* Snap radial(pie) menu for the UV Editor.
### Changed
* Rebuilt the renderer around a backend-neutral `RenderDevice` abstraction, splitting the previously monolithic GL renderer into focused pieces (shaders, frame encoding, GPU resource handles). This lays groundwork for future Android (GLES) and macOS/iOS (Metal) rendering backends.
* Outliner row striping now fills top-to-bottom consistently.
* CI now runs GL rendering tests in a headless environment.
### Fixed
* MOC3 import: incorrect rotation-deformer scaling.
* Several CMO3 read/write round-trip issues.
* MacOS crash/blank-viewport bug caused by an incorrect GLFW library binding (community contribution from Giodotblue).
+110
View File
@@ -0,0 +1,110 @@
# Credits & Third-Party Attributions
Umamo is licensed under the GNU General Public License v3.0.
Project Lead: Azxiana - https://azxiana.com/
## Translations
한국어/Korean - Thank you to Nyaro for the translation.
## Gylphs
Tabler Icons - MIT License - https://github.com/tabler/tabler-icons/blob/main/LICENSE
Inter Font - SIL Open Font License 1.1 - https://raw.githubusercontent.com/rsms/inter/v4.1/LICENSE.txt
Noto Sans CJK - SIL Open Font License 1.1 - https://github.com/notofonts/noto-fonts/blob/main/LICENSE
Blender Icons - CC BY-SA 4.0 - https://creativecommons.org/licenses/by-sa/4.0/ - https://ui.blender.org/icons
Blender Cursors - GNU General Public License v3.0 - https://projects.blender.org/blender/blender/src/branch/main/doc/license/GPL3-license.txt - https://projects.blender.org/blender/blender/src/branch/main/release/datafiles/cursors
## MOC3 File Format
Umamo's MOC3 file format reader is based on Lina Hoshino's black box reverse engineering of the format.
https://www.youtube.com/@HoshinoLina
https://www.youtube.com/watch?v=eEa0-wt1SqE
https://www.youtube.com/watch?v=iT3A0AhK3YE
https://www.youtube.com/watch?v=5AiZTgUx_WM
## Krita KRA File Format
- Upstream: Krita - https://invent.kde.org/graphics/krita
- License: GNU Public License, Version 3
Umamo's KRA file format reader was ported directly from the official Krita repository.
## Clip Studio Paint CLIP File Format
Umamo's CLIP file format reader is based on research by rasensuihei.
https://github.com/rasensuihei/cliputils
MIT License: https://github.com/rasensuihei/cliputils/blob/master/LICENSE
## TwelveMonkeys ImageIO - PSD, TIFF, and WEBP readers (BSD 3-Clause)
- Upstream: TwelveMonkeys ImageIO, `imageio-psd` module - https://github.com/haraldk/TwelveMonkeys
- Copyright (c) 2008-2020 Harald Kuhr
- License: BSD 3-Clause
- Upstream: TwelveMonkeys ImageIO, `imageio-tiff` (and `imageio-metadata`, `common-io`) modules - https://github.com/haraldk/TwelveMonkeys
- Copyright (c) 2012 Harald Kuhr, Oliver Schmidtmer
- License: BSD 3-Clause
Covers the LZW, PackBits, horizontal-predictor, and CCITT (Modified Huffman RLE / T.4 / T.6) decoders.
The IFD parser, pixel assembly, and JPEG-in-TIFF handling are Umamo's own.
- Upstream: TwelveMonkeys ImageIO, `imageio-webp` module - https://github.com/haraldk/TwelveMonkeys
- Copyright (c) 2017 Harald Kuhr, Simon Kammermeier
- License: BSD 3-Clause
Per the BSD 3-Clause terms, the original copyright notice is retained here and in the header of the derived source file. The ported code is distributed as part of Umamo under GPLv3.
```
BSD 3-Clause License
Copyright (c) 2008-2020, Harald Kuhr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
## Baseline JPEG Decoder - Independent JPEG Group
- Upstream: Independent JPEG Group's reference JPEG library (libjpeg) - https://www.ijg.org/
- Copyright (c) 1991-2020, Thomas G. Lane, Guido Vollbeding
- License: IJG License (permissive, GPL-compatible)
Umamo's JPEG decoder (`org.umamo.format.jpeg`) is an independent Kotlin implementation written from the public ITU-T T.81 specification. Accordingly, and per the IJG license's terms for distributing derived work:
> This software is based in part on the work of the Independent JPEG Group.
The decoder is distributed as part of Umamo under GPLv3.
## poly2tri — constrained Delaunay triangulation (BSD)
- Upstream: orbisgis/poly2tri - https://github.com/orbisgis/poly2tri
- License: New BSD License
Used by Add Vertex Accept to triangulate closed draft rings with zigzag (Delaunay) diagonals.
## Bundled Libraries
FileKit - https://github.com/vinceglb/FileKit/blob/main/LICENSE
poly2tri - https://github.com/orbisgis/poly2tri
+9
View File
@@ -0,0 +1,9 @@
This is purely for a marketing blitz later.
* Modern UI that doesn't suck!
* CMO3 Import/Export!
* MOC3 Import/Export!
* Krita(KRA) and Photoshop(PSD) Import!
* Resolution independent scaling(Modern!)
* Pen and Touch Support!
* Android! (Tablets only though, you're crazy if you try to do this on your phone.)
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{{ project }} Copyright (C) {{ year }} {{ organization }}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+261
View File
@@ -0,0 +1,261 @@
# Umamo
An open-source cross-platform modelling editor for 2D puppet animation, with first class pen and touch support, designed to interoperate with the Live2D Cubism source format (`.cmo3`). Runs on Windows, macOS, Linux, and Android tablets with pen/touch input. Supports importing and exporting both CMO3 and MOC3 formats.
> **Status:** Early development. Prebuilt downloads are on the [Releases page](https://github.com/umamoorg/umamo/releases). Note, releases are not currently signed so Windows and MacOS will complain about it. APIs, formats, and scope are in flux.
![Screenshot showing the main Umamo window with 2D puppet posed and smiling in a centered viewport. The left side shows an adjustable parameter panel while the right shows an object outliner, information, and history panel.](docs/screenshots/readme20260905.webp)
## Quick Notes
**Q:** Can I support the Umamo project financially?
**A:** Umamo is completely open source and free, but if you would like to support the project you can [join the Patreon](https://patreon.com/Azxiana) or make a one time [donation through Ko-Fi](https://ko-fi.com/azxiana). All received funds go directly to paying hosting bills, hardware for testing, and platform developer fees. Excess funds will be banked for the future or distributed to other open source projects working with the Umamo Project.
---
**Q:** Does Umamo do animations yet?
**A:** Not yet. This is a long term stretch goal. Getting the modeling, UV editor, and physics interface perfected first will be important for animation later.
---
**Q:** Umamo doesn't support a newer version of Cubism/Krita/Clip Studio Paint file formats yet. Can you add support?
**A:** Yes, please [search if the issue has already been reported](https://github.com/umamoorg/umamo/issues) and if not, [open a new issue](https://github.com/umamoorg/umamo/issues/new) that describes the problem.
---
**Q:** Umamo corrupted my project and I lost my work! HELP!
**A:** Currently Umamo is alpha level software available for testing. Please make sure to **make regular backups** of your files. In fact, make second copies of your files explicitly for playing around with. Do not use the original copies.
## Downloads
Every tagged version publishes desktop builds on the [Releases page](https://github.com/umamoorg/umamo/releases). There are two different releases per platform:
| File | Note |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `umamo-<target>-<version>.zip`/`.tar.gz` | Java SDK not required, just run it directly. |
| `umamo-<target>-<version>.jar` | You will need Java SDK 21 or higher to run. Either open through the file browser or through the command line. `java -jar umamo-...jar` |
Targets: `linux-x64`, `linux-arm64`, `windows-x64`, `macos-arm64`, `macos-x64`. Check your download against the release's `SHA256SUMS.txt`.
**These builds are not signed.** Code signing and notarization cost a lot of money so I will be waiting to do that until getting to a release candidate stage. Until then Windows and MacOS will complain about the applications being unsigned.
- **MacOS:** Gatekeeper will quarantine the application and report it as *damaged*. It is not damaged. After unzipping run this in the Terminal, `xattr -dr com.apple.quarantine /path/to/umamo.app`, or allow the application through the settings.
- **Windows:** SmartScreen shows "Windows protected your PC". Choose *More info* -> *Run anyway*.
- **Linux:** Just run the application: `tar xzf umamo-*.tar.gz` and run `umamo/bin/umamo`. Linux doesn't restrict you from running any application that you wish to run on your computer.
### Opening .uma files from the file manager
Since the builds are plain archives without installers the `.uma` mimetype won't be registered automatically by the operating system. Linux has a manual mimetype registration option while Windows and MacOS will wait for their respective installers in the future.
- **Linux:** The archives come with freedesktop.org files to register the mimetype manually. Put `umamo/bin/umamo` on your `PATH`(or edit the `Exec=` line in `umamo.desktop` to its full path), then register them for your user:
```bash
xdg-mime install --novendor umamo/lib/app/resources/umamo-uma.xml
xdg-desktop-menu install --novendor umamo/lib/app/resources/umamo.desktop
```
`xdg-mime uninstall` and `xdg-desktop-menu uninstall` with the same files to undo it.
## Building & Development
Umamo is a Kotlin Multiplatform project (Gradle, Kotlin DSL) targeting desktop and Android from one shared codebase.
| Platform | Note |
| -------- | --------------------------------------------------------------------------------------------------- |
| Windows | Regularly built and tested |
| Linux | Regularly built and tested |
| MacOS | Working, minimally tested. |
| Android | Not yet, incomplete graphics layer implementation is blocking it. |
| iPadOS | Application and UI loads, but there is no puppet renderer and JDOM is incompatible. |
### Prerequisites
- **JDK 21** (LTS). The build is pinned to a 21 toolchain. Point `JAVA_HOME` at a JDK 21 — e.g. `export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64`. (Newer JDKs run Gradle fine, but are ahead of the Android toolchain.) Use a distribution JDK, not Homebrew's: `:desktop:createDistributable` runs Compose's `checkRuntime`, which hard-errors on a Homebrew JDK unless you pass `-Pcompose.desktop.packaging.checkJdkVendor=false`.
- **Android SDK** with `platforms;android-36` and `build-tools;36.0.0`. Set `ANDROID_HOME` (or create `local.properties` with `sdk.dir=…`). Only needed for the Android target.
The Gradle wrapper (`./gradlew`) pins the Gradle version so no system Gradle install required.
### Common commands
```bash
./gradlew :desktop:run #Launch the desktop editor
./gradlew :android:installDebug #Deploy to a connected Android tablet
./gradlew build #Everything
./gradlew test #Unit tests
./gradlew ktlintFormat #Format all files according to .editorconfig
./gradlew -q :cli:run --args="dump model.moc3" #Dump a CMO3/MOC3's contents to stdout
./gradlew -q :cli:run --args="convert model.cmo3 out.moc3" #Convert between formats(Overwrites WITHOUT confirmation)
./gradlew -q :cli:run --args="diff a.cmo3 b.moc3" #Compare two models semantically
# Cross-target the desktop build (default: host). -Pumamo.target swaps the bundled Skiko + LWJGL
# natives: linux-x64 | linux-arm64 | windows-x64 | macos-x64 | macos-arm64.
./gradlew :desktop:packageUberJarForCurrentOS -Pumamo.target=windows-x64
# Self-contained app image with a bundled JRE (what the release workflow ships).
# → app/desktop/build/compose/binaries/main/app/
./gradlew :desktop:createDistributable
```
`-Pumamo.target` is meaningless for `createDistributable` and must not be combined with it: an app image jlinks the *host* JDK into itself, so cross-resolving the natives would bundle one platform's Skiko/LWJGL inside another platform's runtime. Only the uber jar is portable that way. Pass `-Pumamo.requireTargetIsHost=true` (as CI does) to turn a mismatch into a build failure.
### Running on WSL2 (WSLg)
Two things differ from a native Linux box (neither applies on a real desktop/GPU):
- **Use the system JDK 21, not Homebrew's.** Homebrew's `openjdk@21` has a few issues resolving libraries so it is easier to use the system installed JDK. Install `sudo apt install openjdk-21-jdk` and point `JAVA_HOME` at it: `export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64`.
- **Opt into the GPU.** Mesa defaults to the `llvmpipe` software rasteriser on WSL; select the hardware D3D12 path explicitly. Compose's own Skiko renderer can't make a hardware GL context under WSLg, so let it fall back to software.
```bash
MESA_LOADER_DRIVER_OVERRIDE=d3d12 GALLIUM_DRIVER=d3d12 SKIKO_RENDER_API=SOFTWARE \
./gradlew :desktop:run
```
### Cross-building for another platform
By default the desktop build bundles the natives for the machine running it. Pass `-Pumamo.target=<os>-<arch>` to bundle a *different* platform's natives instead which is useful for testing a Windows build from a WSL2/Linux checkout. Recognized targets: `linux-x64`, `linux-arm64`, `windows-x64`, `macos-x64`, `macos-arm64`.
```bash
# Produce a Windows-native runnable uber-jar from WSL2/Linux:
./gradlew :desktop:packageUberJarForCurrentOS -Pumamo.target=windows-x64
# → app/desktop/build/compose/jars/
```
This swaps both the Compose/Skiko renderer native and the LWJGL GL natives so the jar runs on the target. It is **not** a cross-compiler: the result is portable JVM bytecode plus the target's natives, so you still need a **matching JVM on the target** to launch it.
Don't combine `-Pumamo.target` with `:desktop:run` — that would load the target's natives in your host JVM and fail. The override is for producing artifacts and not running locally.
### Module layout
Reusable library modules live under `module/`, runnable application targets under `app/`. Everything else at the repo root (`gradle/`, `docs/`, build files) is intentionally *not* a module. A module's Gradle path (`:format`) is kept flat and independent of its folder. See: [settings.gradle.kts](settings.gradle.kts)
| Module | Directory | Targets | Role |
| ----------- | ----------------- | ------------- | ------------------------------------------------------------------------------------------------------ |
| `:format` | `module/format` | jvm + android | Cubism file family + art I/O (CMO3 read/write, …) |
| `:reimport` | `module/reimport` | jvm + android | Source-art binding + non-destructive reconcile |
| `:storage` | `module/storage` | jvm + android | App config/data dirs + file IO (okio) + native file dialogs (FileKit) |
| `:settings` | `module/settings` | jvm + android | JSON settings: defaults←user merge, dotted get/set, change Flow → `:storage` |
| `:runtime` | `module/runtime` | jvm + android | Puppet model + CMO3 ingest |
| `:render` | `module/render` | jvm + android | Deformation eval (CPU) + renderer + morph-blend shaders (`expect`/`actual`: LWJGL / GLES) → `:runtime` |
| `:ui` | `module/ui` | jvm + android | Compose Multiplatform editor shell |
| `:desktop` | `app/desktop` | jvm | Desktop entrypoint (Compose Desktop + LWJGL viewport) |
| `:android` | `app/android` | android | Android entrypoint (Activity + Compose + GLSurfaceView) |
Shared logic lives in `commonMain`; platform code in `jvmMain`/`androidMain` via `expect`/`actual`.
### Input, Commands, & Settings
- **Action registry.** Every editor operation is a named `Command` in a central `CommandRegistry` (`:ui`, `org.umamo.ui.action`); menus, the command palette, and key bindings all dispatch through it, so handlers are never hardcoded in widgets. A command palette lists the registry with adaptive search.
- **Key bindings.** Chords are stored logically, by key *position* plus a platform "primary" modifier (CMD on macOS, CTRL elsewhere), so shortcuts survive non-QWERTY layouts and map per OS. They resolve through a `Keymap`; a built-in default (`defaultKeymap`) along with editable user-persisted keymaps and presets(settings `input.keybinding.preset`).
- **Settings.** A layered JSON tree: bundled defaults ← user overrides, addressed by dotted keys (`:settings`), persisted via `:storage` and emitting change events the UI reacts to.
### File formats
Editor-format knowledge for CMO3, MOC3, and CLIP are reverse-engineered by black box observation. KRA is ported directly from Krita's own open-source GPLv3 code which is license-compatible with Umamo. All are written up under [`docs/format/`](docs/format).
#### File Format Support
| Format | Read | Write | Note |
| ------ | ---- | ----- | ---------------------------------------------------------------------------------------- |
| PSD | 〇 | - | Photoshop (Read only) |
| CLIP | △ | - | Clip Studio Paint (Read only) - Implemented, not fully tested. Has some blending issues. |
| KRA | 〇 | - | Krita (Read only) - ZIP + maindoc.xml + tiled LZF rasters; ported from open source. |
| UMA | 〇 | 〇 | Umamo Model File |
| CMO3 | 〇 | 〇 | Cubism Editor Model File - Compatible up to Cubism 5.4 |
| MOC3 | 〇 | 〇 | Cubism Distribution Model File - Compatible up to Cubism 5.4 |
#### Format Documents
Reverse engineered file formats have documentation in the [docs/format/](docs/format/) folder.
#### Diagnostic CLI
The `:cli` module (`app/cli`) is a headless dump, convert, diff, and atlas packing tool over the same CODEC and conversion stack the editor uses. Run it through Gradle; relative paths resolve against the repository root. Always pass `-q` so Gradle's own build output stays out of the tool's output. The tool writes data to stdout and diagnostics to stderr. The convert command will **overwrite WITHOUT confirmation**.
```bash
./gradlew -q :cli:run --args="dump model.moc3" #Static-rig summary
./gradlew -q :cli:run --args="dump model.moc3 --sections" #Container tier: per-section presence + counts
./gradlew -q :cli:run --args="dump model.cmo3" #CAFF entry table + main.xml overview
./gradlew -q :cli:run --args="dump model.cmo3 --xml" #Decompressed main.xml, byte-for-byte (Redirectable)
./gradlew -q :cli:run --args="dump model.cmo3 --puppet" #Import to PuppetModel and summarize (Either format)
./gradlew -q :cli:run --args="dump art.psd" #Artwork canvas, folders, per-layer inventory + trimmed bounds
./gradlew -q :cli:run --args="extract model.cmo3 out/" #Unpack the archive (Plaintext main.xml + layer PNGs) into out/model/
./gradlew -q :cli:run --args="atlas art.psd out/" #Pack the layers into out/art/page_NN.png + placements.txt
./gradlew -q :cli:run --args="atlas art.clip out/ --preview" #Also recomposite the canvas from the packed pages.
./gradlew -q :cli:run --args="convert in.cmo3 out.cmo3" #Resave (An unedited main.xml will reemit byte-identical.)
./gradlew -q :cli:run --args="convert in.moc3 out.moc3" #Rebake (Fresh synthesis, NOT byte-identical by design.)
./gradlew -q :cli:run --args="convert in.cmo3 out.moc3" #Full family: moc3 + model3.json + cdi3.json + textures
./gradlew -q :cli:run --args="convert in.moc3 out.cmo3" #Fresh-graph synthesis (Always reports MissingSourceArt)
./gradlew -q :cli:run --args="diff a.cmo3 b.moc3" #Semantic per-entity diff of two models
```
A moc3 input may also be given as its `.model3.json` manifest; textures and sidecars(cdi3/physics3/pose3/userdata3) are discovered through the manifest's file references.
Both `dump` and `atlas` accept source layered artwork(`.psd`, `.clip`, `.kra`) or any flat raster read as a one-layer document. The `atlas` command takes `--page-size=N`, `--gutter=N`, `--extrude=N`, `--rotate`, `--visible-only`, and `--no-shrink`. It reads every packed tile back out of its page and exits non-zero if any byte differs and reports layers it could not pack(no opaque pixels, or larger than a page) rather than dropping them silently.
#### Running Tests
All tests can be run with `./gradlew test` or individual tests can be run like so:
`./gradlew :interop:jvmTest --tests "org.umamo.interop.PuppetModelDiffTest"`
#### Corpus Testing
Each CODEC and reader have tests that run against real samples that you can supply. Note: The `/test/corpus` is intentionally gitignored to prevent accidentally committing private data. If you don't supply samples then the tests will automatically skip.
Put your samples at `test/corpus/` and they are picked up automatically:
```
test/corpus/cmo3/ EricaTamamo.cmo3 (the model the CMO3 gate's exact counts are pinned to)
test/corpus/moc3/ Put each model's files in a separate subdirectory.
Artwork:
test/corpus/clip/ test/corpus/psd/ test/corpus/krita/ test/corpus/tiff/ test/corpus/jpeg/
```
```bash
./gradlew :format:jvmTest #Corpus automatic discovery.
./gradlew :format:jvmTest -Dcmo3.sample=/path/to/Model.cmo3 #Point at one explicitly.
./gradlew :format:jvmTest --tests "org.umamo.format.cmo3.tools.ModelGenerator" -Dcmo3.generate=true -Dcmo3.gensample=/path/to/Model.cmo3 --rerun #Generate new CMO3 model and registration. Make sure to run ktlintFormat afterwards to clean up.
```
## Legal & Trademark Notice
Umamo is an independent, community-developed project. It is **not affiliated with, authorized by, endorsed by, or sponsored by Live2D Inc.** (formerly Cybernoids Co., Ltd.) or any of its affiliates.
"Live2D®" and "Cubism" are trademarks of Live2D Inc. in Japan and/or other countries; all other trademarks are the property of their respective owners. These marks are used here only nominatively, to describe file-format compatibility, and **no endorsement, affiliation, or sponsorship is implied.**
## Contributors
WANTED: Human translations for various languages.(Japanese, Chinese, Korean, Spanish, French, German, etc.)
The English strings are located at: `module/ui/src/commonMain/composeResources/values/strings.xml`
At the moment I'm not accepting large code contributions from outside contributers. Small fixes are accepted, but please keep in mind that at moment the development speed on this project is rapid. I'm might make your change obsolete by the time I get around to reviewing it.
(Once large changes are accepted in the future.)
If you are planning a large change that touches many files then break it down into a stack of smaller pull requests that build on each other. For example, if you're adding a new export format:
* PR 1: Add the underlying data structures/parser with tests, no UI wiring yet.
* PR 2: Add the export logic that consumes those structures, merged on top of PR 1.
* PR 3: Wire up the UI/CLI flag that exposes the feature, merged on top of PR 2.
Each PR should be reviewable and mergeable on its own instead of being submitted as one giant diff. This makes review faster and makes it easier to bisect regressions.
### Provenance & Reverse Engineering
Umamo's **editor-format layer** (`.cmo3`/`.moc3` read/write, `.clip` ingest) is a **clean-room reimplementation** built from black-box observation of file outputs and independently produced documentation.
By contributing you affirm:
1. No use of official Live2D/Cubism source or decompiled binaries as a basis, knowledge only from observing file outputs and public, independently authored documentation.
2. You are not bound by a Live2D agreement your contribution would breach, and will disclose any such license before contributing.
3. Are not a past or present employee of Live2D or Cybernoids.
If you have been exposed to Live2D source code or decompiled binaries, please do not contribute.
### AI Usage Disclaimer
Large Language Models(LLM) are used to assist with [rubber ducking](https://en.wikipedia.org/wiki/Rubber_duck_debugging) and housekeeping tasks. Assisted tasks include planning development road maps, function documentation, and helping to keep the developer focused. AI has not been and will never be used to decompile or otherwise discover the source code of protected software.
## License
**GPLv3** See [LICENSE](LICENSE)
+82
View File
@@ -0,0 +1,82 @@
# Releasing Umamo
Pushing a semantic version tag builds, tests, and publishes desktop artifacts for all five supported targets.
## What ships
Two files per target, ten in total, plus a `SHA256SUMS.txt`:
| File | For |
| ------------------------------------------ | ---------------------------------------------------------------------------------------- |
| `umamo-<target>-<version>.zip` / `.tar.gz` | Self-contained app image (`:desktop:createDistributable`). Bundles a jlinked JRE. |
| `umamo-<target>-<version>.jar` | Uber jar (`:desktop:packageUberJarForCurrentOS`). Needs a JDK/JRE 21 on the machine. |
Targets and the runner each is built on:
| Target | Runner |
| ------------- | ------------------ |
| `linux-x64` | `ubuntu-latest` |
| `linux-arm64` | `ubuntu-24.04-arm` |
| `windows-x64` | `windows-latest` |
| `macos-arm64` | `macos-latest` |
| `macos-x64` | `macos-15-intel` |
Every leg builds on its own OS and architecture. Unlike the uber jar, an application image cannot be cross-produced: jpackage jlinks the *host* JDK into the image, so cross-resolving natives would bundle one platform's Skiko/LWJGL inside another platform's runtime. The package job passes `-Pumamo.requireTargetIsHost=true` so an unexpected runner `os.arch` fails the build rather than shipping an artifact that runs nowhere.
Out of scope until alpha: code signing, notarization, native installers, auto-update, and any Android artifact. See `TODO.md` § Build and Distribute.
## File associations
The `.uma` document type (`application/vnd.umamo.uma+zip`, `docs/format/UMA.md` § 2) is declared once per OS in `app/desktop/build.gradle.kts` (`fileAssociation`) and in the Android manifest. What that does depends on the artifact, because on Windows and Linux jpackage applies `--file-associations` to **installers only**:
| Platform | Today's artifacts | With an installer |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| Linux | Not registered. The app image ships `lib/app/resources/umamo-uma.xml` and `umamo.desktop`; the README gives the two per-user `xdg-*` commands. | deb / rpm register the type. |
| Windows | Not registered. *Open with* only. | msi / exe register the type. |
| macOS | The app image's own `Info.plist` carries `CFBundleDocumentTypes`, so an unpacked `umamo.app` is the handler with no installer - but see below. | Same. |
| Android | The manifest's VIEW intent filters; no artifact ships yet. | n/a |
The macOS legs publish the uber jar only until JDK 27 (the `appImage: false` note in `release.yml`), and a jar has no bundle to associate. Setting `appImage` back to `true` is therefore also what switches the macOS association on; the open-file handler in `Main.kt` is already in place for it and has not been exercised on a real bundle.
`OsAssociationFilesTest` (`:desktop`) holds the build script, the manifest, and both freedesktop files to the codec's `Uma.MIME_TYPE`, and evaluates the freedesktop magic against a file the writer really produces. Those files are declared as inputs of `:desktop`'s test task - they are not on its classpath, so without that an edit to one leaves the test up to date and unrun.
## Cutting a release
1. Bump `VERSION` in `module/ui/src/commonMain/kotlin/org/umamo/ui/help/ProjectInfo.kt`. The workflow **verifies** the tag against it and never injects a version so a mismatch will fail with an annotation telling you what to fix.
2. Update the `CHANGELOG.md` with new changes under a `## [X.Y.Z] - YYYY-MM-DD` heading.
3. Run the pre-flight checks below.
4. Merge to `master`, then tag and push:
```bash
git tag vX.Y.Z && git push origin vX.Y.Z
```
5. The workflow creates the release as a **draft**, marked prerelease when the version carries a suffix. Download the artifacts and launch at least one per OS before publishing. The CI does not test the packaged binaries.
6. Publish: `gh release edit vX.Y.Z --draft=false`, or discard and re-tag:
```bash
gh release delete vX.Y.Z --yes
git push --delete origin vX.Y.Z && git tag -d vX.Y.Z
```
Prerelease tags are supported as well, so having `-dev` or `-rc` is fine. However, jpackage rejects prerelease suffixes, so `project-version.gradle.kts` strips it for `packageVersion` while everything user visible keeps the full string.
To rehearse the whole pipeline without a tag, run the workflow manually(`gh workflow run release.yml --ref <branch>`). With no tag, the version gate synthesizes `v<ProjectInfo.VERSION>`, sets `publish=false`, and the publish job is skipped. All of the artifacts will be visible on the action runner page and not published as a release.
## Local Pre-flight Checks
```bash
# Export a compatible Java SDK location other Compose's checkRuntime will error.
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
./gradlew :desktop:suggestRuntimeModules # after any dependency change
./gradlew :desktop:createDistributable :desktop:packageUberJarForCurrentOS
./gradlew build # what the release gate runs
# The corpus suites specifically — see the caching caveat below.
./gradlew :format:jvmTest :runtime:jvmTest :render:jvmTest :ui:jvmTest --rerun
```
Then check the app image at `app/desktop/build/compose/binaries/main/app/`:
* `umamo/lib/app/umamo.cfg` — the `[JavaOptions]` block must carry `-Xmx4g` and **must not** carry `-Dumamo.testCmo3`. Compose forwards `application.jvmArgs` to jpackage as `--java-options`, so anything added there ships; the corpus-preview override is deliberately set on the `run` task alone (see the comment at the bottom of `app/desktop/build.gradle.kts`).
* `umamo/lib/runtime/release` — the `MODULES=` line must list `java.instrument`, `java.sql`, `java.xml`, `jdk.security.auth`, and `jdk.unsupported`. The release workflow asserts this too.
`suggestRuntimeModules` under-reports: it misses reflective and service-loaded edges, and does not name `java.xml` even though JDOM — and therefore all of CMO3 read/write — needs it. Treat its output as a lower bound and confirm with `jdeps --list-deps` when adding a dependency.
+298
View File
@@ -0,0 +1,298 @@
# TODO
## Documentation
* Have a full model/ map made in docs/. (When everything is done.)
## Deferred
* GPU glue: multi-pair seam vertices (deferred 2026-06-21)
* Android GLES renderer backend (deferred 2026-06-21)
## WORK STEPS - 2026-09-14
~~1.) Leftovers - Art Sourcing Pipeline Verification~~
~~2.) Operation Strip - Make sure all application operations are using it.~~
~~3.) Phase C - Art Sourcing Pipeline - Cmo3AtlasUndedup Refit~~
~~4.) Phase H - Art Sourcing Pipeline - CMO3 Interop Hardening~~
5.) Phase D - Art Sourcing Pipeline - Automatic Mesh from Art - This should become it's own planning document.
6.) (Everything required for glue, deformers, and so on.)
7.) UMA Format (Phase G - Art Sourcing Pipeline) - Mostly done, a few final pieces to go through.
## VERY IMPORTANT
* Hire translators for localization.
* Final pass on keyboard shortcuts.
* Final pass on default settings.
* Final pass on default workspace layouts.
* Final pass on theme colors.
## User Stories
* glTF export for easy import into game engines. (Requested; far future.)
* Shares buffer/accessor concepts with UMA's bulk-geometry encoding decision (docs/plan/uma-format.md U1), and would slot into the Document › Runtime export-targets model (§ Properties Panel).
* From CrystalorImLisa on Reddit: The ability to mirror deformers and drawables along with their key frames.
* Umamo solution: Select a deformer and the drawable -> Duplicate -> Mirror X (On the duplicate) -> Do some minor UV clean up -> Done!
* https://www.reddit.com/r/Live2D/comments/1uy0871/is_there_a_way_to_duplicate_a_warp_deformer/
* From @thesillydarku on Twitter: "I had to manually add the "-Xmx4g" flag otherwise got java memory heap errors when trying to export to CMO3"
* https://fixupx.com/thesillydarku/status/2102974212952707294
## Artwork Import
* We need to properly handle different blending mode imports from artwork to setup the drawables automatically.
* Automatic visual matching of imported artwork layers to layers cut from a texture atlas after a MOC3 to CMO3 conversion.
## Puppet Model, CMO3, MOC3
* Parameter Repeat
* Glue
* CMO3
* ACParameterControllableSource.isVisible was wired up so now the outliner needs this toggle as well. Deformer editing is not implemented yet so this is minor.
* Refactor interop/cmo3/ in the same way that interop/moc3/ was done.
* MOC3
* (Check the bullshit the AI did without my permission.) CDI3 - Export mesh display names as a separate array.
* Reconcile isVisible/isEnabled from MOC3 for deformers. Maybe for CMO3 too.
## Tools, Shortcuts, and Gizmos
* Improvements
* Unconnected proportional editing should edit all meshes when multiple meshes are selected for edit mode. I would like to merge the proportional button and falloff settings into one menu with the connected checkbox.
* ALT+H (Unhide All) and SHIFT+H (Hide everything that is not selected.)
* New Icons (For myself to get/make.)
* Replace magnet from the cursor/selection menu.
* The Tabler icons on the toolbar are probably fine, but I will check what is available from the Blender icons.
## Overlays Toggle
* Overlay visibility toggles from viewport header.
* General Information - The spot in the AreaHeader showing the selected item will be moved here. It's too much in the AreaHeader.
* Wireframe (Object Mode)
* Grid - Ability to change scale and divisions.
* 2D Cursor
## Object and Mesh Editing
* Improvements
* Mirror along X/Z axis, mirror with 2D cursor as the axis. Note: This is a small divergence to Blender's style. In Blender there is an origin for each object that can be moved to different places. Umamo still has the centroid origin calculated, but no way to move it or even if it was moved, a way to store it.
* Extrude(E) - Extrude an edge creates triangle cut quad automatically.
## Texture Authoring/UV Editor
* Follow Selection Header Control - Split it into options and images.
* New custom image selection control. This will also be an entry point for adding artwork.
* Support renaming images.
* Improvements
* Long running atlas packing should have a progress visible in the status bar. We can also reuse this for other operations such as file open/import/export.
* Bugs
* When relinking EricaTamamo.psd in EricaTamamo.cmo3 it results in some layers getting fringe artifacts like what was experienced in the past.
## UV Editor
* Bugs/Improvements
* Rip and Vertex Slide could be implemented for UV.
* Do a study to determine if rip functionality is really needed. It is definitely needed for 3D work, but for 2D work I think it is less useful. Though I'm curious what people would create with the functionality being available.
* Mirror UVs are shown in the command palette when editing a mesh in the 2D viewport.
* This is actually kind of useful, but technically breaks the border of the command palette only showing what is available per area.
* Pixels outside of the canvas still need to render.
* UV Snap Pie
* (Deferred) Selected to Adjacent Unselected - Moves selection to adjacent unselected element.
* Implementation difficulty: This moves the UV vertex that has been disconnected from its sibling, which is one vertex in the mesh, on top of each other. We will have to either walk the UV/mesh to find the sibling or store it. Selected to Adjacent Unselected is only needed if rip is supported in UVs.
* Relax/Pinch tools - deferred; needs brush machinery (radius cursor, per-stroke commits) that nothing else has yet.
# Mesh and UV Editor Gizmos
* Improvements
* Hold CTRL to enable snapping for rotation and grid placement.
## Shortcuts
https://hollisbrown.github.io/blendershortcuts/ - I should make a page like this demonstrating the shortcuts for Umamo.
## Properties Panel
* The document-level **runtime-compatibility target data model** behind Document › Runtime — the enabled export targets (Cubism, Ayagami, …) + each target's options, how it persists on the document, and how it drives CMO3/MOC3 export. Scaffolded as a placeholder section now; its data design is a separate pass (depends on cataloguing each target runtime's capabilities).
* UMA serialization of the latent composite (the format work this unblocks).
* Improvements
* Deformers still have no editable Object-mode transform — needs the deformer → part → mesh cascade (parts already expand to their subtree meshes for G / S / R).
* Do another pass on the keyed parameter/property highlight colors. Why does off key filled color appear as grey over green?
* Transform Position and Size should update the render while scrubbing.
* Aspect locked properties(Size) should update the other control while one is being scrubbed.
* Single/multiple relation pickers.
* Improvements
* Persist list height.(Stored in UMA format, maybe?)
* Deformer pickAt().
* Context Menus
## Parameters
* Parameter templates:
* Need a way to apply these without having to do a fresh import.
## Menus
* Clicking again should close instead of reopen the menu.
## Tooltips
* Consider swapping to BasicTooltipBox in the future to get rip of the desktop and Android split of TooltipArea. BasicTooltipBox is more recent as of writing this, July 2026, is being actively iterated against.
## Workspace Tabs
* Improvements
* Visual feedback of the tabs moving out of the way when reordering them.
## Keymap
* Keymappings will need to become area contextual. For example: P is pin in the UV editor area. Once the Separate operation(Into multiple drawables) exist, if we want to match Blender's P shortcut for that then it has to become contextual per area.
## Format
### File
* Automatic Backup
### UMA (Native File Format)
* Improvements
* Preview thumbnail should take a snapshot of the 2D space and not from the part thumbnailer. The part thumbnail does not respect visbility and so on.
* Format icon helper - Display thumbnail as the icon with the Umamo logo overlaid. Requires an installer.
See the roadmap: docs/plan/art-sourcing-pipeline.md § Phase G — the source-agnostic container is designed there.
See format planning document: docs/plan/uma-format.md
## Import
* MOC3 sidecar discovery on Android. MOC3 might be a desktop only feature.
## Render
* GPU glue: multi-pair seam vertices — latent correctness gap; see Claude Notes § GPU glue: multi-pair seam vertices.
## Glue
* Glue intensity is keyable but has no Properties home(glue is not selectable). See Claude Notes § Glue intensity has no editable home.
## UI
* Viewport view styles - Top right, in the header area.
* Viewport loading overlay and mouse busy pointer.
* AreaHeader/Viewport2DHeaderControls
* Font size and icon sizes don't line up resulting in the font being 1px offset.(Lots of manual tweaking is required.)
* Menu - New Items
* Edit
* Cut/Copy/Paste
## Theme Colors
* Ability to edit ALL the theme colors (the UmamoColors palette) for a custom look through preferences. For example, in Blender I make my vertex colors as ff00ec(unselected), ff7a00(selected), and 7de400(active selection) since it is easier for me to see.
* The color-blind-assist first pass — vertex/edge/face gizmo colors plus the selection highlight — already exists in Settings > Colors.
## Refactor
* module/render/src/commonMain/kotlin/org/umamo/render/puppet/PuppetRenderer.kt
## DRY/Standardization
* Fields like PropertyFieldRow need to take a key use use that to get the correct resource key automatically instead of passing it.
* For Example: properties_field_base_angle - "base_angle" -> Expanded out to `properties_field_base_angle` and `properties_field_base_angle_description`.
* There are plenty of places in the code base that are passing the values around like this at the moment. Difficulty: .* import level maybe? I need to read up on the Kotlin compiler optimization to determine if this will be an issue.
* operatorParameterDescriptionRes also is the start of something of what I am thinking, but hardcoded.
## Settings
* Keybinding - input.keybinding (Includes keyboard, mouse, and pen buttons.)
* Pen Binding (JPen, Wacom) - input.pen (Includes pen, pressure, and things related to the radial menu.)
* Quick Setup
* Versioned Settings
* Import from Previous
* The settings UI needs a design pass since it is basically just squares and whatever thrown together right now.
* New Settings
* Setting to make Left Click, instead of ALT+Left Click, the default to activate the popup overlap picker.
## Keybindings
* Audit default keybinding maps for Blender and Cubism styles.
## Future Feature Wishes
* Pose Reference - A poseable and adjustable 3D mannequin model for overlay reference.
* Really good edge detection for auto-mesh.
* Normal map, emission, metallic, and reflection shaders for texturing.
* Key/mouse/pen input overlay for recording/streaming.
* History playback for proof of work. The history system is there, but that is a lot of track over a long session. So capture a snapshot every time period or number of snapshots.
* A proper bone skeleton system with bendy bones.
## Build and Distribute
* Eventually get installers, signing, and automatic updates setup.
## MacOS
* Zoom with the touchpad on my 2014 Macbook Pro is glitchy. It will jump around and even go the wrong direction.
* Need to add back a light native menu so it does not say "MainKt" all the time.
## Input
### Pen backend + radial menu (sketch, deferred)
Sketch:
- Settings: `input.pen.backend` ("auto"/"native"/"jpen"/"disabled"), later `input.pen.pressureCurve` etc.
- A `PenInput` seam (commonMain interface) producing pressure / tilt / barrel buttons, `expect`/`actual`: Android `actual` via `MotionEvent` (`getPressure`, `getAxisValue(AXIS_TILT/ORIENTATION)`) in the viewport pointer pipeline (Android pen is the easier, priority target per the thesis); desktop `actual` via JPen or Wintab / Windows Ink behind the seam (the risky part — no clean Compose-desktop pressure path). Barrel buttons bind to commands through the existing action registry.
- Radial menu: a commonMain Compose overlay whose entries come from the action registry, opened by a pen-bound action / long-press — the keyboardless-tablet entry point that carries tool switching and reaching Preferences (per CLAUDE.md).
- `PenSection`: backend dropdown now, pressure-curve editor later; replaces the stub.
- Why deferred: desktop pressure integration + the radial menu + a per-mode keymap context model is a feature of its own. Plan separately once Phase 3's keymap foundation lands (the radial menu and barrel-button binds reuse it).
## Command Palette
* Icons for commands - Long tail feature, would need to add a lot of icons. We can reuse the existing icons for current commands such as editor/select modes.
## Status Bar
* The first iteration to improve the status bar hints was a good success. Eventually:
* Hint icons (Mouse button indicator, etc.)
* Better contextual hints: Swap out anything that is irrelevant when selecting for example and just show selection relevant shortcuts.
## Pose Palette/Library
* Cubism 5.4 added a "Model state set" which is just a pose library. The data is saved into the CMO3 file. This should be easy to implement and store in the native UMA format.
## Color Space and Management
Right now the goal is to support sRGB from ingest to output with full correctness. Eventually we want to be able to add linear color space, HDR, and so on. While vtubers typically are 100% sRGB(art, edit, broadcast) some game developers may opt for different color spaces and require that flexibility. I'm tentatively planning this work for Q1 2027.
# Claude Notes
## GPU glue: multi-pair seam vertices (deferred 2026-06-21)
**What.** The GPU glue weld (`PuppetRenderer` two-pass; `module/render/src/commonMain/.../puppet/`) stores **one
partner per vertex** in its per-vertex glue attribute (partner global index, glue index, weld weight; built
in `buildGlueAttributes`, consumed by `GLUE_VERTEX_SHADER`). If a single mesh vertex participates in **more
than one** glue pair — e.g. a corner vertex shared by two seams — only the last-written pair survives, so the
GPU applies **one** weld where the CPU `applyGluesResolved` applies **both, sequentially**. That would diverge
from the CPU/oracle at such shared verts.
**Why it's fine right now.** Erica's four glues have **disjoint** seam vertices (no vertex is in two pairs),
so the GPU render is pixel-perfect vs the CPU (maxDiff 3/255, 0 px >8). This is a **latent** gap that only a
model with shared seam verts would expose.
**Detection.** Add a glue-aware per-vertex check: run the two-pass GPU glue, transform-feedback-capture the
**post-weld** positions, and diff against the CPU `applyCpuDeform` (which includes glue) on a model whose
glue pairs share vertices. (The existing `GpuDeformValidationTest` only validates the pre-glue deform.)
**Fix options (when/if it bites).**
1. Per-vertex support for *N* partners: widen the glue attribute to a small fixed array (or an indexed side
buffer) and loop the welds in the shader **in the CPU's pair order** so the sequential result matches.
2. Detect shared seam verts at import and fall those specific glue meshes back to CPU glue (the hybrid path),
keeping the rest on the GPU.
## Deformer keeps no rest geometry once its last axis is collapsed (found 2026-09-04)
**What.** `withAxisCollapsed` returns null when the last axis goes, and `withParameterDeleted` stores that
null as a warp's or rotation's `geometryGrid` - so the deformer's lattice / pivot, which lived only in that
grid, is gone from the model. The CMO3 export then has nothing to write for it and removes the source's
`keyformGridSource`; the official editor refuses a source without a default keyform (`setKeyformGridSource`
rejects null, `getDefaultKeyForm` throws "no KeyForms" - the same refusal that crashed it on the first
artwork-origin export, fixed for drawables/parts/glue by writing one default cell in
`Cmo3KeyformLowering.buildBundle`).
**Why it's fine right now.** Nothing in the editor deletes a parameter that keys a deformer's geometry
except the parameter-delete flow, and the structure round-trip gate only reaches the case by choosing a
victim parameter that keys deformer geometry.
**Fix sketch.** Keep the rest cell: a last-axis collapse should yield an axis-less one-cell grid holding the
form at the kept key (the deformer's rest lattice / pivot), not null - for drawables too, since the export
then writes the same shape the corpus does. Once that holds, `writeGridWeb`'s empty-bundle branch becomes
unreachable and can go.
## Glue intensity has no editable home (deferred 2026-07-29)
**What.** `Glue.intensity` is a real keyable channel — `FormChannel.GLUE_INTENSITY`, with a static on
`Glue` and a track in `channelGrids` — and the keyform sheet already renders a row per glue and can move,
insert and delete its keys. What it has nowhere is a **Properties** home: there is no `SelectionTarget.Glue`,
no outliner entry, and no property section, so intensity cannot be typed, scrubbed, or keyed with `I` the
way every other channel now can. `:edit` also has no `withGlueIntensity` / `setGlueIntensity`; the only
writes are whole-object reconstructs inside the keyform and topology ops.
**Why it's fine right now.** The channel is reachable where it matters most — the sheet — and intensity is
the least-touched of the keyable channels (a weld is usually 1.0 and left alone). Nothing is silently
broken: an unexposed channel simply cannot be edited, rather than being editable and wrong.
**What giving it a home costs.** Four things, none of them local:
1. A new `SelectionTarget.Glue`, which touches selection, the outliner, the relation-pick system, and every
exhaustive `when` over selection targets.
2. A stable identity story. A glue has **no id** — `KeyformOwner.Glue` addresses it by the `(meshA, meshB)`
pair precisely because a list ordinal is not stable across edits (`KeyableTarget.kt`).
3. `Glue` is a plain `class`, not a `data class`, so it has no `copy()`; every rewrite reconstructs the full
constructor. A `withGlueIntensity` must do the same.
4. An outliner presence raises a design question that has never been answered: where does a glue *sit* in a
tree organised by parts and deformers, when it belongs to neither and welds two meshes that may be far
apart in it?
**Fix sketch (when/if it bites).** The cheap half is `withGlueIntensity` / `setGlueIntensity` plus a
`GlueChange`, following the standard three-file property-op pattern — that alone would let the sheet's
context menu and `I` write the static. The expensive half is selectability, and is worth deferring until
there is a second reason to want it.
+82
View File
@@ -0,0 +1,82 @@
// :android (app/android) — Android entrypoint (Activity + Compose + GLSurfaceView viewport).
// A plain Android application module (not KMP): it consumes the shared KMP libraries.
// :android — Android 起動点(Activity + Compose + GLSurfaceView ビューポート)。
plugins {
// AGP 9+ has built-in Kotlin support, so the org.jetbrains.kotlin.android plugin is gone —
// applying it now errors. AGP compiles Kotlin itself; the Compose compiler plugin hooks in.
alias(libs.plugins.androidApplication)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
}
// Resolve the application version from ProjectInfo.kt (see gradle/project-version.gradle.kts) so
// versionName never drifts from what the About dialog shows.
apply(from = rootProject.file("gradle/project-version.gradle.kts"))
val umamoVersion = extra["umamoVersion"] as String
android {
namespace = "org.umamo.editor.android"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
// applicationId is the permanent Play identity; it intentionally differs from `namespace`
// so org.umamo stays a clean umbrella for a future viewer app.
applicationId = "org.umamo.editor"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
// versionCode is Play's monotonic release counter — bumped by hand on release; it cannot be
// derived from a semver string.
versionCode = 1
versionName = umamoVersion
}
buildTypes {
release {
isMinifyEnabled = false
}
}
// Keep AGP's Java compilation in lockstep with Kotlin's JDK 21 target (otherwise the
// "inconsistent JVM target" error bites the moment any Java source appears).
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
packaging {
resources {
excludes += "/META-INF/LICENSE.md"
excludes += "/META-INF/LICENSE-notice.md"
}
}
}
kotlin {
jvmToolchain(21)
}
dependencies {
implementation(project(":ui"))
implementation(project(":runtime"))
// Editing core (EditorSession / Selection model): the Android host creates a per-document session
// the same way the desktop does; declared directly for parity with :runtime / :render.
implementation(project(":edit"))
implementation(project(":render"))
// androidAppStorage + the per-OS config/data dirs the settings live in; also pulls FileKit
// (api-exposed by :storage), whose Android pickers MainActivity initialises with FileKit.init.
implementation(project(":storage"))
// The Settings type returned by LocalSettings: :ui depends on :settings only via implementation, so
// MainActivity needs it on its own classpath to read settings.getString / observe settings.changes.
implementation(project(":settings"))
// setContent { } lives in androidx.activity.compose.
implementation(libs.androidx.activity.compose)
// Direct Compose Multiplatform coordinates via the version catalog — the old `compose.runtime`
// plugin aliases were deprecated in CMP 1.10/1.11. The artifacts still redirect to
// androidx.compose on this Android target (Gradle metadata), so resolution is unchanged; see the
// catalog note on the `compose-*` entries and the matching :ui commonMain block.
implementation(libs.compose.runtime)
implementation(libs.compose.foundation)
implementation(libs.compose.ui)
}
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Minimal manifest: one launcher Activity. Uses a platform Material theme so no AppCompat
/ res/values theme setup is needed for the scaffold. namespace (build.gradle.kts) supplies
the package, so the manifest carries no package attribute (AGP requirement). -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Umamo"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.NoActionBar">
<!-- singleTask: a document opened from another app while the editor runs is delivered to THIS activity
(onNewIntent), where the shell asks about unsaved changes, rather than stacking a second editor. -->
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Umamo documents (docs/format/UMA.md § 2), from a provider that knows the type. -->
<intent-filter android:label="Umamo">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="application/vnd.umamo.uma+zip" />
</intent-filter>
<!-- Most file managers do not know the type and report a generic one, so those are matched by NAME:
pathSuffix where the platform has it (API 31), and the pathPattern ladder below it - a pattern's
".*" stops at the first dot, so each extra dot in a path needs a pattern of its own. A file that
matches by name and is not a UMA is refused by the loader's own check of the content. -->
<intent-filter android:label="Umamo">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="application/octet-stream" />
<data android:mimeType="application/zip" />
<data android:pathSuffix=".uma" />
<data android:pathPattern=".*\\.uma" />
<data android:pathPattern=".*\\..*\\.uma" />
<data android:pathPattern=".*\\..*\\..*\\.uma" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.uma" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,118 @@
package org.umamo.editor.android
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import io.github.vinceglb.filekit.FileKit
import io.github.vinceglb.filekit.dialogs.init
import org.umamo.storage.androidAppStorage
import org.umamo.ui.ProvideSettings
import org.umamo.ui.app.EditorApp
import org.umamo.ui.app.HostOpenRequests
import org.umamo.ui.app.rememberDocumentFileFor
import org.umamo.ui.app.rememberEditorSessionFor
import org.umamo.ui.app.rememberExitGuard
import org.umamo.ui.document.Document
import org.umamo.ui.document.newBlankDocument
import org.umamo.ui.theme.ProvideAppThemeFromSettings
import org.umamo.ui.theme.UmamoTheme
/**
* Android entrypoint. Mounts the same shared [EditorApp] shell desktop runs - the full File / Edit /
* Workspace / Help menu bar, document open/save through the SAF picker, the per-document editing
* session, area tree, command palette, and the Preferences window - over the Android storage/settings
* foundation. The 2D GL viewport is the one piece still platform-deferred: viewport areas render
* placeholders (viewportServiceFactory = null) until the GLES sibling of the desktop render service
* lands; the platform split stays confined to the viewport, as intended.
*/
class MainActivity : ComponentActivity() {
/**
* Documents another app hands over - a `.uma` tapped in a file manager arrives as a VIEW intent - waiting for
* the shell to open them. Held by the activity so an intent delivered to the running editor (onNewIntent)
* reaches the same shell as the one that launched it.
*/
private val openRequests = HostOpenRequests()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Only a fresh launch reads the launching intent: a recreated activity (a rotation the manifest does not
// absorb, a process restore) would otherwise reopen the file over whatever the rigger has open by then.
if (savedInstanceState == null) {
openFrom(intent)
}
// FileKit owns the activity-result registry its open/save pickers dispatch through, so it must be
// initialised once with the Activity before any file dialog (or a .clip read) runs.
FileKit.init(this)
val storage = androidAppStorage(this)
setContent {
// ProvideSettings loads settings asynchronously and gates the tree until they are ready; Android
// has no zero-window hazard (that is desktop-only), so the async load is safe here. UmamoTheme
// wraps the whole content (matching desktop's Main) so LocalUmamoColors resolves to the active
// scheme for everything created here, including the future GLES viewport host.
ProvideSettings(storage) {
ProvideAppThemeFromSettings {
UmamoTheme {
// The editor always has a document: it starts in a new, empty one.
var document by remember { mutableStateOf<Document?>(newBlankDocument()) }
val session = rememberEditorSessionFor(document)
val documentFile = rememberDocumentFileFor(document)
val exitGuard = rememberExitGuard()
// Back leaves the app (on Android 8 to 11 it destroys the root activity, edits and all), so
// while the document is dirty it asks through the same guard as File > Exit - and while a
// save is being written it goes through the guard too, which waits for the file to land.
// A clean, idle document keeps the platform's own back behavior.
val dirty = session?.dirty?.collectAsState()?.value == true
BackHandler(enabled = dirty || documentFile?.saving == true) {
exitGuard.request { finish() }
}
EditorApp(
document = document,
session = session,
documentFile = documentFile,
onOpen = { document = it },
onExit = { finish() },
exitGuard = exitGuard,
// The GLES puppet render service is the remaining platform work; until it lands the
// shared shell runs fully (menus, document, panels, thumbnails) with placeholder viewports.
viewportServiceFactory = null,
openRequests = openRequests,
)
}
}
}
}
}
/**
* A VIEW intent delivered while the editor is already running: the manifest makes the activity singleTask, so
* a second document opens here - through the shell's unsaved-changes check - instead of in a second activity.
*
* @param Intent intent The new intent.
*/
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
openFrom(intent)
}
/**
* Forwards the document a VIEW intent names to the shell. The uri string is the same form the recent-files
* list stores, so the shell opens it the way it opens a recent file. The grant behind it is usually read-only
* and never persistable: a Save to it can fail into the save alert (Save As works), and the recent entry it
* leaves can fail later as the soft miss a stored uri already is.
*
* @param Intent? intent The intent to read.
*/
private fun openFrom(intent: Intent?) {
if (intent?.action == Intent.ACTION_VIEW) {
intent.data?.let { documentUri -> openRequests.request(documentUri.toString()) }
}
}
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Adaptive launcher icon (API 26+; minSdk is 26, so this covers every target device). The OS
masks the two layers to the device shape (circle/squircle/rounded square). Background is the
solid backdrop color; foreground is the mascot rendered into the central safe zone. The legacy
mipmap-*/ic_launcher.png bitmaps remain only as a fallback for contexts that request a raw icon. -->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Round-mask variant of the adaptive icon. Same two layers as ic_launcher.xml; the OS applies the
round mask. android:roundIcon in the manifest points here for launchers that request the round form. -->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Backdrop color for the adaptive launcher icon's background layer. Keep in sync with the
`background` variable in docs/design/appicon/generate.sh (which bakes the same backdrop into the
opaque desktop/window/legacy bitmaps) so a re-skin changes every surface together. -->
<resources>
<color name="ic_launcher_background">#FFFFFFFF</color>
</resources>
+45
View File
@@ -0,0 +1,45 @@
// :cli (app/cli) — the headless diagnostic tool: dump / extract / atlas / convert / diff over cmo3,
// moc3, and source artwork files.
// JVM-only on purpose: it is an operator's tool, not a shipping app target. It deliberately avoids
// :ui (whose document layer drags in Compose via LiveParams) and :edit — everything it needs is the
// :interop conversion surface plus :render's space/texture helpers.
plugins {
alias(libs.plugins.kotlinMultiplatform)
}
kotlin {
jvmToolchain(21)
jvm()
sourceSets {
jvmMain {
dependencies {
// :interop api-exposes :format and :runtime, so those come transitively.
implementation(project(":interop"))
// restMeshesToCanvasSpace / canvasToParentSpaceFor and the atlas texture helpers.
implementation(project(":render"))
}
}
}
}
// A hand-registered JavaExec rather than the application plugin: the compose.desktop application
// block is the repo's only other runnable and is not wanted here. Only file collections are
// captured (never the Project), keeping the task configuration-cache safe; `--args` works through
// JavaExec's built-in @Option.
val cliMainCompilation = kotlin.jvm().compilations.getByName("main")
val repositoryRoot = rootDir
tasks.register<JavaExec>("run") {
group = "application"
description = "Runs the Umamo diagnostic CLI; pass arguments with --args=\"dump model.moc3\"."
mainClass.set("org.umamo.cli.MainKt")
classpath(cliMainCompilation.output.allOutputs, cliMainCompilation.runtimeDependencyFiles)
// Relative file arguments should resolve against the repo root the operator invoked from, not
// this subproject's directory (JavaExec's default).
workingDir = repositoryRoot
// The atlas packer holds every source layer's pixels plus the pages it composes, and a real
// document is hundreds of megabytes of raster before a single page is allocated. The JVM
// default (a quarter of RAM) is not something to leave to the operator's machine.
maxHeapSize = "6g"
}
@@ -0,0 +1,353 @@
package org.umamo.cli
import org.umamo.format.art.SourceArt
import org.umamo.format.art.SourceLayer
import org.umamo.format.art.SourceLayerKind
import org.umamo.format.art.isEffectivelyVisible
import org.umamo.format.atlas.AtlasPackItem
import org.umamo.format.atlas.AtlasPackOptions
import org.umamo.format.atlas.AtlasPackPlacement
import org.umamo.format.atlas.AtlasPackResult
import org.umamo.format.atlas.atlasPackItems
import org.umamo.format.atlas.packAtlas
import org.umamo.format.png.PngCodec
import org.umamo.format.raster.RasterImage
import java.io.File
/*
* The atlas subcommand: pack a source artwork document's layers into texture atlas pages.
*
* The packer's standalone proof and inspection surface, beside the editor's own Repack Atlas command
* (document.repackAtlas): it writes the pages, reports every placement, and checks each packed tile
* back out of the page it landed on before claiming success.
*/
/** Canvas pixels past which the preview composite is skipped rather than allocated. */
private const val PREVIEW_PIXEL_CAP = 128_000_000
/**
* Runs `atlas <file> [<directory>] [options]`.
*
* Output lands in a NEW subdirectory named after the input, created under the given directory
* (default: the input file's own directory), matching how `extract` keeps its output from mixing
* into a folder that already holds other files.
*
* @param List arguments The subcommand's arguments.
* @return Int The exit code; 1 when a packed tile fails to read back out of its page.
*/
internal fun runAtlas(arguments: List<String>): Int {
val parsed =
parseArguments(
arguments,
knownFlags = setOf("--rotate", "--visible-only", "--no-shrink", "--preview"),
knownOptions = setOf("--page-size", "--gutter", "--extrude"),
)
if (parsed.positionals.isEmpty() || parsed.positionals.size > 2) {
throw CliUsageException(
"Usage: atlas <file> [<directory>] [--page-size=N] [--gutter=N] [--extrude=N] " +
"[--rotate] [--visible-only] [--no-shrink] [--preview]",
)
}
val loaded = loadInput(parsed.positionals[0])
if (loaded !is LoadedInput.SourceArtInput) {
throw CliUsageException("Atlas applies to source artwork only (psd, clip, kra, or a flat raster)")
}
val gutter = parsed.intOption("--gutter", 2)
val options =
AtlasPackOptions(
maxPageSize = parsed.intOption("--page-size", 4096),
gutter = gutter,
extrude = parsed.intOption("--extrude", minOf(2, gutter)),
allowRotation = "--rotate" in parsed.flags,
shrinkPages = "--no-shrink" !in parsed.flags,
)
val art = loaded.art
val visibleOnly = "--visible-only" in parsed.flags
val include: (SourceLayer) -> Boolean = { layer ->
layer.kind == SourceLayerKind.Raster && (!visibleOnly || art.isEffectivelyVisible(layer))
}
val includedLayers = art.layers.filter(include)
val items = art.atlasPackItems(include)
if (items.isEmpty()) {
throw CliUsageException("${loaded.file.name} has no raster layers to pack")
}
val nonRasterCount = art.layers.count { layer -> layer.kind != SourceLayerKind.Raster }
if (nonRasterCount > 0) {
System.err.println("Note: $nonRasterCount non-raster layer(s) carry no pixels and were not packed.")
}
println("Packing ${items.size} layer(s) of ${loaded.file.name} (${art.widthPx}x${art.heightPx} canvas)")
val result = packAtlas(items, options)
val outputDirectory = resolveOutputDirectory(loaded.file, parsed.positionals.getOrNull(1))
outputDirectory.mkdirs()
writePages(result, outputDirectory)
writeReport(result, includedLayers, items, options, loaded.file, outputDirectory)
reportSkips(result)
if ("--preview" in parsed.flags) {
writePreview(art, includedLayers, items, result, outputDirectory)
}
val mismatches = verifyTiles(items, result)
if (mismatches.isNotEmpty()) {
System.err.println("VERIFY FAILED: ${mismatches.size} tile(s) do not match their source pixels:")
mismatches.take(10).forEach { message -> System.err.println(" $message") }
return 1
}
println("Verified ${result.placements.size}/${result.placements.size} tiles byte-exact")
return 0
}
/**
* Resolves the output subdirectory, named after the input file.
*
* @param File inputFile The source artwork file.
* @param String? parentDirectory The caller's directory argument, when given.
* @return File The directory the pages and report write into.
*/
private fun resolveOutputDirectory(inputFile: File, parentDirectory: String?): File {
val parent = if (parentDirectory != null) File(parentDirectory) else (inputFile.parentFile ?: File("."))
val directory = File(parent, inputFile.nameWithoutExtension)
if (directory.exists()) {
System.err.println("Note: ${directory.path} already exists; its matching files will be overwritten.")
}
return directory
}
/**
* Encodes and writes every packed page.
*
* @param AtlasPackResult result The packing outcome.
* @param File outputDirectory The directory to write into.
*/
private fun writePages(result: AtlasPackResult, outputDirectory: File) {
for ((pageIndex, page) in result.pages.withIndex()) {
val target = File(outputDirectory, "page_${pageIndex.toString().padStart(2, '0')}.png")
val bytes = PngCodec.write(page)
target.writeBytes(bytes)
val occupancy = (result.pageOccupancy(pageIndex) * 100f).toInt()
println("Wrote ${target.path} (${page.width}x${page.height}, $occupancy% occupancy, ${bytes.size} bytes)")
}
}
/**
* Writes the placement report: the options the pack ran with, one line per placement, then the skips.
*
* @param AtlasPackResult result The packing outcome.
* @param List layers The layers that were offered to the packer, in the same order as [items].
* @param List items The pack items, parallel to [layers].
* @param AtlasPackOptions options The options the pack ran with.
* @param File inputFile The source artwork file.
* @param File outputDirectory The directory to write into.
*/
private fun writeReport(
result: AtlasPackResult,
layers: List<SourceLayer>,
items: List<AtlasPackItem>,
options: AtlasPackOptions,
inputFile: File,
outputDirectory: File,
) {
val layerNameByKey = items.indices.associate { itemIndex -> items[itemIndex].key to layers[itemIndex].name }
val target = File(outputDirectory, "placements.txt")
val report = StringBuilder()
report.appendLine("#atlas placements for ${inputFile.name}")
report.appendLine(
"#options pageSize=${options.maxPageSize} gutter=${options.gutter} extrude=${options.extrude} " +
"rotate=${options.allowRotation} shrink=${options.shrinkPages}",
)
for ((pageIndex, page) in result.pages.withIndex()) {
report.appendLine(
"#page $pageIndex ${page.width}x${page.height} ${(result.pageOccupancy(pageIndex) * 100f).toInt()}% occupancy",
)
}
report.appendLine("#page\tx\ty\twidth\theight\tturns\ttrimX\ttrimY\tkey\tname")
for (placement in result.placements) {
report.appendLine(
listOf(
placement.pageIndex,
placement.pageX,
placement.pageY,
placement.pageWidth,
placement.pageHeight,
placement.quarterTurns,
placement.trimLeft,
placement.trimTop,
placement.key,
layerNameByKey[placement.key].orEmpty(),
).joinToString("\t"),
)
}
for (skip in result.skipped) {
report.appendLine("#skipped\t${skip.reason}\t${skip.key}\t${layerNameByKey[skip.key].orEmpty()}")
}
target.writeText(report.toString())
println("Wrote ${target.path} (${result.placements.size} placements, ${result.skipped.size} skipped)")
}
/**
* Prints the skip tally to stderr, grouped by reason.
*
* A page that looks right while several layers quietly went missing is this stage's characteristic
* failure, so the skips are reported every run rather than only living in the written report.
*
* @param AtlasPackResult result The packing outcome.
*/
private fun reportSkips(result: AtlasPackResult) {
if (result.skipped.isEmpty()) {
return
}
for ((reason, skips) in result.skipped.groupBy { skip -> skip.reason }) {
System.err.println("Note: ${skips.size} layer(s) not packed - $reason")
}
}
/**
* Reads every packed tile back out of its page and compares it to the source pixels.
*
* This is the command's reason to exist: the atlas is a repackable indirection over the source art,
* so a page that does not reproduce the art it was built from is worthless however good it looks.
* The page-coordinate mapping ([pagePixelOf]) is written out in this file rather than shared with the
* packer, so a wrong rotation convention cannot agree with itself.
*
* @param List items The tiles that were packed.
* @param AtlasPackResult result The packing outcome.
* @return List One message per mismatching tile, empty when every tile matched.
*/
private fun verifyTiles(items: List<AtlasPackItem>, result: AtlasPackResult): List<String> {
val itemsByKey = items.associateBy { item -> item.key }
val mismatches = mutableListOf<String>()
for (placement in result.placements) {
val item = itemsByKey.getValue(placement.key)
val page = result.pages[placement.pageIndex]
var mismatch: String? = null
for (tileY in 0 until placement.trimHeight) {
for (tileX in 0 until placement.trimWidth) {
val (pageX, pageY) = pagePixelOf(placement, tileX, tileY)
val sourceOffset = ((placement.trimTop + tileY) * item.width + placement.trimLeft + tileX) * 4
val pageOffset = (pageY * page.width + pageX) * 4
for (channelIndex in 0 until 4) {
if (item.rgba[sourceOffset + channelIndex] != page.rgba[pageOffset + channelIndex]) {
mismatch = "'${placement.key}' tile pixel ($tileX, $tileY) at page ($pageX, $pageY)"
break
}
}
if (mismatch != null) {
break
}
}
if (mismatch != null) {
break
}
}
mismatch?.let { message -> mismatches.add(message) }
}
return mismatches
}
/**
* The page pixel a trimmed tile's pixel lands on under its placement, independent of the packer's
* own composition so the two can disagree; one copy serves both the byte check and the preview so
* those two cannot.
*
* @param AtlasPackPlacement placement Where the tile sits on its page.
* @param Int tileX The pixel's x within the trim.
* @param Int tileY The pixel's y within the trim.
* @return Pair<Int, Int> The page (x, y).
*/
private fun pagePixelOf(placement: AtlasPackPlacement, tileX: Int, tileY: Int): Pair<Int, Int> =
if (placement.quarterTurns == 0) {
(placement.pageX + tileX) to (placement.pageY + tileY)
} else {
(placement.pageX + tileY) to (placement.pageY + placement.trimWidth - 1 - tileX)
}
/**
* Composites the packed layers back onto a canvas-sized image, sampling from the PAGES.
*
* The byte check proves the pages carry the right pixels; this is what a human looks at to see that
* the placements also mean the right thing. Blend modes and layer opacity are ignored - it is a
* source-over stack, not a compositor - so a document leaning on them will not match its own
* application's render, which is expected rather than a packing fault.
*
* @param SourceArt art The source document, for canvas size and layer positions.
* @param List layers The layers that were offered to the packer, parallel to [items].
* @param List items The pack items, parallel to [layers].
* @param AtlasPackResult result The packing outcome.
* @param File outputDirectory The directory to write into.
*/
private fun writePreview(
art: SourceArt,
layers: List<SourceLayer>,
items: List<AtlasPackItem>,
result: AtlasPackResult,
outputDirectory: File,
) {
if (art.widthPx.toLong() * art.heightPx.toLong() > PREVIEW_PIXEL_CAP) {
System.err.println("Note: ${art.widthPx}x${art.heightPx} canvas exceeds the preview cap; preview skipped.")
return
}
val placementByKey = result.placements.associateBy { placement -> placement.key }
val canvas = ByteArray(art.widthPx * art.heightPx * 4)
// Source-over from the bottom up: order is top-most first, so the highest order draws first.
for (layerIndex in layers.indices.sortedByDescending { layerIndex -> layers[layerIndex].order }) {
val placement = placementByKey[items[layerIndex].key] ?: continue
drawPlacementOntoCanvas(canvas, art.widthPx, art.heightPx, layers[layerIndex], placement, result)
}
val target = File(outputDirectory, "preview.png")
val bytes = PngCodec.write(RasterImage(art.widthPx, art.heightPx, canvas))
target.writeBytes(bytes)
println("Wrote ${target.path} (${art.widthPx}x${art.heightPx} recomposite from the packed pages, ${bytes.size} bytes)")
}
/**
* Draws one placed layer onto the preview canvas, reading its pixels out of the atlas page.
*
* @param ByteArray canvas The canvas buffer, RGBA8888 straight alpha.
* @param Int canvasWidth The canvas width in pixels.
* @param Int canvasHeight The canvas height in pixels.
* @param SourceLayer layer The layer being drawn, for its canvas position.
* @param AtlasPackPlacement placement Where its pixels sit on a page.
* @param AtlasPackResult result The packing outcome holding the pages.
*/
private fun drawPlacementOntoCanvas(
canvas: ByteArray,
canvasWidth: Int,
canvasHeight: Int,
layer: SourceLayer,
placement: AtlasPackPlacement,
result: AtlasPackResult,
) {
val page = result.pages[placement.pageIndex]
for (tileY in 0 until placement.trimHeight) {
val canvasY = layer.bounds.top + placement.trimTop + tileY
if (canvasY < 0 || canvasY >= canvasHeight) {
continue
}
for (tileX in 0 until placement.trimWidth) {
val canvasX = layer.bounds.left + placement.trimLeft + tileX
if (canvasX < 0 || canvasX >= canvasWidth) {
continue
}
val (pageX, pageY) = pagePixelOf(placement, tileX, tileY)
val pageOffset = (pageY * page.width + pageX) * 4
val canvasOffset = (canvasY * canvasWidth + canvasX) * 4
val sourceAlpha = (page.rgba[pageOffset + 3].toInt() and 0xFF) / 255f
if (sourceAlpha <= 0f) {
continue
}
val destinationAlpha = (canvas[canvasOffset + 3].toInt() and 0xFF) / 255f
val outAlpha = sourceAlpha + destinationAlpha * (1f - sourceAlpha)
for (channelIndex in 0 until 3) {
val sourceChannel = (page.rgba[pageOffset + channelIndex].toInt() and 0xFF) / 255f
val destinationChannel = (canvas[canvasOffset + channelIndex].toInt() and 0xFF) / 255f
val blended =
(sourceChannel * sourceAlpha + destinationChannel * destinationAlpha * (1f - sourceAlpha)) / outAlpha
canvas[canvasOffset + channelIndex] = (blended * 255f + 0.5f).toInt().coerceIn(0, 255).toByte()
}
canvas[canvasOffset + 3] = (outAlpha * 255f + 0.5f).toInt().coerceIn(0, 255).toByte()
}
}
}
@@ -0,0 +1,244 @@
package org.umamo.cli
import org.umamo.format.FormatRegistry
import org.umamo.format.art.ArtReader
import org.umamo.format.art.SourceArt
import org.umamo.format.cmo3.Cmo3
import org.umamo.format.cmo3.Cmo3Model
import org.umamo.format.cmo3.model.custom.CModelSource
import org.umamo.format.moc3.Moc3
import org.umamo.format.moc3.MocDocument
import org.umamo.format.moc3.json.Cdi3Json
import org.umamo.format.moc3.json.Model3Json
import org.umamo.format.raster.RasterCodec
import org.umamo.format.raster.rasterToSourceArt
import org.umamo.interop.cmo3.Cmo3Import
import org.umamo.interop.moc3.Moc3Sidecars
import org.umamo.interop.moc3.import.Moc3Import
import org.umamo.render.restMeshesToCanvasSpace
import org.umamo.runtime.model.PuppetModel
import java.io.File
import java.util.Locale
/*
* Input routing shared by every subcommand: read a file, detect its format through the same
* FormatRegistry the app uses, and (for moc3) discover the sibling family files through the
* model3.json manifest.
*/
/** A loaded input file, branched by detected format. */
internal sealed interface LoadedInput {
/** A CMO3 editor document. */
class Cmo3Input(val model: Cmo3Model, val bytes: ByteArray) : LoadedInput
/** A MOC3 runtime document plus whatever family files sat beside it. */
class Moc3Input(val document: MocDocument, val family: Moc3Family) : LoadedInput
/**
* Layered or flat source artwork: PSD, CLIP, KRA, or any of the flat raster formats read as a
* single-layer document. It carries no rig - there is no source-art to PuppetModel bridge yet
* (pipeline Phase E) - so only artwork-side commands accept it.
*/
class SourceArtInput(val art: SourceArt, val file: File) : LoadedInput
}
/**
* The MOC3 family files discovered around a moc: the manifest (when present), the display-info
* sidecar, the texture files the manifest references, and the pass-through sidecar texts.
*
* @property File mocFile The .moc3 file itself.
* @property Model3Json? manifest The parsed model3.json, or null when none was found.
* @property Cdi3Json? displayInfo The parsed cdi3.json, or null when absent.
* @property List textureFiles The manifest's texture files, resolved against its directory.
* @property List sidecars Physics/pose/userdata texts, carried through verbatim.
*/
internal class Moc3Family(
val mocFile: File,
val manifest: Model3Json?,
val displayInfo: Cdi3Json?,
val textureFiles: List<File>,
val sidecars: List<Moc3Sidecars.PassThroughSidecar>,
)
/**
* Reads and format-detects one input file. A .model3.json path is accepted as a moc3 input, with
* the MOC3 resolved through the manifest's own file reference.
*
* @param String path The input file path.
* @return LoadedInput The loaded, format-branched input.
*/
internal fun loadInput(path: String): LoadedInput {
val inputFile = File(path)
if (!inputFile.isFile) {
throw CliUsageException("No such file: $path")
}
if (inputFile.name.lowercase(Locale.ROOT).endsWith(".model3.json")) {
val manifest = Moc3.readModel3(inputFile.readText())
val mocFile = File(inputFile.parentFile, manifest.fileReferences.moc)
if (!mocFile.isFile) {
throw CliUsageException("Manifest references a missing MOC3: ${mocFile.path}")
}
return loadMoc3(mocFile, manifestFile = inputFile, manifest = manifest)
}
val bytes = inputFile.readBytes()
return when (val codec = FormatRegistry.detect(bytes, inputFile.name)) {
Cmo3 -> LoadedInput.Cmo3Input(Cmo3.read(bytes), bytes)
Moc3 -> loadMoc3(inputFile, manifestFile = null, manifest = null)
is ArtReader -> LoadedInput.SourceArtInput(codec.read(bytes), inputFile)
// A flat raster becomes a one-layer document, which is what makes `atlas cover.png` mean
// something rather than being rejected for lacking layers.
is RasterCodec -> LoadedInput.SourceArtInput(rasterToSourceArt(codec.read(bytes), inputFile.nameWithoutExtension), inputFile)
else -> throw CliUsageException("Unsupported input format: $path (expected cmo3, moc3, model3.json, or source artwork)")
}
}
/**
* Loads a moc3 and discovers its family. Without an explicit manifest the sibling
* `<basename>.model3.json` is tried first, then any manifest in the directory whose moc reference
* names this file.
*
* @param File mocFile The .moc3 file.
* @param File? manifestFile The manifest file, when the caller already has it.
* @param Model3Json? manifest The parsed manifest, when the caller already has it.
* @return LoadedInput The moc3 input with its family.
*/
private fun loadMoc3(mocFile: File, manifestFile: File?, manifest: Model3Json?): LoadedInput.Moc3Input {
val document = Moc3.read(mocFile.readBytes())
val resolvedManifestFile =
manifestFile
?: File(mocFile.parentFile, Moc3Sidecars.basenameFor(mocFile.name) + ".model3.json").takeIf { candidate -> candidate.isFile }
?: mocFile.parentFile
?.listFiles { _, name -> name.lowercase(Locale.ROOT).endsWith(".model3.json") }
?.firstOrNull { candidate ->
runCatching { Moc3.readModel3(candidate.readText()).fileReferences.moc == mocFile.name }.getOrDefault(false)
}
val resolvedManifest = manifest ?: resolvedManifestFile?.let { file -> Moc3.readModel3(file.readText()) }
if (resolvedManifest == null) {
return LoadedInput.Moc3Input(document, Moc3Family(mocFile, null, null, emptyList(), emptyList()))
}
val manifestDirectory = resolvedManifestFile!!.parentFile
val references = resolvedManifest.fileReferences
// Manifest reference first, then the sibling-by-basename fallback the app's document loader
// uses - a model3 without a DisplayInfo entry otherwise converts nameless, and the export then
// writes parameter ids where Cubism expects display names.
val displayInfo =
listOfNotNull(references.displayInfo, "${mocFile.nameWithoutExtension}.cdi3.json")
.distinct()
.firstNotNullOfOrNull { reference ->
File(manifestDirectory, reference)
.takeIf { file -> file.isFile }
?.let { file -> runCatching { Moc3.readCdi3(file.readText()) }.getOrNull() }
}
val textureFiles = references.textures.map { reference -> File(manifestDirectory, reference) }
val sidecars =
buildList {
fun passThrough(kind: Moc3Sidecars.SidecarKind, reference: String?) {
val file = reference?.let { relative -> File(manifestDirectory, relative) } ?: return
if (file.isFile) {
add(Moc3Sidecars.PassThroughSidecar(kind, file.name, file.readText()))
}
}
passThrough(Moc3Sidecars.SidecarKind.Physics, references.physics)
passThrough(Moc3Sidecars.SidecarKind.Pose, references.pose)
passThrough(Moc3Sidecars.SidecarKind.UserData, references.userData)
}
return LoadedInput.Moc3Input(document, Moc3Family(mocFile, resolvedManifest, displayInfo, textureFiles, sidecars))
}
/**
* Imports a loaded input to the runtime PuppetModel - the exact import path the editor uses.
*
* A MOC3-origin puppet gets restMeshesToCanvasSpace (its rest meshes arrive in parent-deformer
* space); a CMO3-origin one authors directly in canvas pixels and must NOT be rebased.
*
* @param LoadedInput loaded The loaded input.
* @return PuppetModel The imported puppet, in canvas space.
*/
internal fun importPuppet(loaded: LoadedInput): PuppetModel =
when (loaded) {
is LoadedInput.Cmo3Input -> Cmo3Import.fromModelSource(loaded.model.root as CModelSource)
is LoadedInput.Moc3Input -> restMeshesToCanvasSpace(Moc3Import.fromMocDocument(loaded.document, loaded.family.displayInfo))
is LoadedInput.SourceArtInput ->
throw CliUsageException(
"${loaded.file.name} is source artwork, which carries no rig; try `atlas` (a source-art to " +
"PuppetModel bridge is pipeline Phase E and does not exist yet)",
)
}
/**
* One command line split into positionals, boolean flags, and valued options.
*
* @property List positionals The non-flag arguments, in order.
* @property Set flags The boolean flags present, with their leading dashes.
* @property Map options The `--key=value` options, keyed with their leading dashes.
*/
internal class CliArguments(
val positionals: List<String>,
val flags: Set<String>,
val options: Map<String, String>,
) {
/**
* Reads one valued option as an integer.
*
* @param String name The option name, with its leading dashes.
* @param Int defaultValue The value to use when the option is absent.
* @return Int The parsed value.
*/
fun intOption(name: String, defaultValue: Int): Int {
val raw = options[name] ?: return defaultValue
return raw.toIntOrNull() ?: throw CliUsageException("$name expects a whole number, got '$raw'")
}
}
/**
* Splits a command line, rejecting anything the caller did not declare.
*
* Unknown flags are a usage error rather than being ignored, so a mistyped option cannot silently
* produce output the operator believes was generated some other way.
*
* @param List arguments The subcommand's raw arguments.
* @param Set knownFlags The boolean flags this subcommand accepts, with leading dashes.
* @param Set knownOptions The `--key=value` options this subcommand accepts, with leading dashes.
* @return CliArguments The split command line.
*/
internal fun parseArguments(arguments: List<String>, knownFlags: Set<String>, knownOptions: Set<String>): CliArguments {
val positionals = mutableListOf<String>()
val flags = mutableSetOf<String>()
val options = mutableMapOf<String, String>()
for (argument in arguments) {
if (!argument.startsWith("--")) {
positionals.add(argument)
continue
}
val separatorIndex = argument.indexOf('=')
if (separatorIndex < 0) {
if (argument !in knownFlags) {
throw CliUsageException("unknown flag '$argument'")
}
flags.add(argument)
continue
}
val name = argument.substring(0, separatorIndex)
if (name !in knownOptions) {
throw CliUsageException("unknown option '$name'")
}
options[name] = argument.substring(separatorIndex + 1)
}
return CliArguments(positionals, flags, options)
}
/**
* Formats a float like C's printf %.6g (what dump_model.c prints), so dump output stays diffable
* against the relive harness. Java's %g keeps trailing zeros where C strips them, hence the trim.
*
* @param Float value The value to format.
* @return String The %.6g-formatted text with C's trailing-zero trimming.
*/
internal fun formatSixSignificant(value: Float): String {
val raw = String.format(Locale.ROOT, "%.6g", value.toDouble())
val exponentIndex = raw.indexOfFirst { character -> character == 'e' || character == 'E' }
val mantissa = if (exponentIndex >= 0) raw.substring(0, exponentIndex) else raw
val exponent = if (exponentIndex >= 0) raw.substring(exponentIndex) else ""
val trimmed = if (mantissa.contains('.')) mantissa.trimEnd('0').trimEnd('.') else mantissa
return trimmed + exponent
}
@@ -0,0 +1,172 @@
package org.umamo.cli
import org.umamo.format.cmo3.Cmo3
import org.umamo.format.moc3.Moc3
import org.umamo.format.png.PngCodec
import org.umamo.interop.ExportReport
import org.umamo.interop.cmo3.Cmo3Conversion
import org.umamo.interop.cmo3.cmo3AtlasPages
import org.umamo.interop.describeExportNotice
import org.umamo.interop.moc3.Moc3Sidecars
import org.umamo.render.PuppetTextures
import org.umamo.render.UndecodablePagePolicy
import org.umamo.render.buildPuppetTextures
import org.umamo.render.canvasToParentSpaceFor
import org.umamo.render.encodeAtlasPng
import org.umamo.render.withTexturePagesFrom
import java.io.File
import java.util.Locale
import kotlin.random.Random
/*
* The convert subcommand: cmo3/moc3 resaves and cross-format conversions, replacing the old
* Cmo3ResaveDumpTest -Dcmo3.resave workflow.
*/
/**
* Runs `convert <in> <out>`, picking the direction from the input's detected format and the output
* path's extension.
*
* @param List arguments The subcommand's arguments.
* @return Int The exit code.
*/
internal fun runConvert(arguments: List<String>): Int {
if (arguments.size != 2) {
throw CliUsageException("Usage: convert <in> <out>")
}
val loaded = loadInput(arguments[0])
val outputFile = File(arguments[1])
val outputExtension = outputFile.name.substringAfterLast('.', "").lowercase(Locale.ROOT)
outputFile.parentFile?.mkdirs()
when {
loaded is LoadedInput.Cmo3Input && outputExtension == "cmo3" -> {
// An unedited graph re-emits its main.xml byte-identically; only the CAFF wrapper differs.
Cmo3.write(loaded.model, outputFile)
println("Resaved cmo3 -> ${outputFile.path} (${outputFile.length()} bytes)")
}
loaded is LoadedInput.Moc3Input && outputExtension == "moc3" -> {
outputFile.writeBytes(Moc3.write(loaded.document))
println("Rebaked moc3 -> ${outputFile.path} (${outputFile.length()} bytes)")
println("Note: a rebake is a fresh synthesis, NOT byte-identical to the source by design")
}
loaded is LoadedInput.Cmo3Input && outputExtension == "moc3" -> {
convertCmo3ToMoc3Family(loaded, outputFile)
}
loaded is LoadedInput.Moc3Input && outputExtension == "cmo3" -> {
convertMoc3ToCmo3(loaded, outputFile)
}
else -> throw CliUsageException("Unsupported conversion: ${arguments[0]} -> ${outputFile.name}")
}
return 0
}
/**
* Lowers a CMO3 document to the full MOC3 family (moc3 + model3.json + cdi3.json + atlas textures)
* next to [outputFile].
*
* The two mandatory pre-steps mirror the app's own export path: the puppet's drawables arrive on
* the -1 texture-page sentinel (CMO3 binds textures through the layered-art web, not a page index),
* so withTexturePagesFrom must land real pages before the lowering can name them.
*
* @param LoadedInput.Cmo3Input loaded The cmo3 input.
* @param File outputFile The target .moc3 path; the family lands beside it.
*/
private fun convertCmo3ToMoc3Family(loaded: LoadedInput.Cmo3Input, outputFile: File) {
val basename = Moc3Sidecars.basenameFor(outputFile.name)
val importedPuppet = importPuppet(loaded)
val modelSource = (loaded.model.root as org.umamo.format.cmo3.model.custom.CModelSource)
val pageSet = cmo3AtlasPages(modelSource) { imageResource -> loaded.model.extractLayerPng(imageResource) }
// Skip matches the editor's CMO3 loader: a page that will not decode drops rather than failing the
// whole conversion, and Skip never returns null, so the fallback is unreachable.
val textures =
buildPuppetTextures(
pageSet.pageBytes,
pageSet.atlasIndexByDrawableId,
pageSet.premultipliedAlpha,
UndecodablePagePolicy.Skip,
) ?: PuppetTextures(emptyList(), emptyMap(), pageSet.premultipliedAlpha)
val puppet = withTexturePagesFrom(importedPuppet, textures)
val pages =
textures.atlases.mapIndexed { pageIndex, atlas ->
Moc3Sidecars.AtlasPage(
fileName = String.format(Locale.ROOT, "%s.%d/texture_%02d.png", basename, atlas.width, pageIndex),
bytes = encodeAtlasPng(atlas),
)
}
val bundle =
Moc3Sidecars.bundle(
puppet = puppet,
basename = basename,
pages = pages,
canvasToParentSpace = canvasToParentSpaceFor(puppet),
)
// Overwrites without confirmation.
val outputDirectory = outputFile.parentFile ?: File(".")
for (bundleFile in bundle.files) {
val target = File(outputDirectory, bundleFile.name)
target.parentFile?.mkdirs()
target.writeBytes(bundleFile.bytes)
println("Wrote ${target.path} (${bundleFile.bytes.size} bytes)")
}
reportNotices(bundle.report)
}
/**
* Synthesizes a fresh CMO3 from a MOC3-origin document. The atlas pages come from the manifest's
* texture files; without a manifest the conversion proceeds textureless with a warning. A
* MissingSourceArt notice is always reported - the pages are atlas copies, not the original
* layered source art.
*
* @param LoadedInput.Moc3Input loaded The moc3 input with its discovered family.
* @param File outputFile The target .cmo3 path.
*/
private fun convertMoc3ToCmo3(loaded: LoadedInput.Moc3Input, outputFile: File) {
val puppet = importPuppet(loaded)
val presentTextureFiles = loaded.family.textureFiles.filter { textureFile -> textureFile.isFile }
if (loaded.family.manifest == null) {
System.err.println("Warning: no model3.json manifest found beside ${loaded.family.mocFile.name}; converting textureless")
} else if (presentTextureFiles.size < loaded.family.textureFiles.size) {
System.err.println("Warning: ${loaded.family.textureFiles.size - presentTextureFiles.size} manifest texture(s) missing on disk")
}
val pages =
presentTextureFiles.map { textureFile ->
val pngBytes = textureFile.readBytes()
val decoded = PngCodec.read(pngBytes)
Cmo3Conversion.AtlasPage(pngBytes = pngBytes, width = decoded.width, height = decoded.height)
}
val result =
Cmo3Conversion.freshCmo3(
puppet = puppet,
pages = pages,
pageIndexByDrawableId = loaded.document.artMeshes.associate { artMesh -> artMesh.id to artMesh.textureIndex },
modelName = outputFile.name.removeSuffix(".cmo3"),
nowMillis = System.currentTimeMillis(),
obfuscateKey = Random.nextInt(),
)
// Overwrites without confirmation.
Cmo3.write(result.model, outputFile)
println("Wrote ${outputFile.path} (${outputFile.length()} bytes)")
reportNotices(result.report)
}
/**
* Prints an export report's notices to stderr - advisory, never fatal. Each line is the same one the
* editor's log carries for that notice, so a report reads alike whichever tool wrote the file.
*
* @param ExportReport report The lowering's report.
*/
private fun reportNotices(report: ExportReport) {
if (report.isEmpty) {
return
}
System.err.println("Export notices (${report.notices.size}):")
for (notice in report.notices) {
System.err.println(" ${describeExportNotice(notice)}")
}
}
@@ -0,0 +1,94 @@
package org.umamo.cli
import org.umamo.interop.EntityDiff
import org.umamo.interop.GlueDiff
import org.umamo.interop.diffPuppetModels
import org.umamo.runtime.model.DeformerId
import org.umamo.runtime.model.DrawableId
import org.umamo.runtime.model.ParameterGroupId
import org.umamo.runtime.model.ParameterId
import org.umamo.runtime.model.PartId
/*
* The diff subcommand: the semantic per-entity difference between two models, through the same
* diffPuppetModels the CMO3 export reconcile dispatches on.
*/
/**
* Runs `diff <a> <b>`: imports both files (either format, both normalized to canvas space by the
* import path) and prints the per-category difference. Exit stays 0 either way - a diff is a
* report, not a failure.
*
* @param List arguments The subcommand's arguments.
* @return Int The exit code.
*/
internal fun runDiff(arguments: List<String>): Int {
if (arguments.size != 2) {
throw CliUsageException("Usage: diff <a> <b>")
}
val baseline = importPuppet(loadInput(arguments[0]))
val edited = importPuppet(loadInput(arguments[1]))
val diff = diffPuppetModels(baseline, edited)
if (diff.isEmpty) {
println("identical")
return 0
}
printCategory("parameters", diff.parameters)
printCategory("parameterGroups", diff.parameterGroups)
printCategory("parts", diff.parts)
printCategory("deformers", diff.deformers)
printCategory("drawables", diff.drawables)
if (diff.glues.isNotEmpty()) {
println("[glues]")
for (glueDiff in diff.glues) {
val key = "${glueDiff.meshA.raw}~${glueDiff.meshB.raw}#${glueDiff.ordinal}"
when (glueDiff) {
is GlueDiff.Created -> println("+ $key")
is GlueDiff.Deleted -> println("- $key")
is GlueDiff.Changed -> println("~ $key ${glueDiff.fields.sorted()}")
}
}
}
if (diff.document.isNotEmpty()) {
println("[document]")
println("~ ${diff.document.sorted()}")
}
return 0
}
/**
* Prints one entity category's diffs: `+ id` created, `- id` deleted, `~ id [FIELDS]` changed.
*
* @param String label The category heading.
* @param List diffs The category's entries (skipped entirely when empty).
*/
private fun <TId, TField : Comparable<TField>> printCategory(label: String, diffs: List<EntityDiff<TId, TField>>) {
if (diffs.isEmpty()) {
return
}
println("[$label]")
for (entityDiff in diffs) {
when (entityDiff) {
is EntityDiff.Created -> println("+ ${formatEntityId(entityDiff.id)}")
is EntityDiff.Deleted -> println("- ${formatEntityId(entityDiff.id)}")
is EntityDiff.Changed -> println("~ ${formatEntityId(entityDiff.id)} ${entityDiff.fields.sorted()}")
}
}
}
/**
* The bare id string of a typed entity id - the value-class toString ("PartId(raw=...)") is noise
* in a report meant for humans and diff scripts.
*
* @param Any? id The typed entity id.
* @return String The raw id text.
*/
private fun formatEntityId(id: Any?): String =
when (id) {
is ParameterId -> id.raw
is ParameterGroupId -> id.raw
is PartId -> id.raw
is DeformerId -> id.raw
is DrawableId -> id.raw
else -> id.toString()
}
@@ -0,0 +1,249 @@
package org.umamo.cli
import org.umamo.format.art.SourceLayerKind
import org.umamo.format.art.analyzeAlpha
import org.umamo.format.cmo3.Cmo3Model
import org.umamo.format.cmo3.caff.CaffArchive
import org.umamo.format.cmo3.serialize.ModelDocument
import org.umamo.format.moc3.MocDocument
import org.umamo.format.moc3.moc.MocCodec
import org.umamo.format.moc3.moc.Section
import org.umamo.runtime.model.PuppetModel
/*
* The dump subcommand: human-readable (and, for MOC3, dump_model.c-diffable) file contents.
*/
/**
* Runs `dump <file> [--sections] [--xml] [--puppet]`.
*
* @param List arguments The subcommand's arguments.
* @return Int The exit code.
*/
internal fun runDump(arguments: List<String>): Int {
val flags = arguments.filter { argument -> argument.startsWith("--") }.toSet()
val positionals = arguments.filterNot { argument -> argument.startsWith("--") }
val unknownFlags = flags - setOf("--sections", "--xml", "--puppet")
if (unknownFlags.isNotEmpty()) {
throw CliUsageException("unknown dump flag(s): ${unknownFlags.joinToString(", ")}")
}
if (positionals.size != 1) {
throw CliUsageException("usage: dump <file> [--sections] [--xml] [--puppet]")
}
val loaded = loadInput(positionals[0])
when (loaded) {
is LoadedInput.Moc3Input -> {
if ("--xml" in flags) {
throw CliUsageException("--xml applies to cmo3 input only")
}
if ("--sections" in flags) {
dumpMoc3Sections(loaded)
} else {
dumpMoc3Document(loaded.document)
}
}
is LoadedInput.Cmo3Input -> {
if ("--sections" in flags) {
throw CliUsageException("--sections applies to moc3 input only")
}
if ("--xml" in flags) {
dumpCmo3Xml(loaded.model)
return 0
}
dumpCmo3Overview(loaded.model)
}
is LoadedInput.SourceArtInput -> {
if ("--sections" in flags || "--xml" in flags) {
throw CliUsageException("--sections and --xml do not apply to source artwork")
}
dumpSourceArt(loaded)
}
}
if ("--puppet" in flags) {
dumpPuppetSummary(importPuppet(loaded))
}
return 0
}
/**
* The MOC3 semantic summary, mirroring dump_model.c's static line grammar (`P`/`T`/`D` records) so
* the relive harness's diff scripts can consume it. Runtime-evaluated columns (posed draw/render
* order, evaluated opacities, vertex-position hashes) are deliberately absent - this dumps the
* static rig, not a revived core.
*
* @param MocDocument document The decoded moc.
*/
private fun dumpMoc3Document(document: MocDocument) {
println("# MOC3 version=${document.version.byteValue}")
document.canvas?.let { canvas ->
val size = "${formatSixSignificant(canvas.width)},${formatSixSignificant(canvas.height)}"
val origin = "${formatSixSignificant(canvas.originX)},${formatSixSignificant(canvas.originY)}"
println("# canvas size=$size origin=$origin ppu=${formatSixSignificant(canvas.pixelsPerUnit)}")
}
println(
"# counts parameters=${document.parameters.size} parts=${document.parts.size} " +
"drawables=${document.artMeshes.size} deformers=${document.deformers.size} " +
"glues=${document.glues.size} groups=${document.renderOrderGroups.size} " +
"bindings=${document.bindings.size} blendShapes=${document.blendShapes.size} " +
"offscreens=${document.offscreens.size}",
)
println("[parameters]")
document.parameters.forEachIndexed { parameterIndex, parameter ->
println(
"P $parameterIndex id=${parameter.id} type=${parameter.type?.number ?: -1} " +
"min=${formatSixSignificant(parameter.minimumValue)} max=${formatSixSignificant(parameter.maximumValue)} " +
"def=${formatSixSignificant(parameter.defaultValue)} repeat=${if (parameter.repeats) 1 else 0}",
)
}
println("[parts]")
document.parts.forEachIndexed { partIndex, part ->
println("T $partIndex id=${part.id} parent=${part.parentPartIndex}")
}
println("[drawables]")
document.artMeshes.forEachIndexed { meshIndex, artMesh ->
println(
"D $meshIndex id=${artMesh.id} cflag=0x${(artMesh.constantFlags and 0xFF).toString(16).padStart(2, '0')} " +
"tex=${artMesh.textureIndex} part=${artMesh.parentPartIndex} vtx=${artMesh.vertexCount} " +
"idx=${artMesh.triangleIndices.size} masks=${artMesh.maskDrawableIndices.size}",
)
}
}
/**
* The MOC3 container tier: version, CountInfo, and per-section presence with element counts.
*
* @param LoadedInput.Moc3Input loaded The moc3 input (re-read at the container tier).
*/
private fun dumpMoc3Sections(loaded: LoadedInput.Moc3Input) {
val container = MocCodec.read(loaded.family.mocFile.readBytes())
println("# MOC3 version=${container.versionByte} sections=${container.sectionCount} bigEndian=${container.isBigEndian}")
println("# countInfo ${container.countInfo.joinToString(",")}")
var presentCount = 0
for (section in Section.entries) {
if (!container.sections.isPresent(section)) {
continue
}
presentCount++
println("S ${section.name} count=${container.sections.elementCount(section)}")
}
println("# sections present=$presentCount modeled=${Section.entries.size}")
}
/**
* The CMO3 overview: target version, the CAFF entry table, the embedded image resources, and the
* parsed main.xml prologue summary.
*
* @param Cmo3Model model The read model.
*/
private fun dumpCmo3Overview(model: Cmo3Model) {
val archive = model.archive
println("# CMO3 targetVersionNo=${model.targetVersionNo ?: "-"}")
println(
"# caff formatVersion=${archive.formatVersion.joinToString(".")} " +
"archiveVersion=${archive.archiveVersion.joinToString(".")} " +
"obfuscateKey=${archive.obfuscateKey}",
)
println("[entries]")
archive.entries.forEachIndexed { entryIndex, entry ->
println(
"E $entryIndex path=${entry.path} tag=${entry.tag} size=${entry.content.size} " +
"compression=${entry.compression} obfuscated=${if (entry.obfuscated) 1 else 0}",
)
}
println("[images]")
model.imageResources().forEachIndexed { imageIndex, resource ->
val pngSize = model.extractLayerPng(resource)?.size ?: 0
println("I $imageIndex type=${resource.type} width=${resource.width} height=${resource.height} pngBytes=$pngSize")
}
val mainXml = archive.firstByTag(CaffArchive.TAG_MAIN_XML)
if (mainXml != null) {
// sharedElements/mainElements are JDOM-typed and JDOM stays :format-internal; the class-version
// table and import list are the useful prologue summary anyway.
val parsed = ModelDocument.parse(mainXml.content)
println("[xml]")
println("# versions ${parsed.versions.entries.joinToString(" ") { (className, versionNumber) -> "$className=$versionNumber" }}")
println("# imports ${parsed.imports.joinToString(" ")}")
}
}
/**
* Writes the decompressed main.xml to stdout byte-for-byte, so a shell redirect round-trips it.
* CaffEntry.content is already inflated and deobfuscated by the CAFF read.
*
* @param Cmo3Model model The read model.
*/
private fun dumpCmo3Xml(model: Cmo3Model) {
val mainXml =
model.archive.firstByTag(CaffArchive.TAG_MAIN_XML)
?: throw IllegalStateException("archive has no main_xml entry")
System.out.write(mainXml.content)
System.out.flush()
}
/**
* The imported-puppet summary: entity counts and the parameter table - the exact import path the
* convert command lowers from, so a suspect conversion can be inspected at this tier first.
*
* @param PuppetModel puppet The imported puppet.
*/
private fun dumpPuppetSummary(puppet: PuppetModel) {
println("[puppet]")
println(
"# counts parameters=${puppet.parameters.size} parts=${puppet.parts.size} " +
"deformers=${puppet.deformers.size} drawables=${puppet.drawables.size} glues=${puppet.glues.size}",
)
println(
"# canvas ${formatSixSignificant(puppet.canvasWidth)}x${formatSixSignificant(puppet.canvasHeight)} " +
"origin=${formatSixSignificant(puppet.worldOriginX)},${formatSixSignificant(puppet.worldOriginZ)} " +
"target=${puppet.runtimeTarget.name}",
)
puppet.parameters.forEachIndexed { parameterIndex, parameter ->
println(
"P $parameterIndex id=${parameter.id.raw} min=${formatSixSignificant(parameter.min)} " +
"max=${formatSixSignificant(parameter.max)} def=${formatSixSignificant(parameter.default)}",
)
}
}
/**
* The source-artwork summary: canvas, folder attributes, and one line per layer.
*
* The layer inventory a PSD/CLIP/KRA reader produces has had no way to be seen until now, which is
* the same gap the atlas command closes on the packing side - this is what you read to judge whether
* a pack skipped the layers it should have. The alpha column is the packer's own view: the trimmed
* opaque bounds, or `empty` for a layer with no opaque pixel (which never reaches a page).
*
* @param LoadedInput.SourceArtInput loaded The loaded artwork document.
*/
private fun dumpSourceArt(loaded: LoadedInput.SourceArtInput) {
val art = loaded.art
val rasterLayerCount = art.layers.count { layer -> layer.kind == SourceLayerKind.Raster }
println("[artwork] ${loaded.file.name}")
println("# canvas ${art.widthPx}x${art.heightPx}")
println("# counts layers=${art.layers.size} raster=$rasterLayerCount groups=${art.groups.size}")
art.groups.forEach { group ->
println(
"G path=${group.path} name=${group.name} vis=${if (group.visible) 1 else 0} " +
"op=${formatSixSignificant(group.opacity)} blend=${group.blend} " +
"clip=${if (group.clipped) 1 else 0} through=${if (group.passThrough) 1 else 0}",
)
}
art.layers.forEachIndexed { layerIndex, layer ->
val trimmed = layer.analyzeAlpha(contourEpsilon = 0f)
val alphaColumn =
if (trimmed == null) {
"empty"
} else {
"${trimmed.opaqueBounds.width}x${trimmed.opaqueBounds.height}" +
"+${trimmed.opaqueBounds.left}+${trimmed.opaqueBounds.top}"
}
println(
"L $layerIndex order=${layer.order} kind=${layer.kind} id=${layer.id.raw} name=${layer.name} " +
"at=${layer.bounds.left},${layer.bounds.top} size=${layer.bounds.width}x${layer.bounds.height} " +
"alpha=$alphaColumn op=${formatSixSignificant(layer.opacity)} blend=${layer.blend} " +
"vis=${if (layer.visible) 1 else 0} clip=${if (layer.clipped) 1 else 0} group=${layer.groupPath}",
)
}
}
@@ -0,0 +1,69 @@
package org.umamo.cli
import java.io.File
import java.util.Locale
/*
* The extract subcommand: unpack a cmo3's CAFF archive into loose files - the plaintext main.xml
* plus every embedded layer PNG.
*/
/**
* Runs `extract <file> [<directory>]`.
*
* The entries land in a NEW subdirectory named after the model, created under the given directory
* (default: the input file's own directory) - `extract Model.cmo3 test/work/` writes into
* `test/work/Model/`. The subdirectory is deliberate accident insurance: extraction never mixes
* its output into a folder that already holds other files.
*
* @param List arguments The subcommand's arguments.
* @return Int The exit code.
*/
internal fun runExtract(arguments: List<String>): Int {
val positionals = arguments.filterNot { argument -> argument.startsWith("--") }
if (arguments.size != positionals.size || positionals.isEmpty() || positionals.size > 2) {
throw CliUsageException("Usage: extract <file> [<directory>]")
}
val loaded = loadInput(positionals[0])
if (loaded !is LoadedInput.Cmo3Input) {
throw CliUsageException("Extract applies to cmo3 input only")
}
val inputFile = File(positionals[0])
val modelName =
inputFile.name.let { fileName ->
if (fileName.lowercase(Locale.ROOT).endsWith(".cmo3")) fileName.dropLast(".cmo3".length) else fileName
}
val parentDirectory = if (positionals.size == 2) File(positionals[1]) else (inputFile.parentFile ?: File("."))
val extractionDirectory = File(parentDirectory, modelName)
if (extractionDirectory.exists()) {
System.err.println("Note: ${extractionDirectory.path} already exists; its matching files will be overwritten.")
}
extractionDirectory.mkdirs()
val archive = loaded.model.archive
val writtenNames = HashSet<String>()
archive.entries.forEachIndexed { entryIndex, entry ->
// Entry paths are archive data: guard against traversal and collisions rather than trusting them.
val safeName = entry.path.ifBlank { "entry_$entryIndex" }
val uniqueName = if (writtenNames.add(safeName)) safeName else "entry_${entryIndex}_$safeName"
val target = File(extractionDirectory, uniqueName)
if (!target.canonicalFile.toPath().startsWith(extractionDirectory.canonicalFile.toPath())) {
throw IllegalStateException("Archive entry escapes the extraction directory: ${entry.path}")
}
target.parentFile?.mkdirs()
// CaffEntry.content is already inflated and deobfuscated, so main.xml lands as plaintext.
target.writeBytes(entry.content)
println("Extracted ${target.path} (${entry.content.size} bytes)")
}
if (archive.preview.present) {
val previewTarget = File(extractionDirectory, "preview.png")
if (writtenNames.contains("preview.png")) {
System.err.println("Note: An archive entry already claimed preview.png; the CAFF preview image was skipped.")
} else {
previewTarget.writeBytes(archive.preview.png!!)
println("Extracted ${previewTarget.path} (${archive.preview.png!!.size} bytes, CAFF preview)")
}
}
println("Extracted ${archive.entries.size} entries into ${extractionDirectory.path}")
return 0
}
@@ -0,0 +1,113 @@
package org.umamo.cli
import kotlin.system.exitProcess
/*
* The Umamo diagnostic CLI: dump / extract / atlas / convert / diff over cmo3, moc3, and source
* artwork files.
*
* Replaces the diagnostic-tests-in-disguise workflow (Cmo3ResaveDumpTest's -Dcmo3.resave, ad-hoc
* probe printlns) with a proper operator tool. Data goes to stdout, diagnostics to stderr; exit 0
* on success, 1 on a command failure, 2 on a usage error.
*/
private const val USAGE = """Umamo diagnostic CLI
Usage (via Gradle; -q suppresses Gradle's own build output, leaving only this tool's):
./gradlew -q :cli:run --args="dump <file> [--sections] [--xml] [--puppet]"
./gradlew -q :cli:run --args="extract <file> [<directory>]"
./gradlew -q :cli:run --args="atlas <file> [<directory>] [options]"
./gradlew -q :cli:run --args="convert <in> <out>"
./gradlew -q :cli:run --args="diff <a> <b>"
Commands:
dump <file> Print a cmo3/moc3/artwork file's contents. MOC3 defaults to printing
a static rig summary. CMO3 defaults to the archive entry table plus
the parsed main.xml overview. Source artwork(PSD, CLIP, KRA, or a
flat raster) prints its canvas, folders, and per-layer inventory with
each layer's trimmed opaque bounds.
--sections MOC3 container tier: per-section presence and counts.
--xml CMO3 only: the decompressed main.xml, byte-for-byte.
--puppet Either format: import to a PuppetModel and summarize.
extract <file> [<directory>]
Unpack a cmo3's archive into loose files: The plaintext main.xml plus
every embedded layer PNG. Files write to a NEW subdirectory named
after the model, created under <directory> (Default: The file's own
directory) - `extract Model.cmo3 test/work/` writes test/work/Model/.
atlas <file> [<directory>]
Pack a source artwork document(PSD, CLIP, KRA, or a flat raster) into
texture atlas pages. Writes page_NN.png plus placements.txt to a NEW
subdirectory named after the input, then reads every packed tile back
out of its page and fails if any byte differs. Layers with no opaque
pixels, or too large for a page, are reported rather than dropped.
--page-size=N Page side to pack against (Default: 4096).
--gutter=N Transparent spacing around every tile (Default: 2).
--extrude=N Edge pixels replicated into the gutter (Default: 2).
--rotate Allow quarter-turning tiles to pack tighter.
--visible-only Skip layers hidden by their own or a folder's eye.
--no-shrink Keep full --page-size pages instead of cropping.
--preview Also write preview.png: the canvas recomposited
from the packed pages (Source-over; blend modes
and layer opacity ignored).
convert <in> <out>
Direction by input format and output extension:
cmo3 -> cmo3 Resave (An unedited main.xml will reemit byte-identical.)
moc3 -> moc3 Rebake (Fresh synthesis, NOT byte-identical by design.)
cmo3 -> moc3 Full family: moc3 + model3.json + cdi3.json + textures
moc3 -> cmo3 Fresh-graph synthesis (Cubism can open it; the source
art pages are atlas copies, so a MissingSourceArt
notice is always reported.)
A moc3 input may also be given as its .model3.json manifest; sibling
sidecars (model3/cdi3/physics3/pose3/userdata3) are discovered by
the manifest's own file references.
diff <a> <b> Import both files (either format) and print the semantic per-entity
difference.
help This text."""
/**
* The CLI entry point: dispatches to a subcommand and converts its outcome to an exit code.
*
* @param Array args The raw command-line arguments (Gradle's --args, split).
*/
fun main(args: Array<String>) {
val exitCode = runCli(args.toList())
if (exitCode != 0) {
exitProcess(exitCode)
}
}
/**
* Runs one CLI invocation. Split from main so the dispatch stays testable without exiting the JVM.
*
* @param List arguments The command line: a verb followed by its positionals and flags.
* @return Int The process exit code (0 success, 1 failure, 2 usage error).
*/
internal fun runCli(arguments: List<String>): Int {
if (arguments.isEmpty() || arguments[0] == "help" || arguments[0] == "--help") {
println(USAGE)
return if (arguments.isEmpty()) 2 else 0
}
return try {
when (arguments[0]) {
"dump" -> runDump(arguments.drop(1))
"extract" -> runExtract(arguments.drop(1))
"atlas" -> runAtlas(arguments.drop(1))
"convert" -> runConvert(arguments.drop(1))
"diff" -> runDiff(arguments.drop(1))
else -> {
System.err.println("unknown command '${arguments[0]}'")
System.err.println(USAGE)
2
}
}
} catch (usageError: CliUsageException) {
System.err.println(usageError.message)
2
} catch (failure: Exception) {
System.err.println("error: ${failure.message ?: failure::class.simpleName}")
1
}
}
/** A malformed invocation - reported as usage (exit 2) rather than a command failure (exit 1). */
internal class CliUsageException(message: String) : Exception(message)
+223
View File
@@ -0,0 +1,223 @@
// :desktop (app/desktop) — desktop entrypoint (Compose Desktop + LWJGL viewport interop).
// :desktop — デスクトップ起動点(Compose Desktop + LWJGL ビューポート連携)。
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
}
// EN: Resolve which platform's natives this build bundles (default: the host; override with
// -Pumamo.target=<os>-<arch>, e.g. windows-x64 to cross-build from WSL2 Linux). The shared script
// also drives :render so both modules agree; it exposes its result via extra properties. See
// gradle/build-target.gradle.kts for the full rationale and the cross-build recipe.
// JA: 同梱するネイティブの対象プラットフォームを解決する(既定はホスト、-Pumamo.target で上書き)。
apply(from = rootProject.file("gradle/build-target.gradle.kts"))
val buildTarget = extra["umamoBuildTarget"] as String
val lwjglNatives = extra["umamoLwjglNatives"] as String
// Resolve the application version from ProjectInfo.kt (see gradle/project-version.gradle.kts) so
// the packaged artifacts never drift from what the About dialog shows.
apply(from = rootProject.file("gradle/project-version.gradle.kts"))
val umamoVersion = extra["umamoVersion"] as String
val umamoVersionNumeric = extra["umamoVersionNumeric"] as String
// The .uma document type every OS registration names. OsAssociationFilesTest holds this script, the Android
// manifest, and the freedesktop files to the codec's own Uma.MIME_TYPE, so the four cannot drift apart.
val umaMimeType = "application/vnd.umamo.uma+zip"
val umaExtension = "uma"
val umaDescription = "Umamo Document"
kotlin {
jvmToolchain(21)
jvm()
sourceSets {
jvmMain {
dependencies {
// EN: Compose Desktop's per-target artifact bundles the matching Skiko native (a
// .so/.dll/.dylib). buildTarget is exactly the artifact's "<os>-<arch>" suffix, so
// `desktop-jvm-$buildTarget` selects the right one — on the host this is what
// `compose.desktop.currentOs` resolves to, so the default path is unchanged. Direct
// coordinate (not the `compose.desktop.<target>` accessor) because those accessors are
// deprecated in CMP 1.11 — same migration the version catalog already made for the
// other compose.* artifacts (see libs.versions.toml).
// JA: 対象プラットフォームの Skiko ネイティブを含む Compose Desktop 依存を直接座標で選ぶ。
implementation("org.jetbrains.compose.desktop:desktop-jvm-$buildTarget:${libs.versions.composeMultiplatform.get()}")
// Compose resources: the desktop menu bar localizes against :ui's EN/JA catalogs via
// stringResource(Res.string.*); :ui exposes it as implementation, so declare it here too.
implementation(libs.compose.components.resources)
implementation(project(":ui"))
implementation(project(":runtime"))
// Editing core: the per-document EditorSession the desktop host creates and the
// Selection / EditorMode model the viewport pick reads (used directly in jvmMain).
implementation(project(":edit"))
implementation(project(":render"))
implementation(project(":settings"))
implementation(project(":storage"))
// Explicit (also transitive via :runtime) — Document loading calls FormatRegistry/Cmo3 directly.
implementation(project(":format"))
// JNA: a tiny Win32 FFI for desktop window chrome (the DWM title-bar caption tint).
// Already on the runtime classpath via FileKit; declared here so jvmMain compiles
// against com.sun.jna.* directly. No-op off Windows — the call is OS-guarded.
implementation(libs.jna)
// LWJGL GL for the offscreen viewport renderer; BOM keeps module versions aligned.
implementation(project.dependencies.platform(libs.lwjgl.bom))
implementation(libs.lwjgl.core)
implementation(libs.lwjgl.opengl)
// GLFW: a hidden-window GL context for the OFFSCREEN viewport renderer. The puppet is
// rendered to an FBO and shown as a lightweight Compose Image (not a heavyweight AWT
// canvas), so Compose menus/overlays/gizmos layer over it correctly on every platform.
implementation(libs.lwjgl.glfw)
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
}
}
jvmTest {
dependencies {
implementation(kotlin("test"))
}
}
}
}
// Compose Desktop's packaging/run DSL. `:desktop:run` launches the editor.
compose.desktop {
application {
mainClass = "org.umamo.editor.desktop.MainKt"
// Everything in this jvmArgs list is baked into the PACKAGED launcher too — the plugin
// hands application.jvmArgs straight to jpackage as --java-options, which end up in
// umamo.cfg. So only put things here that are true for a shipped build. The corpus-preview
// override, a developer affordance pointing at a gitignored absolute host path, is set on
// `:desktop:run` alone at the bottom of this file.
//
// Decoding the 8192² atlas to RGBA is transiently heavy (~0.5 GB); give the preview headroom.
jvmArgs.add("-Xmx16g")
nativeDistributions {
// packageName feeds the uber-jar base name (and any future jpackage installers);
// lowercase matches the project/domain and Linux package conventions.
packageName = "umamo"
// jpackage rejects prerelease suffixes, so installers get the numeric form; the uber jar
// keeps the full ProjectInfo string (below).
packageVersion = umamoVersionNumeric
// Identity metadata. jpackage stamps vendor/description/copyright into the Windows exe
// version resource and the macOS Info.plist, and copies licenseFile into the app image
// — so even an unsigned build says who made it and under what terms.
vendor = "Umamo Project"
description = "Cross-platform 2D puppet modelling editor with Live2D Cubism .cmo3 interop."
copyright = "Copyright (C) Umamo Project contributors. Licensed under the GPL-3.0."
licenseFile.set(rootProject.file("LICENSE"))
// The jlink module set for the bundled runtime. Compose's default is
// [java.base, java.desktop, java.logging, jdk.crypto.ec] and modules(...) APPENDS to
// it rather than replacing it, so these are purely additive. Each is load-bearing,
// and each was traced to the jar that needs it with `jdeps --list-deps`:
// java.instrument — kotlinx-coroutines' AgentPremain debug-probe transformer.
// java.sql — SQLDelight's JdbcSqliteDriver / sqlite-jdbc (CLIP ingest).
// java.xml — JDOM's SAX/JAXP path, i.e. all of CMO3 read/write. Already
// implied (java.desktop requires it transitively), but CMO3 is
// the product; it should not ride on someone else's implication.
// jdk.security.auth — dbus-java, under FileKit's XDG-portal open/save dialogs.
// jdk.unsupported — sun.misc.Unsafe, which LWJGL's MemoryBackendUnsafe* needs.
// Deliberately NOT includeAllModules: that adds ~50 MB per platform to paper over a
// class of bug the release workflow already catches by asserting on the MODULES= line
// of jlink's `release` descriptor. Re-run `:desktop:suggestRuntimeModules` after any
// dependency change and add whatever it names — but note it under-reports, since it
// misses reflective and service-loaded edges (it does not name java.xml).
modules("java.instrument", "java.sql", "java.xml", "jdk.security.auth", "jdk.unsupported")
// App icon per OS. jpackage demands a different container per platform and reads only
// its own host's file, so all three are committed and each is consumed when packaging on
// that OS. These feed createDistributable / the native installers (not the uber jar,
// which carries no icon). Regenerate from the mascot with docs/design/appicon/generate.sh.
//
// The .uma document type (docs/format/UMA.md § 2), declared per OS because that is where the plugin
// puts it. What it does depends on what is being built:
// * macOS: the plugin writes CFBundleDocumentTypes into the app image's own Info.plist, so an
// unpacked Umamo.app is already the handler for .uma - no installer needed.
// * Windows and Linux: the plugin hands it to jpackage as --file-associations, which jpackage
// accepts for INSTALLERS only. It is inert for createDistributable, the only thing a release
// ships today, and takes effect the day an msi / deb is built. Until then Linux registers the
// type per user from the two files under resources/linux (see appResourcesRootDir below).
// The document reuses the application icon until it has one of its own.
windows {
iconFile.set(project.file("icons/umamo.ico"))
fileAssociation(umaMimeType, umaExtension, umaDescription, project.file("icons/umamo.ico"))
}
macOS {
iconFile.set(project.file("icons/umamo.icns"))
fileAssociation(umaMimeType, umaExtension, umaDescription, project.file("icons/umamo.icns"))
// CFBundleIdentifier. Matches :android's applicationId so one reverse-DNS identity
// covers the project on both platforms. Not required for an unsigned app image (the
// plugin only validates it when signing), but jpackage would otherwise derive one
// from the main-class package — and macOS keys preferences and TCC permission grants
// on this string, so changing it later orphans every user's saved state.
bundleID = "org.umamo.editor"
}
linux {
iconFile.set(project.file("icons/umamo.png"))
fileAssociation(umaMimeType, umaExtension, umaDescription, project.file("icons/umamo.png"))
}
// Files copied into the app image beside the jars (lib/app/resources on Linux). resources/linux
// holds the freedesktop shared-mime-info entry and the desktop entry a rigger installs per user to
// make the file manager open .uma with an unpacked Umamo.
appResourcesRootDir.set(project.layout.projectDirectory.dir("resources"))
}
}
}
// OsAssociationFilesTest reads the OS registration files straight from disk - this script, the Android manifest,
// and the two freedesktop files - and holds them to the codec's Uma.MIME_TYPE. None of them is on the test
// classpath, so Gradle does not know the test depends on them: left undeclared, an edit to any one leaves
// jvmTest UP-TO-DATE and the check silently never runs against the change it exists to catch.
val osAssociationFiles =
files(
"resources/linux/umamo-uma.xml",
"resources/linux/umamo.desktop",
"build.gradle.kts",
rootProject.file("app/android/src/main/AndroidManifest.xml"),
)
tasks.withType<Test>().configureEach {
inputs.files(osAssociationFiles).withPropertyName("osAssociationFiles").withPathSensitivity(PathSensitivity.RELATIVE)
}
// `umamo.testCmo3` opens the corpus CMO3 (gitignored; the puppet preview) on launch. It is a
// DEVELOPER affordance carrying an absolute host path, so it must never reach a packaged
// artifact where that path does not exist — hence the run task rather than
// application.jvmArgs, which the plugin forwards to jpackage as --java-options.
//
// Two deliberate choices:
// * withType/matching/configureEach, not tasks.named("run"): the Compose plugin registers its
// tasks inside its own afterEvaluate, so `run` does not exist while this script is being
// evaluated and named() would throw. Same lazy idiom as the uber-jar override below.
// * systemProperty(), not jvmArgs(): the plugin's own configuration action calls
// JavaExec.setJvmArgs() — a REPLACE, not an append. Gradle happens to run that action before
// this one so an appended jvmArg would survive today, but systemProperties is a separate
// collection setJvmArgs never touches, so this holds regardless of action ordering.
// The path is resolved to a val first so the lambda captures a String, not the Project
// (configuration cache).
val runPreviewCmo3Path = rootProject.file("test/corpus/cmo3/EricaTamamo.cmo3").absolutePath
tasks.withType<JavaExec>().matching { execTask -> execTask.name == "run" }
.configureEach {
systemProperty("umamo.testCmo3", runPreviewCmo3Path)
}
// The Compose plugin stamps the uber jar with the HOST os token (its own currentTarget
// detection), which lies when -Pumamo.target cross-resolves the bundled natives — the jar
// CONTENTS already honor buildTarget (Skiko artifact and LWJGL natives above). The plugin
// assigns the name PARTS (appendix/version) directly in its afterEvaluate, after any
// configureEach action, so part-level overrides lose; an explicit archiveFileName replaces the
// derived-from-parts convention outright and wins regardless of assignment order.
//
// Target before version — umamo-<os>-<arch>-<version>.<ext>. Keep that order: it is what the
// release assets are named and what downstream tooling matches on.
tasks.withType<org.gradle.jvm.tasks.Jar>().matching { jarTask -> jarTask.name == "packageUberJarForCurrentOS" }
.configureEach {
archiveFileName.set("umamo-$buildTarget-$umamoVersion.jar")
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Umamo's document type for the freedesktop shared MIME database.
The magic is the identification probe of docs/format/UMA.md § 2, verbatim: a ZIP whose FIRST entry is a stored
"mimetype" with no extra field, so its content sits at a fixed offset. Nested the way the shared database
declares EPUB and OpenDocument, at their priority. That is above application/zip's own magic (the bare
local-header signature), so a .uma with no extension still reads as a UMA. It is deliberately below 80, the
level at which magic would outrank a file's name: a .uma someone renamed to .zip reads as a ZIP, as a renamed
OpenDocument file does - they asked for the archive.
The README's "Opening .uma files from the file manager" gives the per-user install for an unpacked Umamo.
-->
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/vnd.umamo.uma+zip">
<comment>Umamo Document</comment>
<comment xml:lang="ja">Umamo ドキュメント</comment>
<sub-class-of type="application/zip"/>
<generic-icon name="x-office-drawing"/>
<magic priority="70">
<match type="string" offset="0" value="PK\003\004">
<match type="string" offset="30" value="mimetype">
<match type="string" offset="38" value="application/vnd.umamo.uma+zip"/>
</match>
</match>
</magic>
<glob pattern="*.uma"/>
</mime-type>
</mime-info>
+16
View File
@@ -0,0 +1,16 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=Umamo
GenericName=2D Puppet Modelling Editor
GenericName[ja]=2Dパペット モデリングエディター
Comment=Model 2D puppets in the Live2D Ecosystem
Comment[ja]=Live2Dエコシステムにおける2Dパペットのモデリング
# The launcher is named by PATH: an unpacked archive has no fixed location. Put bin/umamo on the PATH, or
# replace this with its absolute path, then: xdg-desktop-menu install --novendor umamo.desktop
Exec=umamo %f
TryExec=umamo
Icon=umamo
Terminal=false
Categories=Graphics;2DGraphics;
MimeType=application/vnd.umamo.uma+zip;
@@ -0,0 +1,274 @@
package org.umamo.editor.desktop
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import io.github.vinceglb.filekit.FileKit
import kotlinx.coroutines.runBlocking
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.umamo.editor.desktop.viewport.OffscreenPuppetService
import org.umamo.format.FileRole
import org.umamo.format.FormatRegistry
import org.umamo.runtime.model.ParameterId
import org.umamo.storage.UmamoLog
import org.umamo.storage.desktopAppStorage
import org.umamo.storage.platformFileFromSavedPath
import org.umamo.ui.LocalSettings
import org.umamo.ui.app.EditorApp
import org.umamo.ui.app.HostOpenRequests
import org.umamo.ui.app.rememberDocumentFileFor
import org.umamo.ui.app.rememberEditorSessionFor
import org.umamo.ui.app.rememberExitGuard
import org.umamo.ui.document.Document
import org.umamo.ui.document.DocumentLoad
import org.umamo.ui.document.PuppetDocument
import org.umamo.ui.document.addRecentFile
import org.umamo.ui.document.fileDisplayName
import org.umamo.ui.document.loadDocument
import org.umamo.ui.document.newBlankDocument
import org.umamo.ui.l10n.FALLBACK_LOCALE_TAG
import org.umamo.ui.l10n.LOCALE_SETTINGS_KEY
import org.umamo.ui.l10n.applyAppLocale
import org.umamo.ui.loadAppSettings
import org.umamo.ui.resources.Res
import org.umamo.ui.resources.app_icon
import org.umamo.ui.resources.app_name
import org.umamo.ui.resources.title_read_only
import org.umamo.ui.resources.title_untitled_document
import org.umamo.ui.theme.ProvideAppThemeFromSettings
import org.umamo.ui.theme.UmamoTheme
import org.umamo.ui.viewport.LiveParams
import java.awt.Desktop
import java.util.concurrent.atomic.AtomicReference
/**
* Applies the `UMAMO_DUMP_PARAMS` environment override (e.g. `ParamAngleX=30,ParamAngleY=-10`) to the
* given live params, so a deformed pose can be dumped headless. A desktop dev affordance - the shared
* initialLiveParams stays environment-free.
*
* @param LiveParams liveParams The initial document's parameter hand-off to rewrite.
*/
private fun applyDumpParamOverrides(liveParams: LiveParams) {
val spec = System.getenv("UMAMO_DUMP_PARAMS") ?: return
val values = liveParams.values.toMutableMap()
spec.split(",").forEach { pair ->
val parts = pair.split("=")
val value = parts.getOrNull(1)?.trim()?.toFloatOrNull()
if (parts.size == 2 && value != null) {
values[ParameterId(parts[0].trim())] = value
}
}
liveParams.values = values.toMap()
}
/**
* Loads the initial document from a `.cmo3`/`.moc3` path and applies the dump-param overrides.
*
* A function rather than inline code in [main] on purpose: main's frame lives for the whole run
* (application {} blocks), and an interpreted frame keeps every local reachable - a document held
* in one would stay pinned, retained CMO3 graph and decoded atlas included, long after another
* file replaces it. Loading in a popped frame leaves the holder in [main] as the only reference.
*
* @param String? initialPath The argv / -Dumamo.testCmo3 path, or null for none.
* @return Document? The loaded document, or null when there is no path or the load fails.
*/
private fun loadInitialDocument(initialPath: String?): Document? {
val path = initialPath ?: return null
// A failed initial load falls back to an empty shell (the failure is in the log); the in-app
// alert only covers interactive opens, since the shell is not up yet to show it here.
val document = (runBlocking { loadDocument(platformFileFromSavedPath(path)) } as? DocumentLoad.Loaded)?.document
// The dump-params override applies only to the initially-opened document - it exists for the
// headless first-frame dump, which always opens via argv / -Dumamo.testCmo3. PuppetDocument
// covers both CMO3 and MOC3 documents, so a .moc3 argv dump poses correctly too.
(document as? PuppetDocument)?.let { applyDumpParamOverrides(it.liveParams) }
return document
}
/**
* The window title: the app name, the open document's name, the unsaved marker, and the read-only marker.
*
* The name follows the `.uma` the document saves to once it has one, so a `Erica.cmo3` saved as `Erica.uma`
* reads as the latter. A document with no file is named here rather than by [Document.displayName], which
* is the plain-text name the log and an export's suggested file name need; the title is chrome, so it
* localizes. A read-only document says so, since Save is greyed for as long as it is open.
*
* @param Document? document The open document.
* @param String? savedPath The `.uma` the document saves to, or null before its first save.
* @param Boolean readOnly Whether the document opened read-only.
* @param Boolean dirty Whether the session has unsaved edits.
* @return String The title.
*/
@Composable
private fun windowTitleFor(document: Document?, savedPath: String?, readOnly: Boolean, dirty: Boolean): String {
val untitled = stringResource(Res.string.title_untitled_document)
val readOnlyMarker = stringResource(Res.string.title_read_only)
val name = savedPath?.let(::fileDisplayName) ?: document?.let { open -> if (open.path == null) untitled else open.displayName }
val markers = (if (dirty) " *" else "") + (if (readOnly) " $readOnlyMarker" else "")
return stringResource(Res.string.app_name) + (name?.let { " - $it$markers" }.orEmpty())
}
/**
* Whether [path] names a document the editor opens by itself - its own `.uma`, or a `.cmo3` / `.moc3` it imports.
* One test for the command line and the macOS open-file event, so a file the OS hands over is accepted the same
* way however it arrives. The extension only says the path is worth reading; the loader identifies the content.
*
* Artwork is deliberately not a document path: it is ADDED to whatever document is open, so a `.psd` argument
* would have nothing to be added to at this point in the launch.
*
* @param String path A path from the command line or the operating system.
* @return Boolean True when the path has a document extension.
*/
internal fun isOpenableDocumentPath(path: String): Boolean = FormatRegistry.kindForFileName(path)?.role == FileRole.Document
/**
* Desktop entrypoint. Opens a single editor window over the storage/settings foundation: window state
* (size/position) and the recent-files list restore from `:settings`, and File → Open/Save-As use the
* native `:storage` dialogs. An initial document may come from a `.uma`, `.cmo3`, or `.moc3` argument or
* `-Dumamo.testCmo3`; otherwise the window opens into a new, empty document.
* `UMAMO_DUMP_PNG` still dumps the first frame headlessly (the WSL verification path).
*
* Settings load synchronously here (the bundled default is a Compose resource, read via `runBlocking`)
* so the window state is ready before the window opens and the window is unconditional - `application {}`
* exits if it ever has zero windows, which an async settings gate would briefly cause.
*
* @param Array<String> args Optional: a `.uma`, `.cmo3`, or `.moc3` path.
*/
fun main(args: Array<String>) {
// FileKit's native dialogs need a one-time init; `appId` names the per-OS data/cache dirs it uses.
FileKit.init(appId = "umamo")
// Pick the first document argument; loadDocument then does the real magic-byte detection once the file
// is actually read (a .moc3 routes to the sidecar-discovering loader). This is how Windows and Linux hand
// over a double-clicked file.
val initialPath = args.firstOrNull(::isOpenableDocumentPath) ?: System.getProperty("umamo.testCmo3")
// macOS hands a double-clicked file over as an open-file event instead, at launch and for as long as the
// app runs. Installed before the window exists: a cold launch's event can arrive before the first
// composition, and the requests wait in their buffer until the shell collects them.
val openRequests = HostOpenRequests()
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.APP_OPEN_FILE)) {
Desktop.getDesktop().setOpenFileHandler { event ->
event.files.map { file -> file.absolutePath }.firstOrNull(::isOpenableDocumentPath)?.let(openRequests::request)
}
}
// Synchronous load, like the settings below: the window opens with the document already in hand.
// The document reaches the first composition through a one-shot holder rather than a plain local:
// the application closure lives for the whole run, so a direct capture would keep the first
// document reachable after the user opens something else. remember empties the holder on first
// composition; only the path string stays behind for the recent-files record.
// A failed or absent argv load still opens a document - the new, empty one the editor starts in.
val initialDocumentHolder = AtomicReference(loadInitialDocument(initialPath) ?: newBlankDocument())
val initialDocumentPath = initialDocumentHolder.get()?.path
val storage = desktopAppStorage("umamo")
// A first run also seeds the system's language here, so the window - and the Quick Setup modal it opens
// with - is already in that language.
val settings = runBlocking { loadAppSettings(storage) }
// Apply the UI language before the window opens so the menu bar (which lives outside the shell's
// own locale scope) and every other stringResource resolve to the configured locale from the start.
applyAppLocale(settings.getString(LOCALE_SETTINGS_KEY) ?: FALLBACK_LOCALE_TAG)
UmamoLog.info("config=${storage.configDirectory}")
application {
var document by remember { mutableStateOf(initialDocumentHolder.getAndSet(null)) }
// The title's unsaved marker, mirrored from the session's dirty flag by the window content below,
// which is where the session lives.
var dirty by remember { mutableStateOf(false) }
// The title's file name and read-only marker, mirrored the same way from the document's save target,
// which is also derived inside the window content.
var savedPath by remember { mutableStateOf<String?>(null) }
var readOnly by remember { mutableStateOf(false) }
val windowState = remember { settings.savedWindowState() }
// A file opened from the command line is a real "open" - record it in recent files too.
LaunchedEffect(Unit) { initialDocumentPath?.let { settings.addRecentFile(it) } }
fun closeApp() {
settings.saveWindowState(windowState)
exitApplication()
}
// Every way out passes through the shell's unsaved-changes guard: the window's close button here, File >
// Exit inside the shell, and the macOS Quit below.
val exitGuard = rememberExitGuard()
// macOS routes Cmd+Q and the Dock's Quit through the application's quit handler, not the window's
// close request. Cancelling the OS's quit and asking the guard keeps one path; the handler is
// unsupported, and nothing is installed, on Windows and Linux.
DisposableEffect(exitGuard) {
val quitHandlerSupported = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.APP_QUIT_HANDLER)
if (quitHandlerSupported) {
Desktop.getDesktop().setQuitHandler { _, response ->
response.cancelQuit()
exitGuard.request { closeApp() }
}
}
onDispose {
if (quitHandlerSupported) {
Desktop.getDesktop().setQuitHandler(null)
}
}
}
Window(
onCloseRequest = { exitGuard.request { closeApp() } },
state = windowState,
// Window + taskbar/dock icon. painterResource decodes the bundled app_icon PNG (the same
// mascot the packaged installer icons derive from); regenerate via docs/design/appicon/generate.sh.
icon = painterResource(Res.drawable.app_icon),
// A document that has never been saved has no file name to show, so the title localizes its own
// name for it rather than showing the plain-text one the log and export names use.
title = windowTitleFor(document, savedPath, readOnly, dirty),
) {
// The session is derived HERE, in the composition that reads the document, and not in the
// application scope above. Window content is its own composition: it reads the document
// state directly, but sees a value from the outer scope only through the content lambda it
// was last handed. A session derived outside reaches EditorApp one frame late, so a newly
// opened document composes once with the previous document's session - and the export
// command, the File menu, and the page resolver registered in that frame keep the stale
// pair. Deriving both in one place keeps them consistent in every frame.
val session = rememberEditorSessionFor(document)
val documentFile = rememberDocumentFileFor(document)
LaunchedEffect(documentFile) {
readOnly = documentFile?.readOnly == true
snapshotFlow { documentFile?.umaPath }.collect { path -> savedPath = path }
}
LaunchedEffect(session) {
val activeSession = session
if (activeSession == null) {
dirty = false
} else {
activeSession.dirty.collect { dirty = it }
}
}
CompositionLocalProvider(LocalSettings provides settings) {
ProvideAppThemeFromSettings {
// Run the whole window content inside UmamoTheme so LocalUmamoColors resolves to the active
// scheme for everything created here - the Windows title-bar tint AND the GL viewport host,
// which reads the themed grid-backdrop colors at creation (it lives outside the shell's
// own UmamoTheme). The shell re-applies the same theme to its subtree, an idempotent,
// cheap re-provide. Without this wrap LocalUmamoColors falls back to its static dark default,
// so the viewport grid never tracked the theme.
UmamoTheme {
WindowsTitleBarTint(window)
WindowResizeHeal(window)
EditorApp(
document = document,
session = session,
documentFile = documentFile,
onOpen = { document = it },
onExit = { closeApp() },
exitGuard = exitGuard,
viewportServiceFactory = { puppet, textures, liveParams ->
OffscreenPuppetService(puppet, textures, liveParams).also { it.start() }
},
openRequests = openRequests,
)
}
}
}
}
}
}
@@ -0,0 +1,110 @@
package org.umamo.editor.desktop
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.sun.jna.Library
import com.sun.jna.Native
import com.sun.jna.Pointer
import com.sun.jna.ptr.IntByReference
import org.umamo.ui.theme.LocalUmamoColors
import java.awt.Window
/*
* Desktop window-chrome integration: tint the host-OS title bar to match the editor's own palette so the
* caption does not sit as a bright system-colored strip above a dark app. Only Windows 11's Desktop Window
* Manager exposes this (DWMWA_CAPTION_COLOR); every other platform is a no-op. The caption color is read
* from [LocalUmamoColors] so it tracks the active light/dark theme.
*/
/**
* The DWM window attribute that sets the title-bar (caption) fill color.
*
* Win32: DWMWA_CAPTION_COLOR (dwmapi.h, value 35). Honored on Windows 11 build 22000 and later; older
* systems return a failure HRESULT, which we ignore so the call is harmless everywhere.
*/
private const val DWMWA_CAPTION_COLOR = 35
/**
* Minimal JNA binding to dwmapi.dll - only the single entry point we need. Loaded lazily and only on
* Windows (see [setWindowsCaptionColor]); the class is never touched on other platforms, so dwmapi.dll is
* never resolved there.
*/
private interface Dwmapi : Library {
/**
* Win32: DwmSetWindowAttribute. Sets a Desktop Window Manager attribute on a window.
*
* pvAttribute is passed by reference; for DWMWA_CAPTION_COLOR it points at a single COLORREF (DWORD),
* so [value] is an int-by-reference and [valueSize] is 4.
*
* @param Pointer windowHandle The target window's HWND.
* @param Int attribute The DWMWA_* attribute identifier.
* @param IntByReference value Pointer to the attribute value (a COLORREF here).
* @param Int valueSize Size of the value in bytes.
* @return Int The HRESULT; 0 (S_OK) on success.
* @note PascalCase is mandatory: JNA's interface mapper binds this method to the dwmapi.dll export of
* the same name, so it must match the Win32 symbol verbatim - hence the naming-rule suppression.
*/
@Suppress("ktlint:standard:function-naming")
fun DwmSetWindowAttribute(windowHandle: Pointer, attribute: Int, value: IntByReference, valueSize: Int): Int
}
/** The dwmapi.dll binding, resolved on first use. Only ever forced on Windows. */
private val dwmapi: Dwmapi by lazy { Native.load("dwmapi", Dwmapi::class.java) }
/**
* Converts a Compose [Color] to a Win32 COLORREF.
*
* Win32 COLORREF packs the channels as 0x00BBGGRR (blue high, red low, top byte zero) - the reverse of
* ARGB's byte order - so the red and blue channels are swapped relative to [toArgb].
*
* @return Int The COLORREF for this color.
*/
private fun Color.toColorRef(): Int {
val argb = toArgb()
val red = (argb shr 16) and 0xFF
val green = (argb shr 8) and 0xFF
val blue = argb and 0xFF
return (blue shl 16) or (green shl 8) or red
}
/**
* Sets the Windows title-bar caption color to [color] via the Desktop Window Manager. A no-op on any
* non-Windows OS, before the window has a native peer (no HWND yet), or on a Windows build that predates
* DWMWA_CAPTION_COLOR - in the last case DWM returns a failure HRESULT, which is deliberately ignored so
* the call degrades to "system default caption" rather than throwing.
*
* @param Window window The window whose caption to tint.
* @param Color color The desired caption fill color.
*/
private fun setWindowsCaptionColor(window: Window, color: Color) {
// Gate on the OS before touching the JNA binding, so dwmapi.dll is only ever loaded on Windows.
if (!System.getProperty("os.name").startsWith("Windows", ignoreCase = true)) {
return
}
if (!window.isDisplayable) {
return
}
val windowHandle = Native.getWindowPointer(window) ?: return
// HRESULT is ignored: a non-zero result (e.g. Windows 10, which lacks this attribute) just means the
// caption keeps its system color.
dwmapi.DwmSetWindowAttribute(windowHandle, DWMWA_CAPTION_COLOR, IntByReference(color.toColorRef()), Int.SIZE_BYTES)
}
/**
* Tints [window]'s host-OS title bar to the theme's window-background color (Windows 11 only; a no-op
* elsewhere). Reads [LocalUmamoColors], so place it under the app theme; it re-applies whenever the
* resolved background changes (a light/dark theme switch), keeping the caption in step with the UI.
*
* This composable emits no UI - it is purely a window-chrome side effect.
*
* @param Window window The host window whose caption to tint.
*/
@Composable
fun WindowsTitleBarTint(window: Window) {
val captionColor = LocalUmamoColors.current.windowBackground
LaunchedEffect(window, captionColor) {
setWindowsCaptionColor(window, captionColor)
}
}
@@ -0,0 +1,62 @@
package org.umamo.editor.desktop
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import java.awt.event.ComponentEvent
import javax.swing.JFrame
import javax.swing.Timer
/*
* On Windows, canceling an interactive resize with Escape restores the original window rect without
* a resize event: AWT silently syncs the frame's cached bounds (~750 ms later) but dispatches no
* componentResized and runs no layout. Compose derives its scene size, its layout, and
* WindowState.size from that missing event, so the content stays frozen at the dragged size inside
* the restored native window. This watchdog detects the desync and replays the pipeline the lost
* event would have driven.
*/
/** How often the heal watchdog compares the frame's bounds against its laid-out root pane. */
private const val HEAL_CHECK_INTERVAL_MILLIS = 250
/**
* Heals the window when the OS changes its bounds behind AWT's event stream (Escape-canceled
* resize). After every healthy resize the root pane is laid out to exactly the frame's bounds
* minus its insets, so a persistent mismatch is proof of a lost resize notification. On a
* mismatch this re-validates the component tree, which resizes the ComposeWindowPanel and with it
* the Compose scene, then dispatches a synthetic COMPONENT_RESIZED so Compose's own window
* listener refreshes WindowState.size. While bounds and layout agree - the permanent state on
* every platform outside this Windows quirk - each tick is two int comparisons on the EDT, so the
* watchdog runs unconditionally rather than behind an OS gate.
*
* This composable emits no UI - it only owns the watchdog timer's lifecycle.
*
* @param JFrame window The host window to watch and heal.
*/
@Composable
fun WindowResizeHeal(window: JFrame) {
DisposableEffect(window) {
val healTimer =
Timer(HEAL_CHECK_INTERVAL_MILLIS) {
if (!window.isShowing) {
return@Timer
}
val insets = window.insets
val expectedWidth = window.width - insets.left - insets.right
val expectedHeight = window.height - insets.top - insets.bottom
val rootPane = window.rootPane
if (expectedWidth > 0 &&
expectedHeight > 0 &&
(rootPane.width != expectedWidth || rootPane.height != expectedHeight)
) {
// Replay what a real resize event does: layout first so the scene and every Swing
// child match the true bounds, then the window-level event so Compose's listener
// re-reads the (already correct) width/height into WindowState.
window.invalidate()
window.validate()
window.dispatchEvent(ComponentEvent(window, ComponentEvent.COMPONENT_RESIZED))
}
}
healTimer.start()
onDispose { healTimer.stop() }
}
}
@@ -0,0 +1,59 @@
package org.umamo.editor.desktop
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.WindowState
import org.umamo.settings.Settings
/**
* The window size/position/placement to open with - restored from `interface.window.*`, or a sensible
* default (1280×800, platform-placed, floating) on first run. A window saved while maximized or fullscreen
* reopens that way; the persisted size/position are the floating restore geometry it returns to.
*
* @return WindowState The starting window state.
*/
fun Settings.savedWindowState(): WindowState {
val width = (getDouble("interface.window.width") ?: 1280.0).dp
val height = (getDouble("interface.window.height") ?: 800.0).dp
val x = getDouble("interface.window.x")
val y = getDouble("interface.window.y")
val position = if (x != null && y != null) WindowPosition(x.dp, y.dp) else WindowPosition.PlatformDefault
val placement =
when (getString("interface.window.placement")) {
"maximized" -> WindowPlacement.Maximized
"fullscreen" -> WindowPlacement.Fullscreen
else -> WindowPlacement.Floating
}
return WindowState(placement = placement, size = DpSize(width, height), position = position)
}
/**
* Persists [state]'s current placement, plus its size + position, to `interface.window.*` so the next launch
* restores them. Call on close (the [WindowState] tracks live resizes/moves/maximize, so it holds the final
* state). Size and position are recorded only while floating: when maximized or fullscreen, [state]'s size
* and position are the screen-filling bounds, so saving them would clobber the restore geometry the window
* should return to on un-maximize - the last floating geometry is kept instead.
*
* @param WindowState state The window state to persist.
*/
fun Settings.saveWindowState(state: WindowState) {
setString(
"interface.window.placement",
when (state.placement) {
WindowPlacement.Maximized -> "maximized"
WindowPlacement.Fullscreen -> "fullscreen"
WindowPlacement.Floating -> "floating"
},
)
if (state.placement == WindowPlacement.Floating) {
setDouble("interface.window.width", state.size.width.value.toDouble())
setDouble("interface.window.height", state.size.height.value.toDouble())
val position = state.position
if (position is WindowPosition.Absolute) {
setDouble("interface.window.x", position.x.value.toDouble())
setDouble("interface.window.y", position.y.value.toDouble())
}
}
}
@@ -0,0 +1,60 @@
package org.umamo.editor.desktop.viewport
import org.lwjgl.glfw.GLFW
import org.lwjgl.opengl.GL
import org.lwjgl.system.MemoryUtil
import org.umamo.render.gl.GlRenderDevice
/**
* The Windows / Linux offscreen GL context: a hidden GLFW window carrying a GL 3.3 core context, made
* current on the render thread.
*/
internal class GlfwOffscreenGlContext : OffscreenGlContext {
override val backendName: String = "GLFW"
private var window: Long = MemoryUtil.NULL
/**
* Creates the GLFW hidden-window GL 3.3 core context on this thread and makes it current. Returns false
* (degrading to a blank viewport) if GLFW init or window creation fails.
*
* @return Boolean True on success.
*/
override fun createAndMakeCurrent(): Boolean {
// On Linux Wayland sessions, LWJGL's GLFW often fails to create the hidden offscreen
// window, which leaves the puppet viewport blank. Prefer X11 (XWayland) when available.
val osName = System.getProperty("os.name").orEmpty().lowercase()
if (osName.contains("linux") && GLFW.glfwPlatformSupported(GLFW.GLFW_PLATFORM_X11)) {
GLFW.glfwInitHint(GLFW.GLFW_PLATFORM, GLFW.GLFW_PLATFORM_X11)
}
if (!GLFW.glfwInit()) {
return false
}
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE)
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3)
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 3)
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE)
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE)
window = GLFW.glfwCreateWindow(1, 1, "umamo-offscreen", MemoryUtil.NULL, MemoryUtil.NULL)
if (window == MemoryUtil.NULL) {
return false
}
GLFW.glfwMakeContextCurrent(window)
GL.createCapabilities()
return true
}
override fun describeContext(): String = GlRenderDevice().describeBackend()
/**
* Releases the GLFW window and unbinds the context. Runs on the render thread, where the context is
* current, after the engine's glFinish barrier.
*/
override fun destroy() {
if (window != MemoryUtil.NULL) {
GLFW.glfwMakeContextCurrent(MemoryUtil.NULL)
GLFW.glfwDestroyWindow(window)
window = MemoryUtil.NULL
}
}
}
@@ -0,0 +1,56 @@
package org.umamo.editor.desktop.viewport
import org.lwjgl.system.Configuration
/**
* An off-screen GL 3.3+ core context owned by a single render thread. The offscreen viewport renderer
* ([OffscreenRenderEngine]) renders only to framebuffer objects, so a context needs no visible window and no
* presentable drawable - just a current GL context on the thread that issues the draw and read-back calls.
*
* Threading contract: [createAndMakeCurrent], [describeContext], and [destroy] all run on the one render
* thread, in that order across the context's life; the context is never migrated to another thread.
*/
internal interface OffscreenGlContext {
/**
* A short backend label for the startup log line (for example "GLFW" or "CGL GL4_Core"), so the log
* records which path the running OS actually took.
*/
val backendName: String
/**
* Creates the context and makes it current on the calling (render) thread. On failure returns false so
* the caller degrades to a blank viewport rather than crashing - the same graceful fallback the engine
* already applies when GL is unavailable.
*
* @return Boolean True on success (a context is now current), false to degrade to a blank viewport.
*/
fun createAndMakeCurrent(): Boolean
/**
* The renderer / version / vendor / GLSL of the current context, for the startup diagnostic. Valid only
* after a successful [createAndMakeCurrent].
*
* @return String The context description.
*/
fun describeContext(): String
/**
* Releases the context on the render thread. Must NOT call glFinish - the engine issues one glFinish
* barrier before disposing its GL resources, and this runs last, after that barrier.
*/
fun destroy()
}
/**
* Selects the offscreen GL context implementation for the running OS. GLFW is used on all platforms.
*
* @return OffscreenGlContext The context backend for this OS.
*/
internal fun createOffscreenGlContext(): OffscreenGlContext {
val osName = System.getProperty("os.name").orEmpty().lowercase()
if (osName.contains("mac") || osName.contains("darwin")) {
// https://javadoc.lwjgl.org/org/lwjgl/glfw/package-summary.html#using-glfw-on-macos-heading
Configuration.GLFW_LIBRARY_NAME.set("glfw_async")
}
return GlfwOffscreenGlContext()
}
@@ -0,0 +1,217 @@
package org.umamo.editor.desktop.viewport
import androidx.compose.ui.graphics.ImageBitmap
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.withContext
import org.umamo.edit.GridConfig
import org.umamo.format.raster.RasterImage
import org.umamo.render.ContentBounds
import org.umamo.render.FrameBackdrop
import org.umamo.render.GridColors
import org.umamo.render.LayerDrawPlan
import org.umamo.render.LayerRasterBatch
import org.umamo.render.PuppetTextures
import org.umamo.render.ViewportCamera
import org.umamo.render.capturedOver
import org.umamo.render.pick.PickCandidate
import org.umamo.runtime.model.DrawableId
import org.umamo.runtime.model.PuppetModel
import org.umamo.ui.model.DrawableThumbnailProvider
import org.umamo.ui.viewport.AreaCameraKey
import org.umamo.ui.viewport.AtlasPageBinding
import org.umamo.ui.viewport.ImageFrame
import org.umamo.ui.viewport.LiveParams
import org.umamo.ui.viewport.PuppetViewportService
import org.umamo.ui.viewport.RenderedFrame
import org.umamo.ui.viewport.UvSceneContent
/**
* Renders the puppet OFF-SCREEN and publishes it as a Compose ImageBitmap per viewport area.
* Because the viewport is then lightweight Compose content, the UI layers over it correctly on every platform.
*
* This is the desktop implementation of [PuppetViewportService]. It is a thin facade that composes the
* pieces and forwards each call to the collaborator that owns it:
*
* - [ViewportAreaRegistry] - the registered areas + their cameras (register / resize / navigation), on the
* UI thread.
* - [OffscreenRenderEngine] - the render thread that owns the GL context, renderer, framebuffers, and
* async read-back, plus the render-input state (selection / shown / model / atlas pages / source
* artwork / grid / highlight colors).
* - [ViewportPicker] - CPU hit-testing and art thumbnails, on the UI thread (no GL).
*
* The GL context is chosen per OS behind [OffscreenGlContext], which is a hidden GLFW window on every
* desktop OS today (macOS only differs by loading the async GLFW library).
*
* Threading: every method here is called on the UI thread; the engine publishes frames from its render
* thread via the areas' StateFlows. Picking is CPU-side and synchronous.
*
* @property PuppetModel puppet The rig to render.
* @property PuppetTextures textures The atlas page(s).
* @property LiveParams liveParams The shared parameter hand-off (drives re-render on change).
*/
class OffscreenPuppetService(
puppet: PuppetModel,
textures: PuppetTextures,
liveParams: LiveParams,
) : PuppetViewportService {
private val registry = ViewportAreaRegistry()
private val engine = OffscreenRenderEngine(puppet, textures, liveParams, registry)
// The picker shares the engine's renderer for its pure-CPU pickGeometry()/drawnOrder() snapshots (the
// same instance the render thread draws with - those reads are CPU-only and UI-thread-safe).
private val picker = ViewportPicker(engine.puppetRenderer, textures, puppet)
/** Starts the render thread (call once, after construction). */
fun start() {
engine.start()
}
override var zoomStepPercent: Float
get() = registry.zoomStepPercent
set(value) {
registry.zoomStepPercent = value
}
override var zoomStepCoarsePercent: Float
get() = registry.zoomStepCoarsePercent
set(value) {
registry.zoomStepCoarsePercent = value
}
override var supersampleEnabled: Boolean
get() = engine.supersampleEnabled
set(value) {
engine.supersampleEnabled = value
}
override var supersampleWhileResizing: Boolean
get() = engine.supersampleWhileResizing
set(value) {
engine.supersampleWhileResizing = value
}
override var gridColors: GridColors
get() = engine.gridColors
set(value) {
engine.gridColors = value
}
override var gridConfig: GridConfig
get() = engine.gridConfig
set(value) {
engine.gridConfig = value
}
override fun register(areaId: String): StateFlow<RenderedFrame?> = registry.register(areaId)
override fun registerUvScene(areaId: String, content: UvSceneContent, islandExtent: ContentBounds?): StateFlow<RenderedFrame?> =
registry.registerUvScene(areaId, content, islandExtent)
override fun setUvSceneContent(areaId: String, content: UvSceneContent, islandExtent: ContentBounds?) =
registry.setUvSceneContent(areaId, content, islandExtent)
override fun unregister(areaId: String) = registry.unregister(areaId)
override fun cameraFlow(areaId: String): StateFlow<ViewportCamera?> = registry.cameraFlow(areaId)
override fun cameras(): Map<AreaCameraKey, ViewportCamera> = registry.cameras()
override fun seedCameras(cameras: Map<AreaCameraKey, ViewportCamera>) = registry.seedCameras(cameras)
override fun resize(areaId: String, width: Int, height: Int) = registry.resize(areaId, width, height)
override fun pan(areaId: String, deltaXpx: Float, deltaYpx: Float) = registry.pan(areaId, deltaXpx, deltaYpx)
override fun zoomAtCursor(areaId: String, zoomIn: Boolean, coarse: Boolean, cursorXpx: Float, cursorYpx: Float) =
registry.zoomAtCursor(areaId, zoomIn, coarse, cursorXpx, cursorYpx)
override fun zoomCentered(areaId: String, zoomIn: Boolean, coarse: Boolean) =
registry.zoomCentered(areaId, zoomIn, coarse)
override fun zoomToRegion(areaId: String, leftPx: Float, topPx: Float, rightPx: Float, bottomPx: Float) =
registry.zoomToRegion(areaId, leftPx, topPx, rightPx, bottomPx)
override fun actualSize(areaId: String) = registry.actualSize(areaId)
override fun fit(areaId: String) = registry.fit(areaId)
override fun fitWorldRect(areaId: String, minX: Float, minZ: Float, maxX: Float, maxZ: Float) =
registry.fitWorldRect(areaId, minX, minZ, maxX, maxZ)
override fun setSelection(ids: Set<DrawableId>) = engine.setSelection(ids)
override fun setActiveSelection(id: DrawableId?) = engine.setActiveSelection(id)
override fun setShownDrawables(ids: Set<DrawableId>) = engine.setShownDrawables(ids)
override fun setEditMeshFrozen(ids: Set<DrawableId>) = engine.setEditMeshFrozen(ids)
override fun setSourceLayerPlan(plan: LayerDrawPlan) = engine.setSourceLayerPlan(plan)
override fun setAtlasPages(binding: AtlasPageBinding) {
engine.setAtlasPages(binding)
// The picker samples page alpha CPU-side, so its pixels must move with the GPU's - a stale set
// would reject clicks on visible art at the re-derived coordinates.
picker.setTextures(binding.textures)
}
override fun deliverSourceLayerRasters(batch: LayerRasterBatch) = engine.deliverSourceLayerRasters(batch)
/**
* Pushes the latest model to the render engine and, when it actually changed, rebuilds the picker's
* model-derived lookup maps so session-created drawables stay pickable / sampleable / labeled.
*
* @param PuppetModel model The current model.
*/
override fun setModel(model: PuppetModel) {
if (engine.setModel(model)) {
picker.updateModel(model)
}
}
override fun setSelectionHighlightColor(red: Float, green: Float, blue: Float) =
engine.setSelectionHighlightColor(red, green, blue)
override fun setActiveSelectionHighlightColor(red: Float, green: Float, blue: Float) =
engine.setActiveSelectionHighlightColor(red, green, blue)
override fun pickAt(areaId: String, cursorXpx: Float, cursorYpx: Float): DrawableId? {
val view = registry.viewFor(areaId) ?: return null
return picker.pickAt(view.camera, view.width, view.height, cursorXpx, cursorYpx)
}
override fun pickAllAt(areaId: String, cursorXpx: Float, cursorYpx: Float): List<PickCandidate> {
val view = registry.viewFor(areaId) ?: return emptyList()
return picker.pickAllAt(view.camera, view.width, view.height, cursorXpx, cursorYpx)
}
override fun drawableWorldCentroids(): Map<DrawableId, FloatArray> = picker.drawableWorldCentroids()
/**
* Queues the capture on the render thread and, once its pixels arrive, converts them off the UI thread
* from the framebuffer's premultiplied color to the straight alpha an image file stores.
*
* @param ImageFrame frame The camera and pixel size to render.
* @param FrameBackdrop backdrop What the puppet is drawn over.
* @return RasterImage? The image, straight alpha, or null when the render thread could not serve it.
*/
override suspend fun renderImage(frame: ImageFrame, backdrop: FrameBackdrop): RasterImage? {
val premultiplied = engine.requestSnapshot(frame.camera, frame.width, frame.height, backdrop).await() ?: return null
return withContext(Dispatchers.Default) { premultiplied.capturedOver(backdrop) }
}
override fun areaView(areaId: String): ImageFrame? = registry.viewFor(areaId)?.let { view -> ImageFrame(view.camera, view.width, view.height) }
override fun visibleContentBounds(): ContentBounds? = engine.puppetRenderer.posedContentBounds(engine.shownDrawables)
override fun thumbnailFor(id: DrawableId): ImageBitmap? = picker.thumbnailFor(id)
override fun thumbnails(): DrawableThumbnailProvider = picker.thumbnails()
override fun partNameFor(id: DrawableId): String? = picker.partNameFor(id)
override fun drawableNameFor(id: DrawableId): String? = picker.drawableNameFor(id)
override fun dispose() = engine.dispose()
}
@@ -0,0 +1,976 @@
package org.umamo.editor.desktop.viewport
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import org.lwjgl.opengl.GL11
import org.umamo.edit.GridConfig
import org.umamo.format.png.PngCodec
import org.umamo.format.raster.RasterImage
import org.umamo.render.ContentBounds
import org.umamo.render.DecodedImage
import org.umamo.render.FrameBackdrop
import org.umamo.render.GridColors
import org.umamo.render.LayerDrawPlan
import org.umamo.render.LayerRasterBatch
import org.umamo.render.PuppetTextures
import org.umamo.render.SupersampledSurface
import org.umamo.render.ViewportCamera
import org.umamo.render.device.ReadbackTicket
import org.umamo.render.gl.GlRenderDevice
import org.umamo.render.puppet.PuppetRenderer
import org.umamo.runtime.model.ChannelValue
import org.umamo.runtime.model.DrawableId
import org.umamo.runtime.model.KeyableTarget
import org.umamo.runtime.model.ParameterId
import org.umamo.runtime.model.PuppetModel
import org.umamo.runtime.model.visibleDrawableIds
import org.umamo.storage.UmamoLog
import org.umamo.ui.graphics.RgbaAlphaType
import org.umamo.ui.graphics.rgbaToImageBitmap
import org.umamo.ui.viewport.AtlasPageBinding
import org.umamo.ui.viewport.LiveParams
import org.umamo.ui.viewport.RenderedFrame
import org.umamo.ui.viewport.UvSceneContent
import java.io.File
import java.util.ArrayDeque
import java.util.concurrent.ConcurrentLinkedQueue
/**
* Framebuffer pixels per display pixel while supersampling is on: the whole pipeline renders 2x and
* box-downscales on resolve. Supersampling off collapses the scale to 1.
*/
internal const val RENDER_SUPERSAMPLE = 2
/** Idle poll when nothing changed and no read-back is in flight (about 60 Hz wake to pick up new params). */
private const val IDLE_MILLIS = 16L
/** Short poll while a read-back is in flight, so its result is collected with low latency. */
private const val BUSY_MILLIS = 1L
/**
* Minimum interval between resize-driven re-renders while an area's size is actively changing (a
* gutter drag or a window-edge resize): about 10 Hz of live feedback, with the Compose side
* stretching the previous frame between them. Pose / camera / state changes are never throttled.
*/
private const val RESIZE_THROTTLE_NANOS = 50_000_000L
/** How long a size must hold still before it counts as settled (the full-quality render then runs). */
private const val RESIZE_SETTLE_NANOS = 25_000_000L
/**
* The render engine: a dedicated daemon thread owns the GL context, the [PuppetRenderer], the supersample
* framebuffers, and the async read-back pool, and runs the render loop. It holds the render-input state the
* UI thread pushes (selection, shown set, model, atlas pages, source artwork, grid, highlight colors), renders
* each registered area whose pose / size / camera / backdrop changed, and publishes finished frames to the
* area's slot.
*
* The read-back is asynchronous (PBO + fence) so the thread never blocks on the GPU while a slider drags.
* Every 2D area of one document shows the same puppet at the same pose (the shared [liveParams]), so those
* areas differ only by size and camera; re-renders happen only when the pose or an area's
* size / camera / scene content / backdrop changes.
*
* @property PuppetModel puppet The rig to render.
* @property PuppetTextures textures The atlas page(s).
* @property LiveParams liveParams The shared parameter hand-off (drives re-render on change).
* @property ViewportAreaRegistry registry The area slots this engine renders and fits.
*/
internal class OffscreenRenderEngine(
private val puppet: PuppetModel,
private val textures: PuppetTextures,
private val liveParams: LiveParams,
private val registry: ViewportAreaRegistry,
) {
// The GL backend the renderer draws through; render-thread-owned, like every GL object here.
private val device = GlRenderDevice()
// GL handles + async read-back state, all owned by the render thread.
private val renderer =
PuppetRenderer(puppet, textures, device).apply {
// The editor viewport shows the world-origin axes (red X / blue Z behind the puppet); the
// renderer default is off so headless render-diff tests stay line-free.
setWorldAxesVisible(true)
}
/** The shared renderer, exposed so the facade can build the CPU picker over its pickGeometry()/drawnOrder(). */
val puppetRenderer: PuppetRenderer
get() = renderer
private val context = createOffscreenGlContext()
// The supersampled draw + display-size resolve target pair, device-owned and backend-neutral.
private val surface = SupersampledSurface(device, RENDER_SUPERSAMPLE)
/** An asynchronous read-back in flight: the device ticket plus what the pixels will mean on arrival. */
private class PendingFrame(
val ticket: ReadbackTicket,
val areaId: String,
val camera: ViewportCamera,
val model: PuppetModel,
)
// In-flight read-backs in submission order; polled front-first each loop tick. Render-thread only.
private val pendingFrames = ArrayDeque<PendingFrame>()
/**
* An image capture waiting for the render thread: what to draw, and where its pixels go.
*
* @property ViewportCamera camera The capture's camera.
* @property Int width The image width in pixels.
* @property Int height The image height in pixels.
* @property FrameBackdrop backdrop What the puppet is drawn over.
* @property CompletableDeferred<RasterImage?> result Completed with the premultiplied pixels, or null.
*/
private class PendingSnapshot(
val camera: ViewportCamera,
val width: Int,
val height: Int,
val backdrop: FrameBackdrop,
val result: CompletableDeferred<RasterImage?>,
)
// Captures queued by the UI thread and taken up by the render thread between frames. A queue for the same
// reason as the raster batches: two requests landing in one tick must both be served.
private val pendingSnapshots = ConcurrentLinkedQueue<PendingSnapshot>()
// False once the render thread can no longer serve a capture (its context never came up, or it has shut
// down), so a request made after that is answered at once instead of waiting forever.
@Volatile
private var acceptingSnapshots = true
@Volatile
private var running = true
// Daemon so it can never block JVM exit; clean teardown still happens via dispose() -> join.
private val renderThread = Thread({ renderLoop() }, "umamo-offscreen-gl").apply { isDaemon = true }
// --- Render inputs: written by the UI thread (volatile publishes of immutable values / scalars), read by
// the render thread each frame. A change bumps a render-version counter the loop folds into per-area
// freshness, so a state-only change (no resize / pose / camera change) still forces exactly one redraw.
// The grid backdrop colors, fed from the editor theme; default to the neutral grey grid until the host
// pushes the themed colors.
@Volatile
private var gridColorsBacking: GridColors = GridColors.Classic
// The per-document grid geometry (major spacing + subdivisions), fed from the session.
@Volatile
private var gridConfigBacking: GridConfig = GridConfig()
// The currently selected drawables, read by the render thread to tint them.
@Volatile
private var selectionBacking: Set<DrawableId> = emptySet()
// The active (last-selected) drawable, tinted apart from the rest of a multi-selection; null when none.
@Volatile
private var activeSelectionBacking: DrawableId? = null
// The drawables actually drawn (the resolved Parts-panel visibility cascade). Seeded from the open
// model's static cascade.
@Volatile
private var shownBacking: Set<DrawableId> = puppet.visibleDrawableIds()
// Edit-session drawable ids whose textured GPU mesh is frozen as the mesh-edit guide image. Empty
// outside Edit mode. Applied on the render thread before updateModel so topology edits keep the image.
@Volatile
private var editMeshFrozenBacking: Set<DrawableId> = emptySet()
// Which artwork the puppet's drawables map onto, published whole. EMPTY is the atlas, which is where
// every document starts until a plan is prepared for it. The pixels are NOT here: they arrive
// through the queue below, in answer to what the renderer asks for.
@Volatile
private var layerPlanBacking: LayerDrawPlan = LayerDrawPlan.EMPTY
// Decoded artwork waiting to be uploaded, drained on the render thread. A queue rather than a
// volatile slot because deliveries are chunked - two batches landing between frames must both be
// taken up, where a slot would silently drop the first.
private val pendingRasterBatches = ConcurrentLinkedQueue<LayerRasterBatch>()
// The latest model, re-pushed on a structural edit (layer reorder / reparent, base-mesh move); seeded
// with the open model.
@Volatile
private var modelBacking: PuppetModel = puppet
// The construction-time page pair: the pages initGl uploads, tagged with the atlas they render.
// Seeds both the published slot and the applied state, so the loop's first tick applies nothing
// unless a binding was pushed before the thread started.
private val initialAtlasBinding = AtlasPageBinding(puppet.atlas, textures)
// The latest page set, published whole with the atlas value it was composed for. The loop applies
// it and an atlas-changing model as one pair - see the pairing note in renderLoop.
@Volatile
private var atlasBindingBacking: AtlasPageBinding = initialAtlasBinding
// The pair the render thread has actually applied. Render-thread-owned after start(); read by the
// UV fit path (pageContentBounds), which also runs on the render thread.
private var appliedAtlasBinding: AtlasPageBinding = initialAtlasBinding
@Volatile
private var puppetRenderBump: Long = 0
// The UV editor's flat scenes (atlas page, source layer) bump separately from the puppet, so a puppet
// update does not needlessly re-render them.
@Volatile
private var atlasRenderBump: Long = 0
// The color selected drawables are tinted toward; RGB, each 0..1, defaults to the classic blue accent.
@Volatile
private var highlightRed: Float = 0.20f
@Volatile
private var highlightGreen: Float = 0.55f
@Volatile
private var highlightBlue: Float = 1.0f
// The color the active drawable is tinted toward; RGB, each 0..1, defaults to the edit-mode active green.
@Volatile
private var activeHighlightRed: Float = 0.49f
@Volatile
private var activeHighlightGreen: Float = 0.89f
@Volatile
private var activeHighlightBlue: Float = 0.0f
// The performance settings (viewport.rendering.*): whether settled frames supersample at all, and
// whether frames rendered while a size is actively changing keep the supersample (false = drop to
// 1x for a quarter of the fill cost during gutter drags and window resizes).
@Volatile
private var supersampleBacking: Boolean = true
@Volatile
private var supersampleWhileResizingBacking: Boolean = true
private var dumped = false
/** Starts the render thread (call once). */
fun start() {
renderThread.start()
}
/** Stops the render thread and releases the GL context. Blocks briefly to join. */
fun dispose() {
running = false
renderThread.join(2000)
acceptingSnapshots = false
failPendingSnapshots()
}
/**
* The drawables actually drawn (the resolved visibility cascade), as last pushed - what a capture's
* framing measures.
*/
val shownDrawables: Set<DrawableId>
get() = shownBacking
/**
* Queues an image capture of the current pose for the render thread, which takes it up between frames
* with the latest model, pages, artwork, shown set, and pose applied.
*
* Always completes: with the premultiplied pixels, or with null when the render thread cannot serve it.
* The check comes after the enqueue, so a shutdown racing the request still sweeps it up.
*
* @param ViewportCamera camera The capture's camera.
* @param Int width The image width in pixels.
* @param Int height The image height in pixels.
* @param FrameBackdrop backdrop What the puppet is drawn over.
* @return Deferred<RasterImage?> The premultiplied pixels, top row first, or null.
*/
fun requestSnapshot(camera: ViewportCamera, width: Int, height: Int, backdrop: FrameBackdrop): Deferred<RasterImage?> {
val snapshot = PendingSnapshot(camera, width, height, backdrop, CompletableDeferred())
pendingSnapshots.add(snapshot)
if (!acceptingSnapshots) {
failPendingSnapshots()
}
return snapshot.result
}
/** Answers every queued capture with null: the render thread will not serve them. */
private fun failPendingSnapshots() {
while (true) {
val snapshot = pendingSnapshots.poll() ?: break
snapshot.result.complete(null)
}
}
/**
* Renders every queued capture, on the render thread. A capture that fails logs and completes null; it
* never takes the render loop down with it.
*
* A shutdown stops the work at the next tile, so dispose() waits for one tile rather than a whole large
* image; what is left in the queue is answered by the loop's teardown.
*/
private fun serveSnapshots() {
while (running) {
val snapshot = pendingSnapshots.poll() ?: break
try {
if (snapshot.backdrop == FrameBackdrop.Grid) {
// The area renders apply the grid per render; a capture over it applies its own the same way.
val gridConfigApplied = gridConfigBacking
renderer.setGrid(gridColorsBacking, gridConfigApplied.scale, gridConfigApplied.subdivisions)
}
val image = renderer.renderSnapshot(snapshot.camera, snapshot.width, snapshot.height, snapshot.backdrop) { running }
if (image == null) {
UmamoLog.info("[GL] image capture (${snapshot.width}x${snapshot.height}) abandoned at shutdown")
}
snapshot.result.complete(image)
} catch (failure: Exception) {
UmamoLog.error("[GL] image capture (${snapshot.width}x${snapshot.height}) failed", failure)
snapshot.result.complete(null)
} catch (failure: OutOfMemoryError) {
// The stitched image is the one large allocation here, and running short of it costs this
// capture, not the viewport.
UmamoLog.error("[GL] image capture (${snapshot.width}x${snapshot.height}) ran out of memory", failure)
snapshot.result.complete(null)
}
}
}
/**
* The grid backdrop colors (background / major / minor). A change bumps both render passes so a
* color-only change repaints without waiting for an unrelated render.
*/
var gridColors: GridColors
get() = gridColorsBacking
set(value) {
if (value != gridColorsBacking) {
gridColorsBacking = value
doPuppetRenderBump()
doAtlasRenderBump()
}
}
/**
* The per-document grid geometry (major spacing + subdivisions). Like the grid colors, a change bumps
* both render passes so a grid-only change repaints without waiting for an unrelated render.
*/
var gridConfig: GridConfig
get() = gridConfigBacking
set(value) {
if (value != gridConfigBacking) {
gridConfigBacking = value
doPuppetRenderBump()
doAtlasRenderBump()
}
}
/**
* Sets the highlighted drawables (object-mode selection). A change bumps the puppet render version so the
* loop re-renders every area once with the new tint; an identical set is a no-op.
*
* @param Set<DrawableId> ids The selected drawable ids.
*/
fun setSelection(ids: Set<DrawableId>) {
if (ids != selectionBacking) {
selectionBacking = ids
doPuppetRenderBump()
}
}
/**
* Sets the active (last-selected) drawable, tinted apart from the rest of a multi-selection. A change
* bumps the puppet render version; an identical value is a no-op.
*
* @param DrawableId id The active drawable id, or null when none is active.
*/
fun setActiveSelection(id: DrawableId?) {
if (id != activeSelectionBacking) {
activeSelectionBacking = id
doPuppetRenderBump()
}
}
/**
* Sets which drawables are drawn (the resolved Parts-panel visibility cascade). A change bumps the puppet
* render version so every area re-renders once; the geometry is unchanged, so only the draw filter moves.
*
* @param Set<DrawableId> ids The drawable ids to draw.
*/
fun setShownDrawables(ids: Set<DrawableId>) {
if (ids != shownBacking) {
shownBacking = ids
doPuppetRenderBump()
}
}
/**
* Freezes Edit-session textured meshes as the mesh-edit guide image (see
* [PuppetRenderer.setEditMeshFrozen]). A change bumps the puppet render version.
*
* @param Set<DrawableId> ids The Edit-session drawable ids to freeze, or empty to thaw.
*/
fun setEditMeshFrozen(ids: Set<DrawableId>) {
if (ids != editMeshFrozenBacking) {
editMeshFrozenBacking = ids
doPuppetRenderBump()
}
}
/**
* Sets which artwork the puppet's drawables map onto; an empty plan displays from the atlas.
*
* A volatile publish of one immutable value, like every other render input. The render loop hands
* it to the renderer, which is where the GPU work happens - this must not touch the device.
*
* @param LayerDrawPlan plan Each drawable's mapping into the document's artwork.
*/
fun setSourceLayerPlan(plan: LayerDrawPlan) {
if (plan !== layerPlanBacking) {
layerPlanBacking = plan
doPuppetRenderBump()
}
}
/**
* Queues decoded artwork for upload on the render thread.
*
* @param LayerRasterBatch batch The decoded artwork.
*/
fun deliverSourceLayerRasters(batch: LayerRasterBatch) {
pendingRasterBatches.add(batch)
doPuppetRenderBump()
}
/**
* Publishes the atlas page set the current model's placements render from. A pure volatile
* publish: the render loop bumps its own freshness when it APPLIES the binding, because applying
* can lag the publish by a tick while the matching model arrives - a bump here would let an area
* render back to freshness against the outgoing pair and never take the new one up.
*
* @param AtlasPageBinding binding The pages plus the atlas value they belong to.
*/
fun setAtlasPages(binding: AtlasPageBinding) {
if (binding !== atlasBindingBacking) {
atlasBindingBacking = binding
}
}
/**
* Pushes the latest model so the render thread can reconcile it after an edit (a layer reorder
* re-derives the render order; a base-mesh move re-uploads the changed drawables' VBOs). A new (different)
* instance bumps the puppet render version so every area re-renders once.
*
* @param PuppetModel model The current model.
* @return Boolean True when the model actually changed (so the caller rebuilds model-derived state).
*/
fun setModel(model: PuppetModel): Boolean {
if (model !== modelBacking) {
modelBacking = model
doPuppetRenderBump()
return true
}
return false
}
/**
* Sets the color selected drawables are tinted toward (the selection highlight). A change bumps the
* puppet render version; an identical color is a no-op.
*
* @param Float red The tint red, 0..1.
* @param Float green The tint green, 0..1.
* @param Float blue The tint blue, 0..1.
*/
fun setSelectionHighlightColor(red: Float, green: Float, blue: Float) {
if (red != highlightRed || green != highlightGreen || blue != highlightBlue) {
highlightRed = red
highlightGreen = green
highlightBlue = blue
doPuppetRenderBump()
}
}
/**
* Sets the color the active drawable is tinted toward (the active-selection highlight). A change bumps the
* puppet render version; an identical color is a no-op.
*
* @param Float red The tint red, 0..1.
* @param Float green The tint green, 0..1.
* @param Float blue The tint blue, 0..1.
*/
fun setActiveSelectionHighlightColor(red: Float, green: Float, blue: Float) {
if (red != activeHighlightRed || green != activeHighlightGreen || blue != activeHighlightBlue) {
activeHighlightRed = red
activeHighlightGreen = green
activeHighlightBlue = blue
doPuppetRenderBump()
}
}
/**
* Whether settled frames render supersampled at all (viewport.rendering.supersample). Off renders
* everything at 1x - the whole-session performance escape hatch for weak GPUs. A change bumps
* both render passes so every area repaints at the new quality.
*/
var supersampleEnabled: Boolean
get() = supersampleBacking
set(value) {
if (value != supersampleBacking) {
supersampleBacking = value
doPuppetRenderBump()
doAtlasRenderBump()
}
}
/**
* Whether frames rendered while an area's size is actively changing keep the supersample
* (viewport.rendering.supersampleWhileResizing). False (the default) drops those frames to 1x;
* the settle render restores full quality within the settle window. No bump on change - the next
* resize simply picks up the new policy.
*/
var supersampleWhileResizing: Boolean
get() = supersampleWhileResizingBacking
set(value) {
supersampleWhileResizingBacking = value
}
/**
* Bump the render version for puppets to increase the frame by one.
*/
fun doPuppetRenderBump() {
puppetRenderBump++
}
/**
* Bump the render version for atlases to increase the frame by one.
*/
fun doAtlasRenderBump() {
atlasRenderBump++
}
/**
* The render thread body: create the context, then loop - collect finished read-backs, issue new renders
* for changed areas, and idle when there is nothing to do.
*/
private fun renderLoop() {
if (!context.createAndMakeCurrent()) {
UmamoLog.warn("[GL] offscreen context unavailable (${context.backendName}); viewport will stay blank")
acceptingSnapshots = false
failPendingSnapshots()
return
}
UmamoLog.info("[GL] offscreen via ${context.backendName}: ${context.describeContext()}")
try {
renderer.initGl()
var lastParams: Map<ParameterId, Float>? = null
var lastOverrides: Map<KeyableTarget, ChannelValue>? = null
var lastShown: Set<DrawableId>? = null
var lastModel: PuppetModel? = null
var lastLayerPlan: LayerDrawPlan? = null
var paramsVersion = 0L
while (running) {
collectCompleted()
val params = liveParams.values
val shown = shownBacking
// Pages and model apply as a consistent PAIR - the decision itself is pure and tested
// (resolveAtlasPairing); this block only carries it out.
val pairing = resolveAtlasPairing(modelBacking, atlasBindingBacking, appliedAtlasBinding, lastModel)
val orderModel = pairing.orderModel
pairing.applyBinding?.let { binding ->
// Pages first, then the model that samples them. The freshness bumps happen HERE, at
// apply, not at publish: paramsVersion re-renders the puppet areas, the atlas bump the
// UV page areas (whose AtlasPage content compares by index and cannot see same-index-
// new-pixels). A concurrent UI-thread bump can collapse into this one; both causes are
// covered by the single re-render that follows either way.
renderer.setAtlasPages(binding.textures)
appliedAtlasBinding = binding
paramsVersion++
doAtlasRenderBump()
}
// The artwork hand-off, on the render thread where the uploads belong. The mapping is
// compared by identity: it is published whole, so a new reference IS the change.
val layerPlan = layerPlanBacking
if (layerPlan !== lastLayerPlan) {
renderer.setSourceLayerPlan(layerPlan)
lastLayerPlan = layerPlan
}
// Then any decoded pixels that arrived since the last frame. Drained rather than sampled:
// the producer chunks its deliveries so visible art lands first, and skipping a batch would
// strand whatever it carried on the atlas until the working set happened to move again.
while (true) {
val batch = pendingRasterBatches.poll() ?: break
renderer.deliverSourceLayerRasters(batch)
}
// Edit-mode guide freeze must land before updateModel so a topology delete in the same tick
// keeps the textured mesh. Applied every tick (cheap set-equality no-op when unchanged).
renderer.setEditMeshFrozen(editMeshFrozenBacking)
// Rebuild the pose - and thus the draw list, which setPose filters by the shown set and sorts by
// the render order - when the pose, the visibility cascade, OR the render order changes. A
// visibility toggle or a layer reorder leaves the params untouched, so without these checks the
// draw list would never refresh. setShownDrawables / updateModel run first so setPose uses them.
// The override map is compared by identity like the params map: both are swapped wholesale on
// the UI thread, so a reference change is exactly "something moved".
val overrides = liveParams.channelOverrides
if (params !== lastParams || overrides !== lastOverrides || shown !== lastShown || orderModel !== lastModel) {
renderer.setShownDrawables(shown)
if (orderModel !== lastModel) {
// Re-point the renderer at the edited model so the next setPose re-derives the draw order
// and (for a deformer reparent) the deform chain.
renderer.updateModel(orderModel)
lastModel = orderModel
}
renderer.setPose(params, overrides)
lastParams = params
lastOverrides = overrides
lastShown = shown
paramsVersion++
}
// Captures run after the hand-offs above, so each one shows exactly the state the areas are about
// to render. A capture leaves the renderer's camera, scale, and selection as it found them, and
// every area render sets its own anyway.
serveSnapshots()
var pendingWork = pendingFrames.isNotEmpty()
val nowNanos = System.nanoTime()
val settleScale = if (supersampleBacking) RENDER_SUPERSAMPLE else 1
// With supersampling off both scales collapse to 1, so supersampleWhileResizing is
// inert by construction (the preferences UI disables its checkbox to say so).
val interactiveScale = if (supersampleWhileResizingBacking) settleScale else 1
for ((areaId, slot) in registry.areas) {
val width = slot.width
val height = slot.height
if (width <= 0 || height <= 0) {
continue
}
// Track size-change recency for the resize throttle. The FIRST observation (a fresh
// slot, observed 0x0) does not stamp, so a newly opened area counts as settled and its
// first frame renders at full quality immediately.
if (width != slot.observedWidth || height != slot.observedHeight) {
val firstObservation = slot.observedWidth == 0 && slot.observedHeight == 0
slot.observedWidth = width
slot.observedHeight = height
if (!firstObservation) {
slot.sizeChangedNanos = nowNanos
}
}
if (slot.inFlight) {
pendingWork = true
continue // one read-back per area in flight; coalesces a flurry of slider moves
}
// Establish or refit the camera now that the size is known - the render thread owns the
// content bounds; the registry restores a remembered camera or fits fresh, and swaps a UV
// area's view when the page or layer it shows has changed.
val camera = registry.establishCamera(slot, areaId, width, height) { scene, content -> contentBoundsFor(scene, content) }
// Freshness splits into the size axis (throttled during an active resize) and the rest.
// A frame rendered below the settle scale stays size-stale on purpose, so the settle
// pass re-renders it at full quality once the size holds still.
// A UV scene is model-independent, so its freshness ignores the pose version and
// puppetRenderBump: it re-renders only on size / camera / the surface it shows (the page index
// or the layer raster), plus the grid colors and geometry it draws its backdrop with - tracked
// by atlasRenderBump. The puppet keeps the full freshness via puppetRenderBump.
val sizeFresh = slot.renderedWidth == width && slot.renderedHeight == height && slot.renderedScale == settleScale
val restFresh =
when (slot.scene) {
RenderScene.Puppet2D ->
slot.renderedParamsVersion == paramsVersion &&
slot.renderedCamera === camera &&
slot.puppetRenderBumpDone == puppetRenderBump
// Kind and payload are read as ONE value, so a switch can never be observed half
// applied. Equality rather than identity: AtlasPage compares its index, and
// SourceLayer's image compares by reference, which is the freshness test either
// surface wants.
RenderScene.UvScene ->
slot.renderedUvContent == slot.uvContent &&
slot.renderedCamera === camera &&
slot.atlasRenderBumpDone == atlasRenderBump
}
if (sizeFresh && restFresh) {
continue
}
if (restFresh && shouldDeferResizeRender(slot, nowNanos)) {
// Deliberately NOT pendingWork: with no read-back in flight the loop then sleeps
// IDLE_MILLIS (16 ms) and revisits, which cannot oversleep the RESIZE_SETTLE_NANOS or the
// RESIZE_THROTTLE_NANOS window - flagging pendingWork with an empty pendingFrames queue
// would skip both sleeps and busy-spin instead.
continue
}
// A size still in motion renders at the interactive scale; pose / camera / state changes
// during that motion share the burst's quality rather than forcing a full-scale render.
val sizeInMotion = nowNanos - slot.sizeChangedNanos < RESIZE_SETTLE_NANOS
val renderScale = if (sizeInMotion) interactiveScale else settleScale
if (width != slot.renderedWidth || height != slot.renderedHeight) {
slot.resizeRenderNanos = nowNanos
}
issueRender(areaId, slot, width, height, paramsVersion, camera, orderModel, renderScale)
pendingWork = true
}
if (!pendingWork) {
Thread.sleep(IDLE_MILLIS)
} else if (pendingFrames.isNotEmpty()) {
Thread.sleep(BUSY_MILLIS)
}
}
} finally {
// Captures are answered before any GL teardown, which can itself throw: a caller awaiting one must
// hear back however this thread ends.
acceptingSnapshots = false
failPendingSnapshots()
// glFinish before any other GL call here, so the driver completes all pending GPU work BEFORE the
// disposers delete GL objects and the context is destroyed - otherwise a driver worker thread can be
// mid-copy on memory we free, which crashed (SIGSEGV in libc memcpy) on a clean window close. A
// single barrier here; the collaborators' dispose() must NOT call glFinish, and the context is
// destroyed last.
GL11.glFinish()
// Abandon in-flight read-backs (the fences/staging are freed through the device); the surface
// targets go the same way. The context is destroyed last.
while (pendingFrames.isNotEmpty()) {
device.cancelReadback(pendingFrames.removeFirst().ticket)
}
// The renderer's own device objects. Source artwork and underlay images are created and
// destroyed across its life rather than uploaded once, so they need releasing explicitly
// rather than being left to die with the context.
renderer.disposeGl()
pendingRasterBatches.clear()
surface.dispose()
context.destroy()
}
}
/**
* The resize-throttle gate: whether a render whose ONLY staleness is its size should wait. A size
* that has held still for the settle window renders immediately (the full-quality settle pass);
* one still in motion renders at most once per throttle interval.
*
* @param AreaSlot slot The area being considered.
* @param Long nowNanos The loop pass's monotonic timestamp.
* @return Boolean True to skip this tick and let the idle sleep revisit.
*/
private fun shouldDeferResizeRender(slot: AreaSlot, nowNanos: Long): Boolean {
val settled = nowNanos - slot.sizeChangedNanos >= RESIZE_SETTLE_NANOS
val throttleElapsed = nowNanos - slot.resizeRenderNanos >= RESIZE_THROTTLE_NANOS
return !settled && !throttleElapsed
}
/**
* Renders [slot] at [width] x [height] into the supersampled draw target, box-downscales it into the
* resolve framebuffer, then kicks off an asynchronous read-back gated by a fence. Marks the slot
* in-flight; the result is posted later by [collectCompleted].
*
* @param String areaId The area's id.
* @param AreaSlot slot The area being rendered.
* @param Int width The render width in pixels.
* @param Int height The render height in pixels.
* @param Long paramsVersion The pose version this render reflects.
* @param ViewportCamera camera The view to project through.
* @param PuppetModel orderModel The model whose geometry this render reflects (stamped onto the frame).
* @param Int renderScale Framebuffer pixels per display pixel for THIS render: the settle scale for
* a still frame, the interactive scale while the size is in motion.
*/
private fun issueRender(
areaId: String,
slot: AreaSlot,
width: Int,
height: Int,
paramsVersion: Long,
camera: ViewportCamera,
orderModel: PuppetModel,
renderScale: Int,
) {
val renderWidth = width * renderScale
val renderHeight = height * renderScale
val drawTarget = surface.ensure(width, height, renderScale)
// Supersample: render the whole pipeline (puppet, clip masks, grid) into the renderScale x draw
// buffer, then box-downscale to display size on resolve. The camera zoom and the grid line width scale
// by the same factor so framing and backdrop are unchanged after the downscale. The resolve target
// is display-size whatever the scale, so read-back consumers never see the quality switch.
renderer.setRenderScale(renderScale.toFloat())
// Capture the backdrop versions applied to this render so the freshness stamp below matches what was
// actually drawn; a change after this point bumps them again and re-renders next iteration.
val puppetRenderBumpDone = puppetRenderBump
val atlasRenderBumpDone = atlasRenderBump
val gridConfigApplied = gridConfigBacking
renderer.setGrid(gridColorsBacking, gridConfigApplied.scale, gridConfigApplied.subdivisions)
renderer.setSelection(selectionBacking)
renderer.setActiveSelection(activeSelectionBacking)
// The shown set is applied in the render-loop pose block (before setPose filters the draw list by it).
renderer.setSelectionHighlightColor(highlightRed, highlightGreen, highlightBlue)
renderer.setActiveSelectionHighlightColor(activeHighlightRed, activeHighlightGreen, activeHighlightBlue)
renderer.setCamera(camera.copy(zoom = camera.zoom * renderScale))
// Read once, drawn and stamped from the same value: re-reading slot.uvContent between the draw and
// the stamp below would let a switch land in between and mark the frame fresh for content it does
// not show.
val uvContent = slot.uvContent
when (slot.scene) {
RenderScene.Puppet2D -> renderer.render(drawTarget, renderWidth, renderHeight)
// A UV area draws its flat surface instead; the pose / selection / shown state pushed above are
// harmless no-ops for it (neither UV draw reads any of them - just the grid and the surface quad).
RenderScene.UvScene ->
when (uvContent) {
// An atlas page the engine already uploaded, addressed by index.
is UvSceneContent.AtlasPage -> renderer.renderAtlasPage(drawTarget, uvContent.pageIndex, renderWidth, renderHeight)
// Artwork the engine has never uploaded, so the renderer takes the pixels rather than an
// index and caches the texture it makes from them.
is UvSceneContent.SourceLayer -> renderer.renderUnderlayImage(drawTarget, uvContent.image, renderWidth, renderHeight)
null -> renderer.renderAtlasPage(drawTarget, null, renderWidth, renderHeight)
}
}
surface.resolve()
if (!dumped) {
System.getenv("UMAMO_DUMP_PNG")?.let { dumpPath ->
// A synchronous client read-back; safe here because no PBO is bound yet. Encoding and the
// file write live here rather than in :render - reading pixels is the renderer's business,
// turning them into a PNG on disk is not, and keeping the split means :render needs no
// image library at all.
File(dumpPath).writeBytes(PngCodec.write(device.readPixels(surface.resolveTarget, width, height)))
dumped = true
UmamoLog.info("[GL] puppet dumped to $dumpPath (${width}x$height)")
}
}
// Bind the frame to the camera it was rendered at (the plain, non-supersampled camera) and to
// orderModel, the geometry this render reflects, so the overlay projects/poses against them - keeping
// the mesh glued to the raster along both the navigation and edit axes. The resolve target is
// capacity-sized (grow-only), so the read-back covers only the used region.
pendingFrames.addLast(PendingFrame(device.beginReadback(surface.resolveTarget, width, height), areaId, camera, orderModel))
slot.inFlight = true
slot.renderedWidth = width
slot.renderedHeight = height
slot.renderedScale = renderScale
slot.renderedParamsVersion = paramsVersion
slot.renderedCamera = camera
slot.puppetRenderBumpDone = puppetRenderBumpDone
slot.atlasRenderBumpDone = atlasRenderBumpDone
slot.renderedUvContent = uvContent
}
/**
* Collects every read-back whose fence signaled and publishes it to its area's slot, clearing the slot's
* in-flight flag. A read-back whose slot was unregistered while in flight is discarded (the slot is gone).
*/
private fun collectCompleted() {
// Front-first, stopping at the first still-in-flight ticket: reads complete in submission order on
// the GPU timeline, so a later one cannot be done before an earlier one.
while (pendingFrames.isNotEmpty()) {
val pending = pendingFrames.first()
val pixels = device.pollReadback(pending.ticket) ?: break
pendingFrames.removeFirst()
val slot = registry.areas[pending.areaId] ?: continue
slot.inFlight = false
// The device's read-back is TOP-first RGBA already; the preview background is composited into
// RGB, so it is opaque - the shared seam's Opaque path ignores the alpha bytes (no per-frame
// alpha pass) and gives the eventual Android viewport the same conversion for free.
val bitmap = rgbaToImageBitmap(pixels.rgba, pixels.width, pixels.height, RgbaAlphaType.Opaque)
slot.imageState.value = RenderedFrame(bitmap, pending.camera, pending.model)
}
}
/**
* The content rectangle an area's camera fits: the puppet's rest-pose bounds for a 2D area, or the
* shown surface's rectangle for a UV-editor area (the atlas page, or the source layer's raster), which
* the registry widens to the shown meshes. Takes the kind and content the registry read rather than
* re-reading the slot, so the rectangle is of the surface the camera is filed under. Render thread only
* (reads the renderer's bounds).
*
* @param RenderScene scene The area's kind.
* @param UvSceneContent? uvContent What a UV-editor area shows; null for a puppet area.
* @return ContentBounds The rectangle to fit.
*/
private fun contentBoundsFor(scene: RenderScene, uvContent: UvSceneContent?): ContentBounds =
when (scene) {
RenderScene.Puppet2D -> renderer.contentBounds()
RenderScene.UvScene ->
when (uvContent) {
is UvSceneContent.AtlasPage -> pageContentBounds(uvContent.pageIndex)
is UvSceneContent.SourceLayer -> imageContentBounds(uvContent.image)
null -> pageContentBounds(null)
}
}
/**
* The source-layer rectangle (0, 0, width, height) for the UV-editor fit, or a unit square when there
* is no layer, matching [pageContentBounds]' fallback so both UV scenes frame the same way.
*
* @param DecodedImage image The layer raster, or null for none.
* @return ContentBounds The layer rectangle, in texel/display units.
*/
private fun imageContentBounds(image: DecodedImage?): ContentBounds =
if (image != null) {
ContentBounds(0f, 0f, image.width.toFloat(), image.height.toFloat())
} else {
ContentBounds(0f, 0f, 1f, 1f)
}
/**
* The atlas page rectangle (0, 0, pageWidth, pageHeight) for the UV-editor fit, or a unit square when
* the page is missing (an untextured active drawable) so the fit stays sane and the grid still frames.
*
* @param Int pageIndex The atlas page, or null for none.
* @return ContentBounds The page rectangle, in texel/display units.
*/
private fun pageContentBounds(pageIndex: Int?): ContentBounds {
val page = pageIndex?.let { appliedAtlasBinding.textures.atlases.getOrNull(it) }
return if (page != null) {
ContentBounds(0f, 0f, page.width.toFloat(), page.height.toFloat())
} else {
ContentBounds(0f, 0f, 1f, 1f)
}
}
}
/**
* One render-loop tick's model/pages pairing decision.
*
* @property PuppetModel orderModel The model to render this tick (the published one, or the
* previous one while its pages are still in flight).
* @property AtlasPageBinding? applyBinding The binding to apply before the model, or null.
*/
internal class AtlasPairingDecision(
val orderModel: PuppetModel,
val applyBinding: AtlasPageBinding?,
)
/**
* Decides how the render loop takes up a published model and a published page binding as one
* consistent pair.
*
* The two arrive on independent channels, and on an undo the baseline model would land frames before
* the baseline pages - repacked pixels under baseline coordinates - so an atlas-CHANGING model waits
* until the binding composed for its atlas has arrived, and the loop keeps rendering the previous
* pair. Non-atlas edits pass untouched: their atlas is the applied binding's own instance. Atlas
* comparison is identity first, then equality - the session's baseline short-circuit can publish the
* baseline pages under an equal-but-distinct atlas instance.
*
* Pure and render-thread-agnostic so the hold/apply matrix is testable without a GL context.
*
* @param PuppetModel publishedModel The latest model the UI published.
* @param AtlasPageBinding publishedBinding The latest page binding the UI published.
* @param AtlasPageBinding appliedBinding The binding the renderer currently holds.
* @param PuppetModel? lastModel The model the loop last applied, or null on the first tick.
* @return AtlasPairingDecision What to render and whether to swap pages first.
*/
internal fun resolveAtlasPairing(
publishedModel: PuppetModel,
publishedBinding: AtlasPageBinding,
appliedBinding: AtlasPageBinding,
lastModel: PuppetModel?,
): AtlasPairingDecision {
val bindingMatchesPublished =
publishedBinding.atlas === publishedModel.atlas || publishedBinding.atlas == publishedModel.atlas
val appliedMatchesPublished =
appliedBinding.atlas === publishedModel.atlas || appliedBinding.atlas == publishedModel.atlas
val orderModel =
if (!appliedMatchesPublished && !bindingMatchesPublished) {
// The pages for this model's atlas have not arrived; keep the previous pair. The first
// tick has no previous model to keep, and renders the published one against whatever pages
// exist rather than nothing at all.
lastModel ?: publishedModel
} else {
publishedModel
}
val applyBinding =
if (publishedBinding !== appliedBinding &&
(publishedBinding.atlas === orderModel.atlas || publishedBinding.atlas == orderModel.atlas)
) {
publishedBinding
} else {
null
}
return AtlasPairingDecision(orderModel, applyBinding)
}
@@ -0,0 +1,659 @@
package org.umamo.editor.desktop.viewport
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import org.umamo.render.ContentBounds
import org.umamo.render.ViewportCamera
import org.umamo.ui.viewport.AreaCameraKey
import org.umamo.ui.viewport.CameraSurface
import org.umamo.ui.viewport.RenderedFrame
import org.umamo.ui.viewport.UvSceneContent
import java.util.concurrent.ConcurrentHashMap
/**
* Which content an area renders: the posed puppet (2D viewport), or the UV editor's flat surface.
*
* WHICH flat surface - a packed atlas page or a source layer's artwork - is not recorded here. That
* belongs to [AreaSlot.uvContent], which carries the kind together with its payload; splitting it
* across two fields is what let a switch be observed half applied.
*/
internal enum class RenderScene {
Puppet2D,
UvScene,
}
/** The surface a scene's camera frames, which is what a remembered camera is keyed by beside its area. */
internal val RenderScene.cameraSurface: CameraSurface
get() =
when (this) {
RenderScene.Puppet2D -> CameraSurface.Viewport
RenderScene.UvScene -> CameraSurface.Uv
}
/**
* Which flat surface a UV-editor camera frames: one atlas page, or one source layer. A view of one means
* nothing over another - a page of thousands of texels and a layer of a few hundred share only their
* origin - so a UV-editor area keeps a view per surface.
*/
internal sealed interface UvSurfaceId {
/**
* An atlas page, by index.
*
* @property Int? pageIndex The page, or null for the untextured fallback's unit square.
*/
data class Page(val pageIndex: Int?) : UvSurfaceId
/**
* A source layer, by its key in the document's source-art store.
*
* @property String layerKey The layer's key.
*/
data class Layer(val layerKey: String) : UvSurfaceId
}
/** The surface this content shows: its identity, never its pixels, so a re-decoded layer is the same surface. */
internal val UvSceneContent.surfaceId: UvSurfaceId
get() =
when (this) {
is UvSceneContent.AtlasPage -> UvSurfaceId.Page(pageIndex)
is UvSceneContent.SourceLayer -> UvSurfaceId.Layer(layerKey)
}
/**
* A camera together with the UV surface it frames, published as ONE value so the two cannot tear: a pan on the
* UI thread racing a surface switch on the render thread can lose one update at worst, never file a view under
* the wrong surface.
*
* @property ViewportCamera camera The pan / zoom.
* @property UvSurfaceId? surface The UV surface it frames, or null for a puppet area's view of the world.
*/
internal data class FramedCamera(val camera: ViewportCamera, val surface: UvSurfaceId?)
/**
* What a UV-editor view is remembered under for the session: one area showing one surface.
*
* @property String areaId The hosting leaf's area id.
* @property UvSurfaceId surface The page or layer the view frames.
*/
internal data class AreaUvSurfaceKey(val areaId: String, val surface: UvSurfaceId)
/**
* The rectangle a UV-editor fit frames: the shown surface, widened to take in every shown mesh that reaches
* past it. A placement moved off the page carries its islands with it, and a fit that only knew the page
* would frame everything but the thing just moved.
*
* @param ContentBounds surfaceBounds The shown surface's rectangle.
* @param ContentBounds? islandExtent The shown meshes' bounds, or null for none.
* @return ContentBounds The union of the two.
*/
internal fun uvFitBounds(surfaceBounds: ContentBounds, islandExtent: ContentBounds?): ContentBounds {
if (islandExtent == null) {
return surfaceBounds
}
val minX = minOf(surfaceBounds.minX, islandExtent.minX)
val minY = minOf(surfaceBounds.minY, islandExtent.minY)
val maxX = maxOf(surfaceBounds.minX + surfaceBounds.width, islandExtent.minX + islandExtent.width)
val maxY = maxOf(surfaceBounds.minY + surfaceBounds.height, islandExtent.minY + islandExtent.height)
return ContentBounds(minX, minY, maxX - minX, maxY - minY)
}
/** The camera and pixel size of a registered area, resolved for a CPU pick. Null-camera areas do not appear. */
internal data class AreaView(val camera: ViewportCamera, val width: Int, val height: Int)
/**
* Per-area render state, shared between the UI thread ([ViewportAreaRegistry]) and the render thread
* ([OffscreenRenderEngine]). Field-ownership contract:
*
* - The @Volatile fields are written by the UI thread and read by the render thread (a volatile publish of
* immutable values or plain scalars): scene, uvContent, uvIslandExtent, width, height, refitRequested.
* framing is written by both: the UI thread's pan / zoom and the render thread's establish, each
* replacing the whole value.
* - imageState / cameraState are thread-safe StateFlows; either thread may set them.
* - refCount is touched only on the UI thread (register/unregister run as composition effects).
* - The remaining plain fields (inFlight, rendered*, *RenderBumpDone) are render-thread-only bookkeeping.
*/
internal class AreaSlot {
// Whether this area renders the posed puppet or the UV editor's flat surface. Set by whichever
// registration claimed the slot last (register vs registerUvScene): switching an area's editor type in
// place registers the new space before the old one releases, so a live slot CAN change kind. WHICH
// flat surface is carried by uvContent below. UI thread writes, render thread reads - a volatile publish.
@Volatile
var scene: RenderScene = RenderScene.Puppet2D
// What a UV-editor area draws, as ONE value: which kind and its payload inseparably.
//
// Publishing the kind and the payload as separate fields would let the render thread observe a
// half-applied switch - the old kind against the new payload - which reads as a legitimately stale
// frame, renders grid-only, and then stamps itself fresh against the payload that landed meanwhile.
// The area would sit on an empty grid until a pan or resize happened to dislodge it, and nothing
// would look wrong anywhere. A single reference cannot tear, so the switch is all-or-nothing.
//
// Null for a puppet area, which has no UV surface.
@Volatile
var uvContent: UvSceneContent? = null
// The display-space bounds of the meshes a UV-editor area shows, which its fit widens the surface to take
// in. Read only when a fit runs, so an edit that moves an island re-renders nothing. Written BEFORE
// uvContent, and read after it: a render thread that sees new content also sees the extent measured over it.
@Volatile
var uvIslandExtent: ContentBounds? = null
@Volatile
var width: Int = 0
@Volatile
var height: Int = 0
val imageState = MutableStateFlow<RenderedFrame?>(null)
// The per-area camera (pan/zoom) with the UV surface it frames. null until the render thread computes the
// initial fit (it needs the area size + content bounds); thereafter each pan / zoom swaps in a new immutable
// value (a volatile publish), and the render thread swaps it again when a UV area's shown surface is no
// longer the one it frames. cameraState mirrors the camera for the overlay readout.
@Volatile
var framing: FramedCamera? = null
/** The area's current pan / zoom, or null before the first fit. */
val camera: ViewportCamera?
get() = framing?.camera
// Set by the Fit command (UI thread), cleared by the render thread, which then recomputes a fresh fit
// (ignoring any remembered camera). A flag rather than camera=null so the old view shows until the refit
// lands, and so refit beats the workspace-restore path.
@Volatile
var refitRequested: Boolean = false
val cameraState = MutableStateFlow<ViewportCamera?>(null)
// How many live composables currently hold this area id. A leaf can be torn down and rebuilt for the SAME
// id during a tree collapse (closing a split sibling), so register(new) and unregister(old) briefly
// overlap; the slot is dropped only when this returns to 0. Touched only on the Compose UI thread.
var refCount: Int = 0
// Render-thread-only bookkeeping (no synchronization needed).
var inFlight: Boolean = false
var renderedWidth: Int = -1
var renderedHeight: Int = -1
var renderedParamsVersion: Long = -1
var renderedCamera: ViewportCamera? = null
var puppetRenderBumpDone: Long = -1
var atlasRenderBumpDone: Long = -1
var renderedUvContent: UvSceneContent? = null
// Render-thread-only resize-throttle bookkeeping: the last size the loop observed, when it last
// changed, when the last resize-driven render was issued (all System.nanoTime), and the
// supersample scale of the last issued render (a 1x interactive frame stays size-stale so the
// settle pass re-renders it at full quality).
var observedWidth: Int = 0
var observedHeight: Int = 0
var sizeChangedNanos: Long = 0L
var resizeRenderNanos: Long = 0L
var renderedScale: Int = -1
}
/**
* Owns the registered viewport areas and their cameras. The register/resize/camera-navigation surface runs
* on the UI thread; [OffscreenRenderEngine] iterates the same [areas] map on the render thread and calls
* [establishCamera] to fit newly-sized areas. The shared state is safe across the two threads: the slot map
* is a ConcurrentHashMap, per-area hand-off fields are @Volatile, and the camera flows are StateFlows.
*/
internal class ViewportAreaRegistry {
/** The registered areas, keyed by stable area id. Iterated by the render engine; mutated by the UI thread. */
val areas = ConcurrentHashMap<String, AreaSlot>()
// Cameras remembered by area AND surface beyond a slot's composable life, so switching workspaces (which
// disposes the inactive workspace's viewports -> drops their slots) and returning restores the pan/zoom
// instead of refitting. Keyed by the surface too because a view of the puppet's world means nothing over
// a texture's pixels: an area switched between the 2D viewport and the UV editor keeps one view of each.
// Area ids are minted once and never reused, so entries never collide; the map grows only by areas ever
// shown (a few floats each) and is not evicted (session-bounded, negligible cost). A UV editor's entry is
// the view of the page or layer it shows now - the one a save writes.
private val rememberedCameras = ConcurrentHashMap<AreaCameraKey, ViewportCamera>()
// A UV-editor area's view of EACH page and layer it has shown, so switching to one it has left brings back
// that view and one it has never shown is fitted: a page's pan and zoom over a layer a fraction of its size
// lands the layer tiny and in a corner. Session state only - never in cameras(), so it never reaches a
// save - and dropped with the engine, so a new document starts over. Bounded the way rememberedCameras is.
private val uvSurfaceCameras = ConcurrentHashMap<AreaUvSurfaceKey, ViewportCamera>()
// The areas that have shown a UV surface this session. Until an area has, its remembered UV view can only
// be the one the document was saved with, which belongs to whichever surface the area opens on.
private val uvShownAreaIds = ConcurrentHashMap.newKeySet<String>()
/**
* Every remembered camera, by area and surface - the areas shown now and the ones a workspace switch put away.
*
* @return Map A copy of the remembered cameras.
*/
fun cameras(): Map<AreaCameraKey, ViewportCamera> = HashMap(rememberedCameras)
/**
* Remembers [cameras] as though each area had been shown with it, so an area registering for the first time
* opens on its saved view rather than a fit. Meant for the moment the engine is built, before any area
* registers; an area that already has a camera keeps it.
*
* @param Map cameras The saved cameras, by area and surface.
*/
fun seedCameras(cameras: Map<AreaCameraKey, ViewportCamera>) {
for ((cameraKey, camera) in cameras) {
rememberedCameras.putIfAbsent(cameraKey, camera)
}
}
// Zoom increments in percentage points, fed from settings (viewport.zoomStep*Percent): the fine step is
// one wheel notch / keyboard press, the coarse step is the Shift-held variant. Defaults mirror
// defaultSettings.json. UI thread only.
@Volatile
var zoomStepPercent: Float = 1f
@Volatile
var zoomStepCoarsePercent: Float = 5f
/**
* Registers a viewport area and returns the flow of images to display for it. Re-registering an id that
* is still live (the same area's leaf rebuilt during a tree collapse - see [AreaSlot.refCount]) returns
* the existing slot and its last image, so the surviving viewport keeps rendering instead of being
* orphaned.
*
* @param String areaId The hosting area's stable id.
* @return StateFlow The area's image stream (null until the first render completes).
*/
fun register(areaId: String): StateFlow<RenderedFrame?> {
val slot = areas.getOrPut(areaId) { AreaSlot() }
claim(slot, RenderScene.Puppet2D, content = null, islandExtent = null)
slot.refCount++
return slot.imageState
}
/**
* Registers a UV-editor area (the flat image underlay) and returns its image flow.
*
* @param String areaId The hosting area's stable id.
* @param UvSceneContent content What the area draws.
* @param ContentBounds? islandExtent The shown meshes' display-space bounds, or null for none.
* @return StateFlow The area's image stream (null until the first render completes).
*/
fun registerUvScene(areaId: String, content: UvSceneContent, islandExtent: ContentBounds?): StateFlow<RenderedFrame?> {
val slot = areas.getOrPut(areaId) { AreaSlot() }
claim(slot, RenderScene.UvScene, content, islandExtent)
slot.refCount++
return slot.imageState
}
/**
* Makes [slot] an area of [scene], whatever it was.
*
* A slot outlives the space that registered it whenever the next space registers first - and switching an
* area's editor type in place does exactly that, the new space composing before the old one is disposed. The
* slot then holds the OLD kind, its surface, and its camera, so a registration has to claim all three or the
* engine keeps drawing the UV page under a 2D viewport's gizmos (and frames the puppet with a page's pan and
* zoom). A registration of the same kind - a leaf rebuilt during a tree collapse - changes nothing here, so
* the surviving viewport keeps its view.
*
* Order matters to the render thread, which walks the slot map and can see this slot mid-claim. Becoming a
* UV scene, the content goes first and the kind second; becoming a puppet, the kind goes first and the
* content is cleared second - either way the area never reads as a UV scene with nothing to draw. The camera
* goes LAST: dropped before the kind, the render thread could re-establish the old surface's view in the gap
* and keep it. Dropped after, the worst it can do is render one frame of the new surface through the old
* camera, which the fresh camera then makes stale.
*
* @param AreaSlot slot The slot to claim.
* @param RenderScene scene The kind of area registering.
* @param UvSceneContent? content What a UV area draws; null for a puppet area.
* @param ContentBounds? islandExtent The shown meshes' bounds a UV area's fit takes in; null for a puppet area.
*/
private fun claim(slot: AreaSlot, scene: RenderScene, content: UvSceneContent?, islandExtent: ContentBounds?) {
val kindChanged = slot.scene != scene
when (scene) {
RenderScene.UvScene -> {
slot.uvIslandExtent = islandExtent
slot.uvContent = content
slot.scene = scene
}
RenderScene.Puppet2D -> {
slot.scene = scene
slot.uvContent = null
slot.uvIslandExtent = null
}
}
if (kindChanged) {
// The old surface's view stays remembered under its own key for the day the area switches back; this
// one is re-established from the new surface's remembered view, or a fit. The last frame goes too:
// it shows the old surface, and the new space's overlays would be drawn over it until the next lands.
slot.framing = null
slot.cameraState.value = null
slot.imageState.value = null
}
}
/**
* Retargets what an already-registered UV-editor area draws, and the mesh extent its fit takes in. A no-op
* for an unregistered area or a puppet (2D) area - only a registration moves an area between the puppet and
* the UV family, and this moves the content within the UV one.
*
* A switch to another page or layer changes no camera here: the render thread sees that the surface shown is
* no longer the one the camera frames and swaps the view as it establishes the next frame, so the new
* surface's first frame already renders through its own view (see [establishCamera]).
*
* @param String areaId The UV-editor area to retarget.
* @param UvSceneContent content The new content to draw.
* @param ContentBounds? islandExtent The shown meshes' display-space bounds, or null for none.
*/
fun setUvSceneContent(areaId: String, content: UvSceneContent, islandExtent: ContentBounds?) {
val slot = areas[areaId] ?: return
if (slot.scene == RenderScene.Puppet2D) {
return
}
applyUvContent(slot, content, islandExtent)
}
/**
* Publishes one UV content choice onto a slot, kind and payload inseparably, with the mesh extent measured
* over it.
*
* The content is one volatile store of one immutable value, which is what makes the switch atomic - see
* [AreaSlot.uvContent] for what publishing them separately would cost. The extent goes first, so a render
* thread that sees the new content also sees the extent that belongs to it.
*
* @param AreaSlot slot The slot to retarget.
* @param UvSceneContent content What the area draws.
* @param ContentBounds? islandExtent The shown meshes' display-space bounds, or null for none.
*/
private fun applyUvContent(slot: AreaSlot, content: UvSceneContent, islandExtent: ContentBounds?) {
slot.uvIslandExtent = islandExtent
slot.uvContent = content
}
/**
* Releases one hold on an area; the slot is dropped only when the last holder leaves (ref-count to zero).
* This guards the tree-collapse case: closing one split sibling rebuilds the surviving area's leaf under a
* fresh composition node, so its [register] runs BEFORE the old leaf's unregister - a plain remove here
* would delete the slot the rebuilt viewport just bound to, freezing it at a stale (stretched) frame. Any
* read-back already in flight for a truly-dropped slot still completes and is discarded when collected.
*
* @param String areaId The area id to release.
*/
fun unregister(areaId: String) {
val slot = areas[areaId] ?: return
slot.refCount--
if (slot.refCount <= 0) {
areas.remove(areaId)
}
}
/**
* Returns the flow of the area's current camera, for the overlay zoom readout. The viewport composable
* registers the area before reading this, so it attaches to the existing slot.
*
* @param String areaId The area id.
* @return StateFlow The area's camera stream (null until the first fit).
*/
fun cameraFlow(areaId: String): StateFlow<ViewportCamera?> =
areas.getOrPut(areaId) { AreaSlot() }.cameraState
/**
* Updates an area's requested pixel size; the render thread re-renders it at the new size. A no-op for an
* unregistered id - registration always precedes the size report, so resize must never resurrect a slot
* the ref-count has already dropped (that would leak a zero-ref slot the render loop renders forever).
*
* @param String areaId The area id.
* @param Int width The new width in pixels.
* @param Int height The new height in pixels.
*/
fun resize(areaId: String, width: Int, height: Int) {
val slot = areas[areaId] ?: return
slot.width = width
slot.height = height
}
/**
* Pans the area's camera by a screen-pixel drag (grab style). No-op before the initial fit exists.
*
* @param String areaId The area id.
* @param Float deltaXpx Horizontal drag in pixels.
* @param Float deltaYpx Vertical drag in pixels.
*/
fun pan(areaId: String, deltaXpx: Float, deltaYpx: Float) {
updateCamera(areaId) { camera -> camera.panByScreen(deltaXpx, deltaYpx) }
}
/**
* Zooms the area's camera about a cursor position (wheel zoom) by one configured step, pinning the world
* point under the cursor. The step (fine or coarse Shift step) comes from settings.
*
* @param String areaId The area id.
* @param Boolean zoomIn True to zoom in, false to zoom out.
* @param Boolean coarse Use the coarse (Shift) step.
* @param Float cursorXpx Cursor X in pixels.
* @param Float cursorYpx Cursor Y in pixels.
*/
fun zoomAtCursor(areaId: String, zoomIn: Boolean, coarse: Boolean, cursorXpx: Float, cursorYpx: Float) {
val slot = areas[areaId] ?: return
val width = slot.width
val height = slot.height
val step = stepFor(coarse)
val deltaPercent = if (zoomIn) step else -step
updateCamera(areaId) { camera ->
camera.zoomAtCursorByPercent(
deltaPercent,
step,
cursorXpx,
cursorYpx,
width,
height,
)
}
}
/**
* Frames a screen-pixel rectangle in the area's camera (Zoom Region / Shift+B): the box fills the
* viewport, letterboxed on the looser axis. A no-op before the first fit or when the area has no size yet.
*
* @param String areaId The area id.
* @param Float leftPx One horizontal box edge in viewport pixels.
* @param Float topPx One vertical box edge in viewport pixels.
* @param Float rightPx The other horizontal box edge in viewport pixels.
* @param Float bottomPx The other vertical box edge in viewport pixels.
*/
fun zoomToRegion(areaId: String, leftPx: Float, topPx: Float, rightPx: Float, bottomPx: Float) {
val slot = areas[areaId] ?: return
val width = slot.width
val height = slot.height
if (width <= 0 || height <= 0) {
return
}
updateCamera(areaId) { camera -> camera.framingScreenRect(leftPx, topPx, rightPx, bottomPx, width, height) }
}
/**
* Zooms the area's camera about its center (keyboard zoom in/out) by one configured step.
*
* @param String areaId The area id.
* @param Boolean zoomIn True to zoom in, false to zoom out.
* @param Boolean coarse Use the coarse (Shift) step.
*/
fun zoomCentered(areaId: String, zoomIn: Boolean, coarse: Boolean) {
val step = stepFor(coarse)
val deltaPercent = if (zoomIn) step else -step
updateCamera(areaId) { camera -> camera.zoomedByPercent(deltaPercent, step) }
}
/**
* Sets the area's camera to true 1:1 about its center (actual size / 100%).
*
* @param String areaId The area id.
*/
fun actualSize(areaId: String) {
updateCamera(areaId) { camera -> camera.withActualSize() }
}
/**
* Refits the area's camera to the content on the next render tick by flagging it - the render thread,
* which owns the content bounds and the current size, recomputes the fit in [establishCamera].
*
* @param String areaId The area id.
*/
fun fit(areaId: String) {
val slot = areas[areaId] ?: return
slot.refitRequested = true
}
/**
* Fits a world-space rectangle inside the area, centerd (the Frame Selected camera move). A no-op before
* the first fit or when the area has no size yet.
*
* @param String areaId The area id.
* @param Float minX The rectangle's minimum world x.
* @param Float minZ The rectangle's minimum world z (up).
* @param Float maxX The rectangle's maximum world x.
* @param Float maxZ The rectangle's maximum world z (up).
*/
fun fitWorldRect(areaId: String, minX: Float, minZ: Float, maxX: Float, maxZ: Float) {
val slot = areas[areaId] ?: return
val width = slot.width
val height = slot.height
if (width <= 0 || height <= 0 || maxX < minX || maxZ < minZ) {
return
}
// A degenerate rect (a single vertex) still frames: ContentBounds spans are clamped to >= 1 world unit
// by the fit, so the camera centers on the point at a sane zoom.
updateCamera(areaId) {
ViewportCamera.fit(ContentBounds(minX, minZ, maxX - minX, maxZ - minZ), width, height)
}
}
/**
* The camera and size of an area for a CPU pick, or null when the area is unregistered, unsized, or has
* no camera yet (before the first fit).
*
* @param String areaId The area id.
* @return AreaView The area's camera and pixel size, or null.
*/
fun viewFor(areaId: String): AreaView? {
val slot = areas[areaId] ?: return null
val camera = slot.camera ?: return null
return AreaView(camera, slot.width, slot.height)
}
/**
* Render-thread: ensures the slot has a camera for what it shows, establishing or refitting it now that the
* size is known. A pending refit forces a fresh fit. Otherwise a freshly-(re)registered area restores its
* remembered camera (so workspace switches preserve pan/zoom), and a UV-editor area whose shown page or
* layer is no longer the one its camera frames swaps to the view it left that surface with - either falling
* back to a fit the first time that surface is shown. The content bounds are resolved lazily (only when a
* fit is actually needed) via [contentBounds]; a UV-editor fit is widened to the shown meshes' extent.
*
* The kind and the content are read once, up front: the fit, the recall, and the record all have to be about
* the same surface, and the UI thread can retarget the slot at any moment. A retarget that lands after the
* read leaves a camera framing a surface no longer shown, which the next call swaps in turn.
*
* @param AreaSlot slot The area being established.
* @param String areaId The area id.
* @param Int width The current area width.
* @param Int height The current area height.
* @param Function contentBounds Supplies the rectangle of the scene and content it is handed, evaluated only
* when a fit is needed.
* @return ViewportCamera The area's current camera.
*/
fun establishCamera(
slot: AreaSlot,
areaId: String,
width: Int,
height: Int,
contentBounds: (RenderScene, UvSceneContent?) -> ContentBounds,
): ViewportCamera {
val scene = slot.scene
val content = slot.uvContent
val shownSurface =
when (scene) {
RenderScene.Puppet2D -> null
RenderScene.UvScene -> content?.surfaceId ?: UvSurfaceId.Page(null)
}
val framing = slot.framing
val refit = slot.refitRequested
if (framing != null && !refit && framing.surface == shownSurface) {
return framing.camera
}
val recalled = if (refit) null else recallCamera(areaId, scene, shownSurface)
val camera =
recalled ?: run {
val sceneBounds = contentBounds(scene, content)
// Read after the content: the UI thread writes the extent first, so it belongs to this content.
val fitBounds =
when (scene) {
RenderScene.Puppet2D -> sceneBounds
RenderScene.UvScene -> uvFitBounds(sceneBounds, slot.uvIslandExtent)
}
ViewportCamera.fit(fitBounds, width, height)
}
slot.refitRequested = false
publishCamera(slot, areaId, FramedCamera(camera, shownSurface))
return camera
}
/**
* The view an area had of a surface, for an area establishing one without a refit, or null when it has none
* and the surface is fitted.
*
* A UV-editor area takes its own view of that page or layer first. The area's whole-UV view - what a saved
* document seeds - stands in only while the area has shown no UV surface this session: until then it can only
* be the saved view, which belongs to whatever surface the area opens on. After that it is the last surface's
* view, and a different surface fits rather than inheriting it.
*
* @param String areaId The area id.
* @param RenderScene scene The area's kind.
* @param UvSurfaceId? surface The UV surface shown, or null for a puppet area.
* @return ViewportCamera? The view to restore, or null to fit.
*/
private fun recallCamera(areaId: String, scene: RenderScene, surface: UvSurfaceId?): ViewportCamera? {
if (surface == null) {
return rememberedCameras[AreaCameraKey(areaId, scene.cameraSurface)]
}
uvSurfaceCameras[AreaUvSurfaceKey(areaId, surface)]?.let { remembered ->
return remembered
}
if (areaId in uvShownAreaIds) {
return null
}
return rememberedCameras[AreaCameraKey(areaId, CameraSurface.Uv)]
}
/**
* Makes [framing] the slot's camera and remembers it: under the area and its surface kind (what a save writes
* and a workspace switch restores) and, for a UV-editor view, under the page or layer it frames. Keyed off the
* framing's own surface rather than the slot's current content, so a view is always filed with the surface it
* was taken of.
*
* @param AreaSlot slot The area's slot.
* @param String areaId The area id.
* @param FramedCamera framing The camera and the surface it frames.
*/
private fun publishCamera(slot: AreaSlot, areaId: String, framing: FramedCamera) {
slot.framing = framing
slot.cameraState.value = framing.camera
val surface = framing.surface
if (surface == null) {
rememberedCameras[AreaCameraKey(areaId, CameraSurface.Viewport)] = framing.camera
} else {
rememberedCameras[AreaCameraKey(areaId, CameraSurface.Uv)] = framing.camera
uvSurfaceCameras[AreaUvSurfaceKey(areaId, surface)] = framing.camera
uvShownAreaIds.add(areaId)
}
}
/** The zoom step in percentage points for this notch/press: the coarse (Shift) step or the fine step. */
private fun stepFor(coarse: Boolean): Float = if (coarse) zoomStepCoarsePercent else zoomStepPercent
/**
* Applies [transform] to the area's current camera and publishes the result, still framing the surface it
* framed. No-op before the initial fit (there is nothing to transform until the first frame establishes the
* view).
*
* @param String areaId The area id.
* @param Function transform Maps the current camera to its replacement.
*/
private fun updateCamera(areaId: String, transform: (ViewportCamera) -> ViewportCamera) {
val slot = areas[areaId] ?: return
val framing = slot.framing ?: return
publishCamera(slot, areaId, framing.copy(camera = transform(framing.camera)))
}
}
@@ -0,0 +1,240 @@
package org.umamo.editor.desktop.viewport
import androidx.compose.ui.graphics.ImageBitmap
import org.umamo.render.PuppetTextures
import org.umamo.render.ViewportCamera
import org.umamo.render.pick.PickCandidate
import org.umamo.render.pick.drawableCentroids
import org.umamo.render.pick.pickAllDrawables
import org.umamo.render.pick.pickDrawable
import org.umamo.render.pick.screenToWorldX
import org.umamo.render.pick.screenToWorldZ
import org.umamo.render.puppet.PuppetRenderer
import org.umamo.runtime.model.DrawableId
import org.umamo.runtime.model.PuppetModel
import org.umamo.runtime.model.atlasKeyByDrawable
import org.umamo.runtime.model.drawableNameByDrawable
import org.umamo.runtime.model.partNameByDrawable
import org.umamo.runtime.model.pickableIndicesByDrawable
import org.umamo.runtime.model.pickableUvsByDrawable
import org.umamo.ui.model.DrawableThumbnailProvider
import org.umamo.ui.model.DrawableThumbnailer
/**
* CPU-side hit-testing and art previews for the viewport, over the current deformed pose. Runs entirely on
* the UI thread and never touches GL: it reuses the renderer's pure-CPU pick geometry (a snapshot the render
* thread produces) and its resolved draw order, and the retained CPU atlas pixels for the alpha gate. The
* facade resolves each area's camera and size and forwards them here, so this class is area-agnostic.
*
* The model-derived lookup maps (pick indices / UVs, atlas keys, part labels) and the thumbnail provider are
* rebuilt by [updateModel] so session-created drawables (a duplicate's fresh ".001" id) and visibility edits
* stay pickable, sampleable, and labeled - maps frozen at construction would leave a duplicate unpickable.
*
* ビューポートの CPU ヒットテストとアートプレビュー。UI スレッドのみ、GL 不使用。
*
* @property PuppetRenderer renderer The renderer, for its pure-CPU pickGeometry() and drawnOrder().
* @property PuppetTextures textures The atlas pages, for the alpha gate and page sizes.
*/
internal class ViewportPicker(
private val renderer: PuppetRenderer,
// var: the session swaps the page set on a repack, and the alpha gate must sample the pixels the
// GPU is showing - see setTextures.
private var textures: PuppetTextures,
model: PuppetModel,
) {
// Per-drawable triangle indices for hit-testing, restricted to the drawables actually shown (the
// Parts-panel eyeball cascade) and to those carrying a triangle mesh. Picking iterates the pose's
// deformed positions and looks indices up here, so unshown / mesh-less drawables are never hit.
private var pickableIndices: Map<DrawableId, IntArray> = model.pickableIndicesByDrawable()
// Per-drawable UVs (full-atlas [0,1]) for the same pickable set, so picking can interpolate the hit
// point's UV and sample the atlas alpha (rejecting clicks on a mesh's transparent triangle overhang).
private var pickableUvs: Map<DrawableId, FloatArray> = model.pickableUvsByDrawable()
// Drawable id -> owning part name, for the overlap-picker row labels.
private var partNameByDrawableId: Map<DrawableId, String> = model.partNameByDrawable()
// Drawable id -> its own name, the other half of an overlap-picker row label.
private var drawableNameByDrawableId: Map<DrawableId, String> = model.drawableNameByDrawable()
// Drawable id -> atlas lookup key: the source-format id the atlas map is keyed by, resolved through
// textureSourceId so a duplicate samples its SOURCE's texels for the pick alpha gate.
private var atlasKeyByDrawableId: Map<DrawableId, String> = model.atlasKeyByDrawable()
// Art-mesh previews for the overlap picker (the same provider the Outliner hover uses). Pure CPU over
// the immutable atlas bytes, so it is built once and shared - a single cache across both consumers.
private val thumbnailer = DrawableThumbnailer(model, textures)
/**
* Swaps the atlas page set after a repack (or its undo), so the alpha gate and the thumbnails read
* the pixels the viewport is showing rather than the set the picker was built over.
*
* @param PuppetTextures next The new page set.
*/
fun setTextures(next: PuppetTextures) {
if (next === textures) {
return
}
textures = next
thumbnailer.setTextures(next)
}
/**
* Rebuilds the model-derived lookup maps and the thumbnail provider after a committed edit or undo, so
* session-created drawables and visibility edits stay pickable, sampleable, and labeled.
*
* @param PuppetModel model The current model.
*/
fun updateModel(model: PuppetModel) {
pickableIndices = model.pickableIndicesByDrawable()
pickableUvs = model.pickableUvsByDrawable()
partNameByDrawableId = model.partNameByDrawable()
drawableNameByDrawableId = model.drawableNameByDrawable()
atlasKeyByDrawableId = model.atlasKeyByDrawable()
thumbnailer.updateModel(model)
}
/**
* Hit-tests a viewport pixel against the current deformed pose and returns the FRONT-MOST opaque drawable
* under it, or null when the click misses or no pose is ready yet. Restricted to shown, meshed drawables;
* front/back uses the renderer's resolved draw order, and the transparent triangle overhang is rejected
* by the atlas-alpha gate.
*
* @param ViewportCamera camera The area's camera (screen-to-world inverse).
* @param Int width The area width in pixels.
* @param Int height The area height in pixels.
* @param Float cursorXpx Cursor X in pixels (top-left origin).
* @param Float cursorYpx Cursor Y in pixels (top-left origin).
* @return DrawableId The hit drawable, or null on a miss.
*/
fun pickAt(camera: ViewportCamera, width: Int, height: Int, cursorXpx: Float, cursorYpx: Float): DrawableId? {
if (width <= 0 || height <= 0) {
return null
}
val geometry = renderer.pickGeometry() ?: return null
// Screen (y-down) to world (y-up), the inverse of the camera's worldToNdc - see ScreenSpacePick.
val worldX = screenToWorldX(cursorXpx, camera, width)
val worldZ = screenToWorldZ(cursorYpx, camera, height)
return pickDrawable(
worldX,
worldZ,
geometry.worldPositions,
pickableIndices,
pickableUvs,
frontRankMap(),
::sampleTexelAlpha,
)
}
/**
* All opaque drawables under a viewport pixel, FRONT-TO-BACK with each one's centrality - for the
* Alt-click overlap-picker popup. Same screen-to-world, hit, and alpha gate as [pickAt].
*
* @param ViewportCamera camera The area's camera.
* @param Int width The area width in pixels.
* @param Int height The area height in pixels.
* @param Float cursorXpx Cursor X in pixels (top-left origin).
* @param Float cursorYpx Cursor Y in pixels (top-left origin).
* @return List The opaque candidates, front-to-back.
*/
fun pickAllAt(
camera: ViewportCamera,
width: Int,
height: Int,
cursorXpx: Float,
cursorYpx: Float,
): List<PickCandidate> {
if (width <= 0 || height <= 0) {
return emptyList()
}
val geometry = renderer.pickGeometry() ?: return emptyList()
val worldX = screenToWorldX(cursorXpx, camera, width)
val worldZ = screenToWorldZ(cursorYpx, camera, height)
return pickAllDrawables(
worldX,
worldZ,
geometry.worldPositions,
pickableIndices,
pickableUvs,
frontRankMap(),
::atlasSizeOf,
::sampleTexelAlpha,
)
}
/**
* Every visible drawable's world-space centroid at the current pose, for Object-mode region select. Reads
* the same posed pick geometry as [pickAt] and reduces each drawable to its centroid; empty before the
* first frame's geometry lands. Area-independent - the caller projects with its camera.
*
* @return Map The per-drawable [x, y] world centroid.
*/
fun drawableWorldCentroids(): Map<DrawableId, FloatArray> {
val geometry = renderer.pickGeometry() ?: return emptyMap()
return drawableCentroids(geometry.worldPositions)
}
/**
* A small preview of a drawable's art for the overlap-picker popup, delegated to the shared thumbnailer
* (the same provider the Outliner hover uses). Returns null for an untextured or mesh-less drawable.
*
* @param DrawableId id The drawable to preview.
* @return ImageBitmap The cropped preview, or null when untextured or mesh-less.
*/
fun thumbnailFor(id: DrawableId): ImageBitmap? = thumbnailer.thumbnailFor(id)
/** The shared art-mesh thumbnail provider, exposed so the host can wire it to the Outliner hover preview. */
fun thumbnails(): DrawableThumbnailProvider = thumbnailer
/**
* The name of the part a drawable belongs to, for the overlap-picker row labels, or null when the
* drawable sits at the root with no owning part.
*
* @param DrawableId id The drawable to look up.
* @return String The owning part's name, or null.
*/
fun partNameFor(id: DrawableId): String? = partNameByDrawableId[id]
/**
* A drawable's own display name, for the overlap-picker row labels, or null when it is not pickable
* in the current model.
*
* @param DrawableId id The drawable to look up.
* @return String The drawable's name, or null.
*/
fun drawableNameFor(id: DrawableId): String? = drawableNameByDrawableId[id]
/** The renderer's resolved back-to-front draw list as a front-rank map (higher index = more front). */
private fun frontRankMap(): Map<DrawableId, Float> =
renderer.drawnOrder().withIndex().associate { (index, id) -> id to index.toFloat() }
/** The drawable's atlas page size (width, height) in texels, or null when it is untextured. */
private fun atlasSizeOf(id: DrawableId): Pair<Int, Int>? =
textures.atlasIndexByDrawableId[atlasKeyByDrawableId[id] ?: id.raw]?.let { atlasIndex ->
textures.atlases.getOrNull(atlasIndex)?.let { image -> image.width to image.height }
}
/**
* The atlas-texel alpha (0..1) for a drawable at a full-atlas (u, v), or 1f when the drawable is
* untextured (a flat draw color, treated as fully opaque). Reads the retained CPU atlas pixels; the
* alpha byte is the coverage whether or not the atlas is premultiplied, so no un-premultiply is needed.
* A point off the page is transparent, as the renderer draws it: a mesh overhangs its art, and when the
* page is a single model image that overhang runs past the page itself.
*
* @param DrawableId id The drawable.
* @param Float u The full-atlas U.
* @param Float v The full-atlas V.
* @return Float The texel alpha, 0..1.
*/
private fun sampleTexelAlpha(id: DrawableId, u: Float, v: Float): Float {
val atlasIndex = textures.atlasIndexByDrawableId[atlasKeyByDrawableId[id] ?: id.raw] ?: return 1f
val image = textures.atlases.getOrNull(atlasIndex) ?: return 1f
if (!(u >= 0f && u < 1f && v >= 0f && v < 1f)) {
return 0f
}
val px = (u * image.width).toInt().coerceAtMost(image.width - 1)
val py = (v * image.height).toInt().coerceAtMost(image.height - 1)
val alpha = image.rgba[(py * image.width + px) * 4 + 3].toInt() and 0xFF
return alpha / 255f
}
}
@@ -0,0 +1,181 @@
package org.umamo.editor.desktop.packaging
import org.umamo.editor.desktop.isOpenableDocumentPath
import org.umamo.format.uma.Uma
import org.umamo.format.uma.UmaModel
import org.umamo.format.uma.UmaWriterInfo
import org.w3c.dom.Element
import java.io.ByteArrayOutputStream
import java.io.File
import java.util.zip.CRC32
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.xml.parsers.DocumentBuilderFactory
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
/**
* Holds every operating-system registration of the `.uma` type to the codec. The type is declared in four places
* no compiler connects - the freedesktop MIME entry, the desktop entry, the desktop package's build script, and the
* Android manifest - and a registration that names another string, or a magic rule that reads another offset,
* fails silently: the file manager just stops recognising the file. The magic is not compared to a table here,
* it is EVALUATED against the bytes the writer really produces (docs/format/UMA.md § 2).
*/
class OsAssociationFilesTest {
/** Gradle runs a module's tests from the module directory, which is what these paths are relative to. */
private val mimeEntry = File("resources/linux/umamo-uma.xml")
private val desktopEntry = File("resources/linux/umamo.desktop")
private val buildScript = File("build.gradle.kts")
private val androidManifest = File("../android/src/main/AndroidManifest.xml")
/** One `match` rule of a shared-mime-info magic: a string expected at an offset, and the rules nested under it. */
private class MagicRule(val offset: Int, val expected: ByteArray, val nested: List<MagicRule>)
/**
* The bytes a shared-mime-info `string` value denotes: C-style escapes, of which the entry uses the octal form.
*
* @param String value The attribute's text.
* @return ByteArray The bytes to find.
*/
private fun magicBytesOf(value: String): ByteArray {
val bytes = ByteArrayOutputStream()
var position = 0
while (position < value.length) {
if (value[position] == '\\' && position + 3 < value.length && value.substring(position + 1, position + 4).all { digit -> digit in '0'..'7' }) {
bytes.write(value.substring(position + 1, position + 4).toInt(8))
position += 4
} else {
bytes.write(value[position].code)
position++
}
}
return bytes.toByteArray()
}
/**
* The `match` rules directly under [parent], each with its own nested rules.
*
* @param Element parent A `magic` or `match` element.
* @return List<MagicRule> The rules.
*/
private fun rulesUnder(parent: Element): List<MagicRule> {
val rules = ArrayList<MagicRule>()
val children = parent.childNodes
for (childIndex in 0 until children.length) {
val child = children.item(childIndex) as? Element ?: continue
if (child.tagName == "match") {
assertEquals("string", child.getAttribute("type"), "the matcher below only evaluates string rules")
rules += MagicRule(child.getAttribute("offset").toInt(), magicBytesOf(child.getAttribute("value")), rulesUnder(child))
}
}
return rules
}
/**
* Whether [content] satisfies any of [rules]: a rule holds when its bytes sit at its offset AND, when it has
* nested rules, one of those holds too - the shared MIME database's own semantics.
*
* @param ByteArray content The file's bytes.
* @param List<MagicRule> rules The alternatives.
* @return Boolean True when one matches.
*/
private fun matches(content: ByteArray, rules: List<MagicRule>): Boolean =
rules.any { rule ->
val end = rule.offset + rule.expected.size
end <= content.size &&
content.copyOfRange(rule.offset, end).contentEquals(rule.expected) &&
(rule.nested.isEmpty() || matches(content, rule.nested))
}
/** The `mime-type` element of the committed entry. */
private fun mimeTypeElement(): Element {
val document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(mimeEntry)
return document.getElementsByTagName("mime-type").item(0) as Element
}
/**
* A ZIP whose first entry is a stored `mimetype` holding [mimetype] - the shape KRA, EPUB, and OpenDocument
* share with UMA - or a plain ZIP when [mimetype] is null.
*
* @param String? mimetype The first entry's content, or null for none.
* @return ByteArray The archive.
*/
private fun zipAnnouncing(mimetype: String?): ByteArray {
val bytes = ByteArrayOutputStream()
ZipOutputStream(bytes).use { zip ->
if (mimetype != null) {
val content = mimetype.toByteArray(Charsets.US_ASCII)
val entry = ZipEntry("mimetype")
entry.method = ZipEntry.STORED
entry.size = content.size.toLong()
entry.compressedSize = content.size.toLong()
entry.crc = CRC32().also { crc -> crc.update(content) }.value
zip.putNextEntry(entry)
zip.write(content)
zip.closeEntry()
}
zip.putNextEntry(ZipEntry("content.txt"))
zip.write("not a puppet".toByteArray())
zip.closeEntry()
}
return bytes.toByteArray()
}
/** The magic recognises what the writer writes, and nothing that merely looks like it. */
@Test
fun theFreedesktopMagicMatchesARealUmaAndNothingElse() {
val magic = mimeTypeElement().getElementsByTagName("magic").item(0) as Element
val rules = rulesUnder(magic)
val written = Uma.write(UmaModel.create(UmaWriterInfo("Umamo", "0.0.0-test")))
assertTrue(Uma.matches(written), "the codec's own probe accepts the file")
assertTrue(matches(written, rules), "and so does the freedesktop magic")
assertFalse(matches(zipAnnouncing(null), rules), "a plain ZIP is not a UMA")
assertFalse(matches(zipAnnouncing("application/x-krita"), rules), "nor is another format that announces itself the same way")
// The shared database gives application/zip's bare-signature magic 60 and its ZIP-based formats (EPUB,
// OpenDocument) 70. Above 60 so an extensionless .uma is not read as a plain ZIP; below 80, the level at
// which magic would outrank a file's NAME and a .uma renamed to .zip would stop opening as an archive.
val priority = magic.getAttribute("priority").toInt()
assertTrue(priority in 61..79, "priority $priority must sit above application/zip's 60 and below the name-outranking 80")
}
/** The entry names the codec's type, as a ZIP subtype, with the `.uma` glob. */
@Test
fun theFreedesktopEntryNamesTheCodecsType() {
val mimeType = mimeTypeElement()
assertEquals(Uma.MIME_TYPE, mimeType.getAttribute("type"))
assertEquals("application/zip", (mimeType.getElementsByTagName("sub-class-of").item(0) as Element).getAttribute("type"))
assertEquals("*.${Uma.kind.extension}", (mimeType.getElementsByTagName("glob").item(0) as Element).getAttribute("pattern"))
}
/** The desktop entry, the package's build script, and the Android manifest all name the same type and extension. */
@Test
fun everyRegistrationNamesTheSameType() {
val desktopLines = desktopEntry.readLines()
assertTrue("MimeType=${Uma.MIME_TYPE};" in desktopLines, "the desktop entry handles the type")
assertTrue(desktopLines.any { line -> line.startsWith("Exec=") && line.endsWith("%f") }, "and takes the file as an argument, which Main reads")
val script = buildScript.readText()
assertTrue("val umaMimeType = \"${Uma.MIME_TYPE}\"" in script, "the package's file association names the type")
assertTrue("val umaExtension = \"${Uma.kind.extension}\"" in script, "and the extension")
assertEquals(3, Regex("fileAssociation\\(umaMimeType, umaExtension,").findAll(script).count(), "declared for Windows, macOS, and Linux")
val manifest = androidManifest.readText()
assertTrue("android:mimeType=\"${Uma.MIME_TYPE}\"" in manifest, "the Android intent filter names the type")
assertTrue("android:pathSuffix=\".${Uma.kind.extension}\"" in manifest, "and the extension, for providers that report a generic type")
}
/** A path the OS hands over is accepted by extension alone, however it is cased; the loader checks the content. */
@Test
fun aHandedOverPathIsAcceptedByItsExtension() {
assertTrue(isOpenableDocumentPath("/home/rigger/Erica.uma"))
assertTrue(isOpenableDocumentPath("C:\\Rigs\\ERICA.UMA"))
assertTrue(isOpenableDocumentPath("/home/rigger/Erica.cmo3"))
assertTrue(isOpenableDocumentPath("/home/rigger/Erica.moc3"))
assertFalse(isOpenableDocumentPath("/home/rigger/Erica.psd"), "artwork is imported into a document, never opened as one")
assertFalse(isOpenableDocumentPath("--some-flag"))
}
}
@@ -0,0 +1,123 @@
package org.umamo.editor.desktop.viewport
import org.umamo.render.PuppetTextures
import org.umamo.runtime.model.AtlasPage
import org.umamo.runtime.model.PuppetAtlas
import org.umamo.runtime.model.PuppetModel
import org.umamo.ui.viewport.AtlasPageBinding
import kotlin.test.Test
import kotlin.test.assertNull
import kotlin.test.assertSame
/**
* Pins the render loop's model/pages pairing: an atlas-changing model is held until the binding
* composed for its atlas arrives (undo must never render repacked pixels under baseline
* coordinates), non-atlas edits pass untouched, and the baseline's equal-but-distinct atlas
* instance still pairs. Pure - the decision is exactly what the loop carries out.
*/
class AtlasPairingTest {
private fun modelWith(atlas: PuppetAtlas): PuppetModel =
PuppetModel(
parameters = emptyList(),
parts = emptyList(),
deformers = emptyList(),
drawables = emptyList(),
rootChildren = emptyList(),
rootPartId = null,
canvasWidth = 10f,
canvasHeight = 10f,
worldOriginX = 5f,
worldOriginZ = 5f,
atlas = atlas,
)
private fun bindingFor(atlas: PuppetAtlas): AtlasPageBinding =
AtlasPageBinding(atlas, PuppetTextures(emptyList(), emptyMap(), premultipliedAlpha = false))
private val baselineAtlas = PuppetAtlas(pages = listOf(AtlasPage(64, 64)))
private val repackedAtlas = PuppetAtlas(pages = listOf(AtlasPage(128, 128)))
@Test
fun aNonAtlasEditPassesUntouched() {
val baseline = modelWith(baselineAtlas)
val applied = bindingFor(baselineAtlas)
val edited = baseline.copy(canvasWidth = 20f)
val decision = resolveAtlasPairing(edited, applied, applied, baseline)
assertSame(edited, decision.orderModel, "a same-atlas model renders immediately")
assertNull(decision.applyBinding, "and swaps nothing")
}
@Test
fun anAtlasChangingModelWaitsForItsPages() {
val baseline = modelWith(baselineAtlas)
val applied = bindingFor(baselineAtlas)
val repacked = modelWith(repackedAtlas)
val held = resolveAtlasPairing(repacked, applied, applied, baseline)
assertSame(baseline, held.orderModel, "the previous pair keeps rendering while pages are in flight")
assertNull(held.applyBinding)
val newBinding = bindingFor(repackedAtlas)
val released = resolveAtlasPairing(repacked, newBinding, applied, baseline)
assertSame(repacked, released.orderModel, "the matching binding releases the hold")
assertSame(newBinding, released.applyBinding, "and the pages swap first")
}
@Test
fun undoHoldsUntilTheBaselinePagesComeBack() {
val baseline = modelWith(baselineAtlas)
val repacked = modelWith(repackedAtlas)
val repackedBinding = bindingFor(repackedAtlas)
val held = resolveAtlasPairing(baseline, repackedBinding, repackedBinding, repacked)
assertSame(repacked, held.orderModel, "baseline coordinates must not render against repacked pixels")
assertNull(held.applyBinding)
val baselineBinding = bindingFor(baselineAtlas)
val released = resolveAtlasPairing(baseline, baselineBinding, repackedBinding, repacked)
assertSame(baseline, released.orderModel)
assertSame(baselineBinding, released.applyBinding)
}
@Test
fun anEqualButDistinctBaselineAtlasStillPairs() {
// The session's baseline short-circuit can publish the baseline pages under an atlas instance
// that is equal to - but not identical with - the model's own.
val modelAtlasTwin = PuppetAtlas(pages = listOf(AtlasPage(64, 64)))
val model = modelWith(modelAtlasTwin)
val applied = bindingFor(repackedAtlas)
val baselineBinding = bindingFor(baselineAtlas)
val decision = resolveAtlasPairing(model, baselineBinding, applied, modelWith(repackedAtlas))
assertSame(model, decision.orderModel, "structural equality is enough to pair")
assertSame(baselineBinding, decision.applyBinding)
}
@Test
fun aBindingRepublishUnderTheCurrentAtlasAppliesAlone() {
// The resolver's derive-failure fallback republishes pages under the model's own atlas.
val model = modelWith(repackedAtlas)
val applied = bindingFor(repackedAtlas)
val republished = bindingFor(repackedAtlas)
val decision = resolveAtlasPairing(model, republished, applied, model)
assertSame(model, decision.orderModel)
assertSame(republished, decision.applyBinding, "new pages under an unchanged atlas still swap")
}
@Test
fun theFirstTickRendersThePublishedModelRegardless() {
val model = modelWith(repackedAtlas)
val applied = bindingFor(baselineAtlas)
val decision = resolveAtlasPairing(model, applied, applied, lastModel = null)
assertSame(model, decision.orderModel, "with no previous pair there is nothing to hold")
assertNull(decision.applyBinding)
}
}
@@ -0,0 +1,195 @@
package org.umamo.editor.desktop.viewport
import androidx.compose.ui.graphics.toPixelMap
import org.umamo.render.DecodedImage
import org.umamo.render.PuppetTextures
import org.umamo.runtime.model.AtlasPage
import org.umamo.runtime.model.BlendMode
import org.umamo.runtime.model.Drawable
import org.umamo.runtime.model.DrawableId
import org.umamo.runtime.model.DrawableMesh
import org.umamo.runtime.model.KeyformAxis
import org.umamo.runtime.model.KeyformCell
import org.umamo.runtime.model.KeyformGrid
import org.umamo.runtime.model.MeshDeltaForm
import org.umamo.runtime.model.OrgChild
import org.umamo.runtime.model.Parameter
import org.umamo.runtime.model.ParameterId
import org.umamo.runtime.model.PuppetAtlas
import org.umamo.runtime.model.PuppetModel
import org.umamo.runtime.model.visibleDrawableIds
import org.umamo.ui.viewport.AtlasPageBinding
import org.umamo.ui.viewport.LiveParams
import kotlin.test.Test
import kotlin.test.assertTrue
/**
* The live-repack integration gate, one level above the renderer: a real OffscreenPuppetService with
* its render thread and pairing loop, driven with the exact publish sequence the UI performs on a
* repack - setModel with a NEW atlas value, setAtlasPages with the binding composed for it - and
* then a plain UV edit. The UV edit is the point: after a page-count-changing repack, editing a
* mapping must still re-render (the modelG report: UV edits stopped updating the render after a
* 5-page document repacked to 2).
*
* Self-skips when no GL context can be created (no frame ever arrives).
*/
class AtlasSwapModelUpdateTest {
private val paramA = ParameterId("A")
private val probeId = DrawableId("SwapProbe")
// A 120x120 quad centered at the origin, keyed with one zero-delta form.
private val quadPositions = floatArrayOf(-60f, -60f, 60f, -60f, -60f, 60f, 60f, 60f)
private val quadIndices = intArrayOf(0, 1, 2, 1, 3, 2)
private fun quadUvs(centerU: Float, centerV: Float, halfSpan: Float = 0.2f): FloatArray =
floatArrayOf(
centerU - halfSpan,
centerV + halfSpan,
centerU + halfSpan,
centerV + halfSpan,
centerU - halfSpan,
centerV - halfSpan,
centerU + halfSpan,
centerV - halfSpan,
)
private fun solidImage(red: Int, green: Int, blue: Int, size: Int = 16): DecodedImage {
val rgba = ByteArray(size * size * 4)
for (pixel in rgba.indices step 4) {
rgba[pixel] = red.toByte()
rgba[pixel + 1] = green.toByte()
rgba[pixel + 2] = blue.toByte()
rgba[pixel + 3] = 0xFF.toByte()
}
return DecodedImage(rgba, size, size)
}
/** A 16x16 page whose left half is blue and right half is white. */
private fun blueWhiteImage(): DecodedImage {
val size = 16
val rgba = ByteArray(size * size * 4)
for (rowIndex in 0 until size) {
for (columnIndex in 0 until size) {
val pixel = (rowIndex * size + columnIndex) * 4
val white = columnIndex >= size / 2
rgba[pixel] = if (white) 0xFF.toByte() else 0x00
rgba[pixel + 1] = if (white) 0xFF.toByte() else 0x00
rgba[pixel + 2] = 0xFF.toByte()
rgba[pixel + 3] = 0xFF.toByte()
}
}
return DecodedImage(rgba, size, size)
}
private fun modelWith(atlas: PuppetAtlas, uvs: FloatArray): PuppetModel {
val drawable =
Drawable(
id = probeId,
name = "SwapProbe",
parentDeformerId = null,
blendMode = BlendMode.Normal,
maskedBy = emptyList(),
mesh = DrawableMesh(quadPositions.copyOf(), uvs, quadIndices),
geometryGrid =
KeyformGrid(
listOf(KeyformAxis(paramA, floatArrayOf(0f))),
listOf(KeyformCell(intArrayOf(0), MeshDeltaForm(FloatArray(quadPositions.size)))),
),
)
return PuppetModel(
parameters = listOf(Parameter(paramA, "A", -1f, 1f, 0f)),
parts = emptyList(),
deformers = emptyList(),
drawables = listOf(drawable),
rootChildren = listOf(OrgChild.Drawable(drawable.id)),
rootPartId = null,
atlas = atlas,
)
}
/** Waits until the area publishes a frame satisfying [accept], or returns null on timeout. */
private fun awaitFrame(
frames: kotlinx.coroutines.flow.StateFlow<org.umamo.ui.viewport.RenderedFrame?>,
deadlineMillis: Long = 5_000,
accept: (androidx.compose.ui.graphics.PixelMap) -> Boolean,
): Boolean {
val start = System.currentTimeMillis()
while (System.currentTimeMillis() - start < deadlineMillis) {
val frame = frames.value
if (frame != null && accept(frame.bitmap.toPixelMap())) {
return true
}
Thread.sleep(20)
}
return false
}
private fun centerChannelDominates(pixels: androidx.compose.ui.graphics.PixelMap, channel: String): Boolean {
val color = pixels[pixels.width / 2, pixels.height / 2]
val red = color.red
val green = color.green
val blue = color.blue
return when (channel) {
"red" -> red > green + 0.25f && red > blue + 0.25f
"blue" -> blue > red + 0.25f && blue > green + 0.25f
"white" -> red > 0.7f && green > 0.7f && blue > 0.7f
else -> false
}
}
@Test
fun aUvEditAfterAPageCountChangingRepackStillRerenders() {
val baselineAtlas = PuppetAtlas(pages = listOf(AtlasPage(16, 16)))
val baselineModel = modelWith(baselineAtlas, quadUvs(0.5f, 0.5f))
val baselineTextures = PuppetTextures(listOf(solidImage(0xFF, 0x00, 0x00)), mapOf(probeId.raw to 0), false)
val service = OffscreenPuppetService(baselineModel, baselineTextures, LiveParams(emptyMap()))
service.start()
try {
val frames = service.register("area")
service.resize("area", 100, 100)
val sawBaseline = awaitFrame(frames) { pixels -> centerChannelDominates(pixels, "red") }
if (!sawBaseline) {
println("[atlas-swap-live] no GL frame arrived; skipping (context unavailable, or baseline never rendered)")
return
}
// The repack, in the UI's publish order: the committed model first (the session collector),
// then the binding composed for its atlas (the resolver). Page count changes 1 -> 2 and the
// probe moves to page 1, whose LEFT half is blue.
val repackedAtlas = PuppetAtlas(pages = listOf(AtlasPage(16, 16), AtlasPage(16, 16)))
val repackedModel = modelWith(repackedAtlas, quadUvs(0.25f, 0.5f))
val repackedTextures =
PuppetTextures(
listOf(solidImage(0x00, 0xFF, 0x00), blueWhiteImage()),
mapOf(probeId.raw to 1),
false,
)
service.setModel(repackedModel)
service.setShownDrawables(repackedModel.visibleDrawableIds())
service.setAtlasPages(AtlasPageBinding(repackedAtlas, repackedTextures))
assertTrue(
awaitFrame(frames) { pixels -> centerChannelDominates(pixels, "blue") },
"the repacked pair must render (probe on page 1's blue half)",
)
// The UV edit: same atlas instance, the mapping moves to the WHITE half. This is the exact
// gesture the modelG report says stops updating the render.
val editedModel =
repackedModel.copy(
drawables =
listOf(
repackedModel.drawables.single().let { drawable ->
drawable.copy(mesh = DrawableMesh(drawable.mesh!!.positions, quadUvs(0.75f, 0.5f), drawable.mesh!!.indices))
},
),
)
service.setModel(editedModel)
assertTrue(
awaitFrame(frames) { pixels -> centerChannelDominates(pixels, "white") },
"a UV edit after the repack must re-render (probe moved to page 1's white half)",
)
} finally {
service.dispose()
}
}
}
@@ -0,0 +1,361 @@
package org.umamo.editor.desktop.viewport
import org.umamo.render.ContentBounds
import org.umamo.render.DecodedImage
import org.umamo.render.ViewportCamera
import org.umamo.ui.viewport.AreaCameraKey
import org.umamo.ui.viewport.CameraSurface
import org.umamo.ui.viewport.UvSceneContent
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertNull
import kotlin.test.assertTrue
/**
* Pins how an area's scene routing is published, which decides what the render loop draws it as and
* which content bounds its camera fits.
*
* These are pure state assertions - no GL, no render thread - because the routing is pure state. The
* engine reads exactly these fields to choose between drawing the posed puppet and drawing a flat UV
* surface, so a slot that reads as the wrong kind sends an area to the wrong renderer and fits it to
* the wrong bounds, which shows up as artwork that is simply in the wrong place.
*/
class ViewportAreaRegistryTest {
private fun image(width: Int = 4, height: Int = 4): DecodedImage =
DecodedImage(ByteArray(width * height * 4), width, height)
/**
* A registered UV area reads as a UV scene, not as a puppet.
*
* The regression this exists for: the kind and the content were once published as separate fields,
* and collapsing them into one value dropped the kind write. Every UV area then still read as
* Puppet2D, so the engine fit each one to the PUPPET's rest bounds instead of the page rectangle and
* the atlas landed far off origin - while every existing test stayed green, because nothing covered
* this routing at all.
*/
@Test
fun registeringAUvSceneMarksTheAreaAsUv() {
val registry = ViewportAreaRegistry()
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
val slot = registry.areas.getValue("uv")
assertEquals(RenderScene.UvScene, slot.scene, "a UV area must not read as a puppet area")
assertEquals(UvSceneContent.AtlasPage(0), slot.uvContent, "and it carries the content it registered with")
}
/** A puppet area stays a puppet area, and carries no UV surface. */
@Test
fun registeringAPuppetAreaLeavesItAPuppet() {
val registry = ViewportAreaRegistry()
registry.register("puppet")
val slot = registry.areas.getValue("puppet")
assertEquals(RenderScene.Puppet2D, slot.scene, "the puppet area keeps the puppet scene")
assertNull(slot.uvContent, "and has no UV surface to draw")
}
/**
* Retargeting a UV area replaces its whole surface, kind and payload together.
*
* A page and a layer are addressed differently - one by index into the document's uploaded pages,
* one by pixels the engine has never seen - so a switch that carried over half of the old choice
* would draw one surface while the freshness test spoke for the other.
*/
@Test
fun retargetingReplacesTheWholeSurface() {
val registry = ViewportAreaRegistry()
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
val slot = registry.areas.getValue("uv")
val layer = image()
registry.setUvSceneContent("uv", UvSceneContent.SourceLayer("layer", layer), null)
assertEquals(UvSceneContent.SourceLayer("layer", layer), slot.uvContent, "the layer view replaces the page view whole")
assertEquals(RenderScene.UvScene, slot.scene, "and it is still a UV area")
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(2), null)
assertEquals(UvSceneContent.AtlasPage(2), slot.uvContent, "and switching back replaces it whole again")
}
/**
* Retargeting never turns a puppet area into a UV one.
*
* The puppet / UV split is fixed at registration; only the surface within the UV family moves.
*/
@Test
fun retargetingIgnoresAPuppetArea() {
val registry = ViewportAreaRegistry()
registry.register("puppet")
registry.setUvSceneContent("puppet", UvSceneContent.AtlasPage(1), null)
val slot = registry.areas.getValue("puppet")
assertEquals(RenderScene.Puppet2D, slot.scene, "a puppet area is not retargetable into a UV scene")
assertNull(slot.uvContent, "and takes on no UV surface")
}
/** An unregistered area is a no-op rather than a crash, since requests can outlive their area. */
@Test
fun retargetingAnUnknownAreaDoesNothing() {
val registry = ViewportAreaRegistry()
registry.setUvSceneContent("gone", UvSceneContent.AtlasPage(0), null)
assertTrue(registry.areas.isEmpty(), "no slot is conjured for an area that never registered")
}
/**
* A UV area survives the register-before-unregister overlap a tree collapse produces.
*
* Closing a split sibling rebuilds the surviving area's leaf under a fresh composition node, so the
* new register runs BEFORE the old unregister. The slot must still be a UV area afterwards.
*/
@Test
fun aReRegisteredUvAreaSurvivesTheOverlap() {
val registry = ViewportAreaRegistry()
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
registry.registerUvScene("uv", UvSceneContent.AtlasPage(1), null)
registry.unregister("uv")
val slot = registry.areas.getValue("uv")
assertEquals(RenderScene.UvScene, slot.scene, "the surviving hold keeps the area a UV scene")
assertEquals(UvSceneContent.AtlasPage(1), slot.uvContent, "with the content the rebuilt leaf registered")
}
/**
* Switching an area's editor type in place - the UV editor to the 2D viewport - hands the slot to the new space.
*
* The new space registers BEFORE the old one releases (it composes first), so the slot never drops to zero and
* is reused as it stands: still a UV scene, still holding the page, still on the page's camera. Left that way
* the engine keeps drawing the atlas page under the 2D viewport's gizmos, framed by a pan and zoom that mean
* nothing in the puppet's world. A registration claims all three.
*/
@Test
fun switchingAUvEditorToAViewportInPlaceRetargetsTheSlot() {
val registry = ViewportAreaRegistry()
val pageBounds = ContentBounds(0f, 0f, 4096f, 4096f)
val puppetBounds = ContentBounds(-600f, -900f, 1200f, 1800f)
registry.registerUvScene("area", UvSceneContent.AtlasPage(0), null)
val slot = registry.areas.getValue("area")
val pageCamera = registry.establishCamera(slot, "area", 800, 600) { _, _ -> pageBounds }
// The space switch: the viewport registers while the UV editor still holds the area, then the editor lets go.
registry.register("area")
registry.unregister("area")
assertEquals(slot, registry.areas["area"], "the slot survives the switch - the area never went unheld")
assertEquals(RenderScene.Puppet2D, slot.scene, "and now reads as a puppet area")
assertNull(slot.uvContent, "with no UV surface left to draw")
assertNull(slot.camera, "and no camera, so the engine establishes the puppet's view")
assertNull(slot.imageState.value, "and no last frame of the page to show under the viewport's overlays")
val puppetCamera = registry.establishCamera(slot, "area", 800, 600) { _, _ -> puppetBounds }
assertEquals(ViewportCamera.fit(puppetBounds, 800, 600), puppetCamera, "the puppet is fitted, not framed by the page's camera")
// And back: each surface kept its own view for the area.
registry.registerUvScene("area", UvSceneContent.AtlasPage(0), null)
registry.unregister("area")
assertEquals(RenderScene.UvScene, slot.scene)
assertEquals(pageCamera, registry.establishCamera(slot, "area", 800, 600) { _, _ -> error("the page's view is remembered, not refitted") })
}
/**
* A leaf rebuilt for the SAME space - a tree collapse registers the survivor again before its old leaf releases -
* keeps its camera and its frame: only a change of kind is a claim.
*/
@Test
fun reRegisteringTheSameSpaceKeepsTheView() {
val registry = ViewportAreaRegistry()
registry.register("area")
val slot = registry.areas.getValue("area")
val camera = registry.establishCamera(slot, "area", 800, 600) { _, _ -> ContentBounds(0f, -100f, 100f, 100f) }
registry.register("area")
registry.unregister("area")
assertEquals(camera, slot.camera)
assertEquals(camera, slot.cameraState.value)
}
/**
* A camera seeded before an area registers is the one the area opens on, in place of a fit - how a saved
* document reopens each area on the view it was left with (docs/format/UMA.md § 7.3). A seed is for one
* surface: the same area showing the other surface fits instead.
*/
@Test
fun aSeededCameraIsWhatTheAreaOpensOn() {
val registry = ViewportAreaRegistry()
val saved = ViewportCamera(120f, -340f, 2.5f)
registry.seedCameras(
mapOf(
AreaCameraKey("viewport", CameraSurface.Viewport) to saved,
AreaCameraKey("never-shown", CameraSurface.Viewport) to ViewportCamera(1f, 1f, 1f),
AreaCameraKey("now-a-uv-editor", CameraSurface.Viewport) to ViewportCamera(2f, 2f, 2f),
),
)
registry.register("viewport")
registry.register("fresh")
registry.registerUvScene("now-a-uv-editor", UvSceneContent.AtlasPage(0), null)
val fitBounds = ContentBounds(0f, -100f, 100f, 100f)
val restored = registry.establishCamera(registry.areas.getValue("viewport"), "viewport", 800, 600) { _, _ -> error("a seeded area must not fit") }
val fitted = registry.establishCamera(registry.areas.getValue("fresh"), "fresh", 800, 600) { _, _ -> fitBounds }
val otherSurface = registry.establishCamera(registry.areas.getValue("now-a-uv-editor"), "now-a-uv-editor", 800, 600) { _, _ -> fitBounds }
assertEquals(saved, restored)
assertEquals(ViewportCamera.fit(fitBounds, 800, 600), fitted, "an area with nothing saved fits its content, as before")
assertEquals(ViewportCamera.fit(fitBounds, 800, 600), otherSurface, "a view saved for the puppet is not applied to a texture")
assertEquals(ViewportCamera(2f, 2f, 2f), registry.cameras()[AreaCameraKey("now-a-uv-editor", CameraSurface.Viewport)], "and stays remembered for the day the area shows a viewport again")
assertTrue(AreaCameraKey("never-shown", CameraSurface.Viewport) in registry.cameras(), "every remembered camera is readable for the next save")
}
/** Seeding never moves an area that already has a camera: it is for the moment the engine is built. */
@Test
fun seedingLeavesAnEstablishedCameraAlone() {
val registry = ViewportAreaRegistry()
registry.register("viewport")
val established = registry.establishCamera(registry.areas.getValue("viewport"), "viewport", 800, 600) { _, _ -> ContentBounds(0f, -100f, 100f, 100f) }
registry.seedCameras(mapOf(AreaCameraKey("viewport", CameraSurface.Viewport) to ViewportCamera(9f, 9f, 9f)))
assertEquals(established, registry.cameras()[AreaCameraKey("viewport", CameraSurface.Viewport)])
}
/**
* A UV editor keeps a view per page and layer. Switching to one it has never shown fits that surface rather
* than carrying the page's pan and zoom over it - a layer a fraction of the page's size would land tiny and in a
* corner - and switching back brings back the view the first one was left with.
*/
@Test
fun eachSurfaceKeepsItsOwnView() {
val registry = ViewportAreaRegistry()
val pageBounds = ContentBounds(0f, 0f, 4096f, 4096f)
val layerBounds = ContentBounds(0f, 0f, 300f, 200f)
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
val slot = registry.areas.getValue("uv")
registry.establishCamera(slot, "uv", 800, 600) { _, _ -> pageBounds }
registry.pan("uv", 40f, -25f)
val pannedPage = slot.camera
val layerContent = UvSceneContent.SourceLayer("layer-1", image(300, 200))
registry.setUvSceneContent("uv", layerContent, null)
assertEquals(pannedPage, slot.camera, "a retarget moves no camera by itself - the render thread swaps it with the next frame")
val layerView =
registry.establishCamera(slot, "uv", 800, 600) { _, content ->
assertEquals(layerContent, content, "the fit is of the content the swap files the view under")
layerBounds
}
assertEquals(ViewportCamera.fit(layerBounds, 800, 600), layerView, "a layer the area has never shown is fitted")
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(0), null)
assertEquals(pannedPage, registry.establishCamera(slot, "uv", 800, 600) { _, _ -> error("the page's view is remembered, not refitted") })
registry.setUvSceneContent("uv", UvSceneContent.SourceLayer("layer-1", image(300, 200)), null)
assertEquals(layerView, registry.establishCamera(slot, "uv", 800, 600) { _, _ -> error("a layer is known by its key, not its pixels") })
}
/** Two UV editors keep their own views: one's view of a page is not what the other opens that page on. */
@Test
fun twoAreasKeepSeparateViewsOfOnePage() {
val registry = ViewportAreaRegistry()
val pageBounds = ContentBounds(0f, 0f, 1024f, 1024f)
registry.registerUvScene("top", UvSceneContent.AtlasPage(1), null)
registry.registerUvScene("bottom", UvSceneContent.AtlasPage(0), null)
val top = registry.areas.getValue("top")
val bottom = registry.areas.getValue("bottom")
registry.establishCamera(top, "top", 800, 300) { _, _ -> pageBounds }
registry.zoomCentered("top", zoomIn = true, coarse = true)
registry.establishCamera(bottom, "bottom", 800, 300) { _, _ -> pageBounds }
registry.setUvSceneContent("bottom", UvSceneContent.AtlasPage(1), null)
assertEquals(ViewportCamera.fit(pageBounds, 800, 300), registry.establishCamera(bottom, "bottom", 800, 300) { _, _ -> pageBounds })
assertNotEquals(top.camera, bottom.camera, "and the top area's zoom stays its own")
}
/**
* An area put away by a workspace tab switch and brought back showing another surface - its selection moved
* while it was away - opens on that surface's view, or a fit, never on the last view it had of the old one.
*/
@Test
fun aReturningAreaOnAnotherSurfaceTakesThatSurfacesView() {
val registry = ViewportAreaRegistry()
val pageBounds = ContentBounds(0f, 0f, 2048f, 2048f)
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
registry.establishCamera(registry.areas.getValue("uv"), "uv", 800, 600) { _, _ -> pageBounds }
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(1), null)
registry.establishCamera(registry.areas.getValue("uv"), "uv", 800, 600) { _, _ -> pageBounds }
registry.zoomCentered("uv", zoomIn = true, coarse = true)
val secondPageView = registry.areas.getValue("uv").camera
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(0), null)
registry.establishCamera(registry.areas.getValue("uv"), "uv", 800, 600) { _, _ -> error("the first page's view is remembered") }
registry.pan("uv", 120f, 0f)
// The tab switch drops the slot; the area comes back following a selection now on the second page.
registry.unregister("uv")
assertNull(registry.areas["uv"], "the slot is gone while its workspace is away")
registry.registerUvScene("uv", UvSceneContent.AtlasPage(1), null)
val returned = registry.establishCamera(registry.areas.getValue("uv"), "uv", 800, 600) { _, _ -> error("the second page's view is remembered") }
assertEquals(secondPageView, returned)
assertEquals(secondPageView, registry.cameras()[AreaCameraKey("uv", CameraSurface.Uv)], "and it is the view a save now writes")
registry.unregister("uv")
registry.registerUvScene("uv", UvSceneContent.SourceLayer("never-shown", image(64, 64)), null)
val layerBounds = ContentBounds(0f, 0f, 64f, 64f)
assertEquals(ViewportCamera.fit(layerBounds, 800, 600), registry.establishCamera(registry.areas.getValue("uv"), "uv", 800, 600) { _, _ -> layerBounds })
}
/**
* A saved document's UV view belongs to the surface the area opens on. Once the area has shown a surface this
* session, a surface it has not shown fits instead of inheriting the saved view.
*/
@Test
fun aSeededUvViewBelongsToTheFirstSurfaceShown() {
val registry = ViewportAreaRegistry()
val saved = ViewportCamera(300f, 200f, 0.5f)
val pageBounds = ContentBounds(0f, 0f, 1024f, 1024f)
registry.seedCameras(mapOf(AreaCameraKey("uv", CameraSurface.Uv) to saved))
registry.registerUvScene("uv", UvSceneContent.AtlasPage(3), null)
val slot = registry.areas.getValue("uv")
assertEquals(saved, registry.establishCamera(slot, "uv", 800, 600) { _, _ -> error("the saved view is what the area opens on") })
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(0), null)
assertEquals(ViewportCamera.fit(pageBounds, 800, 600), registry.establishCamera(slot, "uv", 800, 600) { _, _ -> pageBounds })
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(3), null)
assertEquals(saved, registry.establishCamera(slot, "uv", 800, 600) { _, _ -> error("and the opening page keeps it") })
}
/** A save sees one UV view per area, the shown surface's: the views kept for the other surfaces are session state. */
@Test
fun aSaveSeesOnlyTheShownSurfacesView() {
val registry = ViewportAreaRegistry()
val layerBounds = ContentBounds(0f, 0f, 300f, 200f)
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), null)
val slot = registry.areas.getValue("uv")
registry.establishCamera(slot, "uv", 800, 600) { _, _ -> ContentBounds(0f, 0f, 4096f, 4096f) }
registry.pan("uv", 10f, 10f)
registry.setUvSceneContent("uv", UvSceneContent.SourceLayer("layer-1", image(300, 200)), null)
val layerView = registry.establishCamera(slot, "uv", 800, 600) { _, _ -> layerBounds }
assertEquals(mapOf(AreaCameraKey("uv", CameraSurface.Uv) to layerView), registry.cameras())
}
/**
* A UV editor's fit frames the page, widened to every shown mesh that reaches past it: a placement moved off the
* page carries its islands with it, and a fit of the page alone would frame everything but what was just moved.
*/
@Test
fun aFitTakesInMeshesPastThePageEdge() {
val pageBounds = ContentBounds(0f, 0f, 1024f, 1024f)
val spilled = ContentBounds(900f, -300f, 600f, 400f)
val widened = ContentBounds(0f, -300f, 1500f, 1324f)
assertEquals(widened, uvFitBounds(pageBounds, spilled))
assertEquals(pageBounds, uvFitBounds(pageBounds, ContentBounds(10f, 10f, 20f, 20f)), "meshes inside the page leave the page fit alone")
assertEquals(pageBounds, uvFitBounds(pageBounds, null), "as does a surface with no meshes")
val registry = ViewportAreaRegistry()
registry.registerUvScene("uv", UvSceneContent.AtlasPage(0), spilled)
val slot = registry.areas.getValue("uv")
assertEquals(ViewportCamera.fit(widened, 800, 600), registry.establishCamera(slot, "uv", 800, 600) { _, _ -> pageBounds }, "the first fit takes the spill in")
registry.setUvSceneContent("uv", UvSceneContent.AtlasPage(0), ContentBounds(10f, 10f, 20f, 20f))
registry.fit("uv")
assertEquals(ViewportCamera.fit(pageBounds, 800, 600), registry.establishCamera(slot, "uv", 800, 600) { _, _ -> pageBounds }, "and Fit View follows the meshes back inside")
}
}
+172
View File
@@ -0,0 +1,172 @@
// Root build script. Plugins are declared here with `apply false` purely to pin their
// versions for the whole build; each module opts in by `alias(...)`-ing the ones it needs.
// This avoids every module repeating version numbers (the version catalog holds those).
// ルートビルドスクリプト。プラグインは `apply false` でバージョン固定のみを行い、各モジュールが
// 必要なものを `alias(...)` で取り込む。
plugins {
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.composeCompiler) apply false
alias(libs.plugins.composeMultiplatform) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidKmpLibrary) apply false
alias(libs.plugins.ktlint)
}
// Apply ktlint to every subproject so tab-based style (see .editorconfig) is enforced
// uniformly. ktlint reads .editorconfig, so no rule config is needed here.
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
// Compose Multiplatform generates Kotlin under build/generated (JetBrains space-indent style); lint
// our own sources, not generated output (e.g. the resources `Res` collectors).
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
filter {
exclude { element -> element.file.path.contains("/generated/") }
}
}
// Name every test as it runs, and print failures in full.
//
// Gradle's defaults report a passing run as a single count, which is the one shape this build must
// not have: the corpus- and GL-gated tests self-skip when their input is missing, and "239 tests
// completed" reads identically whether the GL suite rendered pixels or sat out the whole run. Naming
// passed AND skipped tests is what tells those two apart in a CI log.
//
// FULL rather than the default SHORT because SHORT prints only "AssertionError at File.kt:120" and
// drops the message - which is where a failure says what it actually was (HeadlessGlGate puts the
// GLFW error code and description there). Standard streams stay off: the tests print per-pixel
// diagnostics that would bury everything else.
tasks.withType<Test>().configureEach {
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
}
// Keeps the common source sets free of JVM-only APIs.
//
// This is NOT redundant with the compiler. Every target today is JVM-based (desktop JVM +
// Android/ART), so the common source set resolves `java.*` and the `kotlin.jvm.*` default import
// perfectly happily — a commonMain file can call java.util.zip and still compile. That only
// stops being true the day a non-JVM target (Kotlin/Native, for iPadOS) is added, at which point
// every accumulated leak surfaces at once, in code nobody has touched for months. This task
// turns that latent debt into an immediate failure instead.
//
// commonTest is in scope too, and deliberately: it has to compile for every target its commonMain
// does, so a JVM-only API there is the same latent break, and a test source set is exactly where one
// slips in unnoticed (a test that only ever runs on the JVM still has to *build* everywhere). It is
// also where the leaks were: `"ABCD".toByteArray(Charsets.US_ASCII)` in a shared test reads as
// harmless until the day it isn't.
//
// Three rules, each from a real leak found in this tree. Note that none of them is only about imports:
// the JVM's default imports (`java.lang.*`, `kotlin.jvm.*`, `kotlin.text.Charsets`) mean JVM-only APIs
// can appear with no import line to grep for, and even a non-default API can be written out in full at
// the use site — `catch (_: java.util.zip.DataFormatException)` needs no import and was exactly how the
// old ClipRaster reached zlib.
// 1. No `java.*` / `javax.*`, whether imported or spelled out at the use site — put the code in
// jvmAndroidMain, or hide the platform behind an expect/actual (see
// org.umamo.format.clip.useClipDatabase for the pattern). Reach for a common-code library
// before either: okio covers DEFLATE and buffers, which is how org.umamo.format.binary.Deflate
// retired the expect/actual it used to need.
// 2. `@Jvm*` annotations must be imported explicitly from `kotlin.jvm`. They are optional
// expectations, so non-JVM targets ignore them — but `kotlin.jvm.*` is a default import only
// on JVM, so an unimported `@JvmInline` is an unresolved reference off-JVM.
// 3. No `Charsets` — `kotlin.text.Charsets` is JVM-only, so `String(bytes, US_ASCII)` and
// `toByteArray(UTF_16BE)` do not exist off-JVM. Use org.umamo.format.binary.BinaryText, or
// `encodeToByteArray()` when the bytes really are meant to be UTF-8.
// (`decodeToString()` is NOT a general substitute: it is UTF-8 only.)
//
// This check is a net, not a proof: it catches the leak classes we have actually hit. The definitive
// check is compiling against a real non-JVM target — and `:format` now does exactly that: it carries
// an `iosArm64()` target, so its commonMain purity is a compiler guarantee and this task is only a
// faster pre-check there. (The two blockers this note used to name — CArrayList/CHashMap extending
// java.util collections — were resolved by delegating instead of inheriting.) Every other module is
// still JVM-only, and for those this task remains the only thing holding the line; the way to upgrade
// one is to copy :format's target, not to grow this regex.
val commonSources =
fileTree(rootDir) {
include(
"module/*/src/commonMain/**/*.kt",
"module/*/src/commonTest/**/*.kt",
"app/*/src/commonMain/**/*.kt",
"app/*/src/commonTest/**/*.kt",
)
}
val checkCommonSourcePurity =
tasks.register("checkCommonSourcePurity") {
group = "verification"
description = "Fails if any module's commonMain/commonTest uses a JVM-only API, which would break a future Kotlin/Native target."
inputs.files(commonSources).withPropertyName("commonSources")
// A marker output, so a green run stays UP-TO-DATE instead of re-reading every common source
// file on every `check`. The task's real product is the failure, not the file.
val report = layout.buildDirectory.file("reports/commonSourcePurity.txt")
outputs.file(report).withPropertyName("report")
val sourceFiles = commonSources
val repositoryRoot = rootDir
doLast {
val jvmImport = Regex("""^import (java|javax)\.""")
// Qualified use with no import: `catch (_: java.util.zip.DataFormatException)`. The
// lookbehind keeps `org.foo.java.Bar` and an identifier ending in "java" from matching.
val jvmQualifiedUse = Regex("""(?<![A-Za-z0-9_.$])(java|javax)\.[a-z][A-Za-z0-9_]*\.""")
val jvmAnnotationUse = Regex("""@(Jvm[A-Za-z]+)""")
val jvmAnnotationImport = Regex("""^import kotlin\.jvm\.(Jvm[A-Za-z]+)""")
val charsetsUse = Regex("""\bCharsets\.""")
val violations = mutableListOf<String>()
for (sourceFile in sourceFiles.files.sortedBy { it.path }) {
val lines = sourceFile.readLines()
val relativePath = sourceFile.relativeTo(repositoryRoot).path
val importedJvmAnnotations =
lines.mapNotNull { line ->
jvmAnnotationImport.find(line.trim())?.groupValues?.get(1)
}.toSet()
lines.forEachIndexed { lineIndex, line ->
val trimmed = line.trim()
if (jvmImport.containsMatchIn(trimmed)) {
violations += "$relativePath:${lineIndex + 1}: a common source set must not import a JVM-only API -> $trimmed"
return@forEachIndexed
}
// Only flag real code, not prose in comments or docblocks.
if (!trimmed.startsWith("*") && !trimmed.startsWith("//") && !trimmed.startsWith("/*")) {
if (jvmQualifiedUse.containsMatchIn(line)) {
violations +=
"$relativePath:${lineIndex + 1}: a common source set must not reference a JVM-only API, even fully " +
"qualified (a qualified use needs no import, so rule 1 alone would miss it) -> $trimmed"
}
jvmAnnotationUse.findAll(line).forEach { match ->
val annotation = match.groupValues[1]
if (annotation !in importedJvmAnnotations) {
violations +=
"$relativePath:${lineIndex + 1}: @$annotation needs an explicit `import kotlin.jvm.$annotation` " +
"(kotlin.jvm.* is a default import only on JVM targets)"
}
}
if (charsetsUse.containsMatchIn(line)) {
violations +=
"$relativePath:${lineIndex + 1}: Charsets is JVM-only (kotlin.text.Charsets); use " +
"encodeToByteArray()/decodeToString() when the bytes are UTF-8, else " +
"org.umamo.format.binary.decodeAscii / encodeUtf16Be -> $trimmed"
}
}
}
}
if (violations.isNotEmpty()) {
throw GradleException(
"common-source purity check failed (${violations.size} violation(s)):\n" +
violations.joinToString("\n") { " $it" },
)
}
val reportFile = report.get().asFile
reportFile.parentFile.mkdirs()
reportFile.writeText("common-source purity: ${sourceFiles.files.size} file(s) checked, no violations.\n")
}
}
// Wire into `check` so the guard runs with the normal verification lifecycle rather than needing to be
// remembered. Gradle runs the task once however many subprojects depend on it.
subprojects {
tasks.matching { task -> task.name == "check" }.configureEach {
dependsOn(checkCommonSourcePurity)
}
}
+159
View File
@@ -0,0 +1,159 @@
#!/usr/bin/env bash
#
# Regenerate every Umamo application-icon asset from the pixel-art master.
#
# Run this by hand whenever the mascot art changes. It is deliberately NOT part
# of the Gradle build: the build references the committed outputs, and this
# script (re)produces them so contributors without image tooling still build.
#
# Pixel-art crispness: every size is nearest-neighbor scaled. Upscales use the
# largest integer multiple of the master edge that fits the target, then pad
# transparently to the exact dimension, so every source pixel keeps a uniform
# width (a non-integer scale would make some pixels one device-pixel wider).
# Targets smaller than the master fall back to point sampling.
#
# Requires ImageMagick 7 (`magick`). ImageMagick writes .ico and .icns itself,
# so no extra packers are needed; icotool (icoutils) / png2icns (libicns) /
# iconutil (macOS) are higher-fidelity alternatives if you prefer them.
#
# Usage: docs/design/appicon/generate.sh [path/to/master.png]
# (default master: docs/design/appicon/umamo-icon.png)
set -euo pipefail
scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repoRoot="$(cd "$scriptDir/../../.." && pwd)"
master="${1:-$scriptDir/umamo-icon.png}"
if [[ ! -f "$master" ]]; then
echo "master art not found: $master" >&2
echo "drop the mascot PNG there (or pass its path) and re-run." >&2
exit 1
fi
magick="$(command -v magick || command -v convert)"
if [[ -z "$magick" ]]; then
echo "ImageMagick (magick/convert) not found on PATH." >&2
exit 1
fi
scratch="$(mktemp -d)"
trap 'rm -rf "$scratch"' EXIT
# Solid backdrop composited under the opaque outputs. The mascot is black line
# art on transparency, so a filled background keeps it visible on dark taskbars and
# launchers and matches the Android adaptive background. Keep this in sync with the
# ic_launcher_background color resource (values/ic_launcher_background.xml) so a
# re-skin changes both at once.
background="white"
# Crisp nearest-neighbor render of the master at targetEdge x targetEdge, on a
# transparent canvas, filling the frame. -filter point is pure point sampling (no
# blending), so the pixel-art edges stay hard. When the target is an integer
# multiple of the master every source pixel keeps a uniform width; the 160px master
# does not integer-divide the standard icon sizes, so filling (minor per-pixel width
# variance at large sizes) is preferred over integer-scale-plus-margin, which would
# size the mascot inconsistently across the frame set. The master is square; a
# non-square master would fit within the box (letterboxed) rather than fill.
emitTransparent() {
local targetEdge="$1" outputPath="$2"
mkdir -p "$(dirname "$outputPath")"
"$magick" "$master" -filter point -resize "${targetEdge}x${targetEdge}" "$outputPath"
}
# As emitTransparent, but flattened onto the solid backdrop (an opaque square).
emitSquare() {
local targetEdge="$1" outputPath="$2"
mkdir -p "$(dirname "$outputPath")"
"$magick" "$master" -filter point -resize "${targetEdge}x${targetEdge}" \
-background "$background" -flatten "$outputPath"
}
# Opaque backdrop disc + mascot, transparent outside the circle (legacy round
# launcher bitmap). round_src is already opaque (emitSquare flattened it), so
# CopyOpacity from the circle mask just carves the disc out of the square.
emitRound() {
local targetEdge="$1" outputPath="$2"
emitSquare "$targetEdge" "$scratch/round_src.png"
"$magick" -size "${targetEdge}x${targetEdge}" xc:none -fill white \
-draw "circle $((targetEdge/2)),$((targetEdge/2)) $((targetEdge/2)),0" \
"$scratch/round_mask.png"
"$magick" "$scratch/round_src.png" "$scratch/round_mask.png" \
-alpha off -compose CopyOpacity -composite "$outputPath"
}
### Desktop -- jpackage per-OS installer icons --------------------------------
desktopIcons="$repoRoot/app/desktop/icons"
mkdir -p "$desktopIcons"
# Windows .ico (multi-resolution frame set).
windowsSizes=(16 24 32 48 64 128 256)
windowsFrames=()
for size in "${windowsSizes[@]}"; do
emitSquare "$size" "$scratch/ico_${size}.png"
windowsFrames+=("$scratch/ico_${size}.png")
done
"$magick" "${windowsFrames[@]}" "$desktopIcons/umamo.ico"
# macOS .icns -- assembled directly. ImageMagick's icns writer only emits a
# single frame, and png2icns/iconutil are not reliably present, so we build the
# container ourselves: an 'icns' magic + big-endian total length, then one typed
# chunk per size (each chunk is OSType + big-endian length-incl-header + a PNG
# payload, which modern macOS reads directly). The OSType/size table mirrors the
# standard iconutil .iconset mapping (non-retina icp4/icp5 plus retina ic07..ic14).
# Reference: Apple Icon Image format (icns); iconutil iconset type codes.
icnsSizes=(16 32 64 128 256 512 1024)
for size in "${icnsSizes[@]}"; do
emitSquare "$size" "$scratch/icns_${size}.png"
done
python3 - "$desktopIcons/umamo.icns" "$scratch" <<'PY'
import os, struct, sys
outputPath, scratchDir = sys.argv[1], sys.argv[2]
# (OSType, pixel size) in the standard iconset order. Sizes recur across types
# on purpose (icp5/ic11 both 32px, ic08/ic13 both 256px, ic09/ic14 both 512px)
# so both the point-size and its @2x retina slot are populated.
entries = [
(b"icp4", 16), (b"icp5", 32), (b"ic11", 32), (b"ic12", 64),
(b"ic07", 128), (b"ic13", 256), (b"ic08", 256), (b"ic14", 512),
(b"ic09", 512), (b"ic10", 1024),
]
chunks = b""
for osType, size in entries:
with open(os.path.join(scratchDir, f"icns_{size}.png"), "rb") as pngFile:
pngBytes = pngFile.read()
chunks += osType + struct.pack(">I", 8 + len(pngBytes)) + pngBytes
container = b"icns" + struct.pack(">I", 8 + len(chunks)) + chunks
with open(outputPath, "wb") as icnsFile:
icnsFile.write(container)
PY
# Linux single PNG.
emitSquare 512 "$desktopIcons/umamo.png"
### Desktop -- live window / taskbar icon (Compose resource) ------------------
emitSquare 512 "$repoRoot/module/ui/src/commonMain/composeResources/drawable/app_icon.png"
### Android -- launcher icons -------------------------------------------------
androidRes="$repoRoot/app/android/src/main/res"
# Legacy square/round bitmaps are 48dp; adaptive foreground layers are 108dp.
declare -A legacyEdge=( [mdpi]=48 [hdpi]=72 [xhdpi]=96 [xxhdpi]=144 [xxxhdpi]=192 )
declare -A foregroundEdge=( [mdpi]=108 [hdpi]=162 [xhdpi]=216 [xxhdpi]=324 [xxxhdpi]=432 )
for density in "${!legacyEdge[@]}"; do
emitSquare "${legacyEdge[$density]}" "$androidRes/mipmap-$density/ic_launcher.png"
emitRound "${legacyEdge[$density]}" "$androidRes/mipmap-$density/ic_launcher_round.png"
# Adaptive foreground: render the mascot (on transparency, so the adaptive
# background color shows through) into the central ~66dp safe zone of the 108dp
# layer so the OS mask (circle/squircle/etc.) never clips it.
fgEdge="${foregroundEdge[$density]}"
safeEdge=$(( fgEdge * 66 / 108 ))
emitTransparent "$safeEdge" "$scratch/fg_${density}.png"
"$magick" "$scratch/fg_${density}.png" -background none -gravity center \
-extent "${fgEdge}x${fgEdge}" \
"$androidRes/mipmap-$density/ic_launcher_foreground.png"
done
echo "regenerated Umamo icons from $master"
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g>
<path d="M377.065,801.822C376.711,725.254 397.337,651.256 434.776,587.043L496.976,623.308C465.915,676.582 448.771,737.966 449.064,801.489L377.065,801.822ZM801.808,377.064L801.517,449.063C771.034,448.94 740.038,452.831 709.191,461.097C678.344,469.362 649.555,481.49 623.218,496.838L586.966,434.63C618.702,416.136 653.386,401.51 690.556,391.55C727.726,381.59 765.077,376.915 801.808,377.064ZM1167.18,590.109L1104.66,625.821C1073.16,570.661 1027.62,526.074 974.08,495.468L1009.81,432.961C1074.34,469.851 1129.2,523.623 1167.18,590.109ZM1165.22,1012.96L1103.02,976.692C1134.09,923.418 1151.23,862.034 1150.94,798.511L1222.93,798.178C1223.29,874.746 1202.66,948.744 1165.22,1012.96ZM798.191,1222.94L798.482,1150.94C828.965,1151.06 859.961,1147.17 890.809,1138.9C921.656,1130.64 950.445,1118.51 976.782,1103.16L1013.03,1165.37C981.298,1183.86 946.614,1198.49 909.444,1208.45C872.273,1218.41 834.923,1223.09 798.191,1222.94ZM432.817,1009.89L495.336,974.179C526.844,1029.34 572.384,1073.93 625.92,1104.53L590.186,1167.04C525.657,1130.15 470.795,1076.38 432.817,1009.89Z" style="fill:white;"/>
<path d="M434.776,1012.96C397.337,948.745 376.712,874.747 377.065,798.18L449.064,798.512C448.771,862.036 465.915,923.419 496.976,976.693L434.776,1012.96ZM590.185,432.962L625.919,495.468C572.383,526.074 526.844,570.662 495.336,625.822L432.816,590.11C470.794,523.624 525.656,469.852 590.185,432.962ZM1013.03,434.63L976.782,496.838C950.445,481.49 921.656,469.362 890.809,461.097C859.962,452.831 828.966,448.94 798.483,449.063L798.192,377.064C834.923,376.915 872.274,381.59 909.444,391.55C946.614,401.51 981.298,416.136 1013.03,434.63ZM1222.93,801.82L1150.94,801.488C1151.23,737.964 1134.09,676.581 1103.02,623.307L1165.22,587.042C1202.66,651.255 1223.29,725.253 1222.93,801.82ZM1009.82,1167.04L974.081,1104.53C1027.62,1073.93 1073.16,1029.34 1104.66,974.178L1167.18,1009.89C1129.21,1076.38 1074.34,1130.15 1009.82,1167.04ZM586.965,1165.37L623.217,1103.16C649.555,1118.51 678.343,1130.64 709.191,1138.9C740.038,1147.17 771.034,1151.06 801.517,1150.94L801.808,1222.94C765.077,1223.09 727.726,1218.41 690.556,1208.45C653.386,1198.49 618.701,1183.86 586.965,1165.37Z" style="fill:rgb(255,0,0);"/>
</g>
<g>
<rect x="120" y="760.609" width="480" height="80" style="fill-opacity:0.85;"/>
<rect x="0" y="760.304" width="120" height="80" style="fill:rgb(255,0,0);"/>
<rect x="1000" y="760.304" width="480" height="80" style="fill-opacity:0.85;"/>
<rect x="1480" y="760" width="120" height="80" style="fill:rgb(255,0,0);"/>
</g>
<g>
<path d="M839.696,600.304L759.696,600.304L759.696,120.304L839.696,120.304L839.696,600.304Z" style="fill-opacity:0.85;"/>
<path d="M840,120.304L760,120.304L760,0.304L840,0.304L840,120.304Z" style="fill:rgb(0,0,255);"/>
<path d="M840,1000.3L760,1000.3L760,1480.3L840,1480.3L840,1000.3Z" style="fill-opacity:0.85;"/>
<path d="M840.304,1480.3L760.304,1480.3L760.304,1600.3L840.304,1600.3L840.304,1480.3Z" style="fill:rgb(0,0,255);"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path1" d="M654.37,59.456L1538.09,943.172C1566.83,971.916 1573.3,1027.25 1538.09,1047.73C1482.75,1079.89 1440.09,1111.42 1480.24,1146.9C1500.89,1166.4 1500.89,1199.26 1480.24,1218.76L1213.45,1485.55C1193.98,1506.28 1161.06,1506.28 1141.59,1485.55C1106.47,1445.21 1079.61,1483.03 1047.45,1538.36C1026.97,1573.4 971.639,1567.11 942.894,1538.36L59.178,654.648C30.198,625.471 30.48,578.289 59.807,549.461C103.103,506.164 158.167,500.865 109.571,452.268C89.727,432.424 89.727,400.251 109.571,380.407L375.997,113.981C395.841,94.137 428.014,94.137 447.858,113.981C496.455,162.577 506.785,102.483 550.081,59.186C579.054,30.705 625.545,30.825 654.37,59.456Z" style="fill:white;stroke:black;stroke-width:75.21px;"/>
<path id="path1-4" d="M490.484,307.419C501.864,318.349 500.45,338.202 487.313,351.953L451.555,387.623C451.989,404.435 458.586,419.394 470.147,429.778C478.624,438.735 489.712,444.898 502.348,447.675C537.197,432.251 574.183,437.25 596.953,460.462C610.392,473.828 618.04,492.223 618.679,512.715C619.125,527.7 612.755,545.075 614.908,558.696C617.477,571.676 623.645,583.079 632.779,591.735C643.916,604.28 660.473,610.918 678.852,610.207L712.151,576.99C725.914,563.816 745.844,562.433 756.726,573.897C768.016,584.85 766.567,604.635 753.47,618.346L717.712,654.016C718.122,670.836 724.723,685.802 736.304,696.17C744.835,705.359 756.081,711.675 768.929,714.492C803.778,699.068 840.765,704.067 863.534,727.279C876.985,740.59 884.61,758.972 885.175,779.447C886.253,815.335 864.066,860.696 924.068,861.373L960.236,825.294C973.999,812.121 993.93,810.738 1004.81,822.201C1016.19,833.131 1014.78,852.984 1001.64,866.735L965.882,902.405C966.606,919.103 973.166,933.976 984.474,944.56C995.079,955.175 1026.11,981.527 1037.97,983.771C1072.78,968.334 1109.73,973.301 1132.49,996.474C1145.99,1009.79 1153.65,1028.21 1154.22,1048.73C1154.66,1063.71 1148.29,1081.09 1150.53,1094.79C1153.08,1107.79 1159.25,1119.19 1168.4,1127.83C1179.54,1140.38 1196.1,1147.02 1214.48,1146.3L1247.77,1113.09C1261.56,1099.98 1281.43,1098.6 1292.35,1109.99C1303.73,1120.92 1302.32,1140.78 1289.18,1154.53L1154.04,1289.34C1140.25,1302.44 1120.38,1303.82 1109.46,1292.43C1098.08,1281.5 1099.49,1261.65 1112.63,1247.9L1147.98,1212.63C1148.72,1194.27 1142.11,1177.72 1129.57,1166.57C1121.24,1157.7 1110.3,1151.61 1097.81,1148.91C1081.77,1145.75 1069.01,1153.05 1051.86,1152.87C1030.48,1152.7 1011.21,1145.05 997.263,1131.2C974.809,1107.63 970.067,1070.77 984.986,1035.78C982.657,1024.03 956.488,993.332 945.967,982.802C935.322,971.575 920.478,965.01 903.81,964.154L866.412,1001.46C852.628,1014.56 832.757,1015.94 821.838,1004.55C810.458,993.623 811.871,973.77 825.008,960.019L863.225,921.896C862.101,862.825 818.066,883.863 782.728,883.507C761.365,883.313 742.095,875.662 728.137,861.833C705.672,838.236 700.9,801.368 715.774,766.329C712.884,754.02 706.748,743.231 697.931,734.957C687.577,723.251 672.609,716.475 655.725,715.85L618.327,753.155C604.543,766.258 584.672,767.637 573.752,756.248C562.298,745.356 563.716,725.444 576.923,711.714L612.271,676.453C612.901,658.278 606.312,641.91 593.912,630.845C585.553,621.948 574.582,615.835 562.068,613.101C546.315,609.825 533.644,617.208 516.656,617.199C495.293,617.005 476.023,609.355 462.064,595.525C439.629,571.911 434.858,535.06 449.702,500.021C446.778,487.544 440.52,476.629 431.52,468.309C421.098,456.801 406.159,450.193 389.363,449.662L351.965,486.967C338.181,500.07 318.31,501.449 307.39,490.06C296.01,479.131 297.424,459.277 310.561,445.526L445.909,310.513C459.693,297.409 479.564,296.03 490.484,307.419L490.484,307.419Z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="arrow">
<path id="path3" d="M1238.16,465.813C1200.45,470.321 1172.07,502.298 1172.06,540.271L1172.06,1061.73C1172.07,1091.6 1189.8,1118.63 1217.21,1130.52C1244.62,1142.41 1276.48,1136.9 1298.3,1116.49L1576.97,855.764C1608.65,826.122 1608.65,775.87 1576.97,746.229L1298.3,485.504C1282.14,470.391 1260.13,463.185 1238.16,465.813Z" style="fill-rule:nonzero;"/>
<path id="path4" d="M1247.06,540.272L1525.73,800.996L1247.06,1061.73L1247.06,540.272Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket">
<path id="path5" d="M247.986,0.289C175.62,0.289 115.709,54.825 115.709,128.691L115.709,182.094C115.709,255.96 175.62,310.498 247.986,310.498L346.342,310.498C376.809,310.498 394.666,318.557 405.932,329.455C417.197,340.354 426.975,357.561 426.975,395.707L426.975,1207.33C426.975,1248.59 417.796,1266.45 409.27,1275.23C400.743,1284 385.352,1292.54 346.342,1292.54L242.586,1292.54C170.22,1292.54 115.373,1356.24 115.373,1420.94L115.373,1474.34C115.373,1512.4 132.13,1542.6 153.846,1564.37C175.561,1586.14 204.519,1602.75 242.586,1602.75L398.219,1602.75C493.192,1602.75 579.877,1568.75 640.363,1506.65C700.849,1444.55 733.187,1356.83 732.605,1260.28L732.607,1260.73L732.607,342.303C732.607,246.008 700.388,158.55 640.07,96.459C579.753,34.368 493.192,0.289 398.219,0.289L247.986,0.289Z" style="fill-rule:nonzero;"/>
<path id="path6" d="M247.987,75.289C216.254,75.289 190.709,101.077 190.709,128.691L190.709,182.095C190.709,209.709 216.254,235.498 247.987,235.498L346.342,235.498C436.795,235.498 501.974,288.9 501.974,395.706L501.974,1207.33C501.974,1314.13 450.097,1367.54 346.342,1367.54L242.587,1367.54C210.853,1367.54 190.372,1393.33 190.372,1420.94L190.372,1474.35C190.372,1501.96 217.156,1527.75 242.587,1527.75L398.219,1527.75C553.852,1527.75 658.571,1420.94 657.607,1260.73L657.607,342.303C657.607,182.095 553.852,75.289 398.219,75.289L247.987,75.289Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="arrow1" serif:id="arrow">
<path id="path7" d="M362.238,465.813C340.269,463.185 318.26,470.391 302.1,485.504L23.426,746.229C-8.25,775.87 -8.251,826.121 23.424,855.764L302.1,1116.49C323.922,1136.9 355.775,1142.41 383.184,1130.52C410.594,1118.63 428.332,1091.6 428.34,1061.73L428.34,540.271C428.331,502.298 399.944,470.321 362.238,465.813Z" style="fill-rule:nonzero;"/>
<path id="path8" d="M353.34,1061.73L74.665,800.996L353.34,540.272L353.34,1061.73Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket1" serif:id="bracket">
<path id="path9" d="M1200.55,0.289C1105.58,0.289 1018.89,34.287 958.404,96.387C897.918,158.486 865.583,246.211 866.164,342.756L866.162,342.303L866.162,1260.73C866.162,1357.03 898.38,1444.49 958.697,1506.58C1019.01,1568.67 1105.58,1602.75 1200.55,1602.75L1350.78,1602.75C1423.15,1602.75 1483.06,1548.21 1483.06,1474.34L1483.06,1420.94C1483.06,1347.08 1423.15,1292.54 1350.78,1292.54L1252.43,1292.54C1221.96,1292.54 1204.1,1284.48 1192.84,1273.58C1181.57,1262.68 1171.8,1245.48 1171.8,1207.33L1171.8,395.707C1171.8,354.447 1180.97,336.586 1189.5,327.809C1198.02,319.032 1213.42,310.498 1252.43,310.498L1356.18,310.498C1428.55,310.498 1483.4,246.793 1483.4,182.094L1483.4,128.691C1483.4,90.636 1466.64,60.434 1444.92,38.666C1423.21,16.898 1394.25,0.289 1356.18,0.289L1200.55,0.289Z" style="fill-rule:nonzero;"/>
<path id="path10" d="M1350.78,1527.75C1382.52,1527.75 1408.06,1501.96 1408.06,1474.35L1408.06,1420.94C1408.06,1393.33 1382.52,1367.54 1350.78,1367.54L1252.43,1367.54C1161.97,1367.54 1096.79,1314.13 1096.79,1207.33L1096.79,395.706C1096.79,288.9 1148.67,235.498 1252.43,235.498L1356.18,235.498C1387.91,235.498 1408.4,209.709 1408.4,182.095L1408.4,128.691C1408.4,101.077 1381.61,75.289 1356.18,75.289L1200.55,75.289C1044.92,75.289 940.197,182.095 941.162,342.303L941.162,1260.73C941.162,1420.94 1044.92,1527.75 1200.55,1527.75L1350.78,1527.75Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1500 1500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path id="path16-4" d="M679.966,499.983L820.03,499.976L820.051,630.066L679.964,630.091L679.966,499.983Z" style="fill-rule:nonzero;"/>
<path id="path16-4-7" d="M679.973,299.992L820.02,299.985L820.042,399.968L679.97,399.992L679.973,299.992Z" style="fill-rule:nonzero;"/>
<path id="path16-4-3" d="M679.979,100.029L820.026,100.022L820.048,200.004L679.976,200.029L679.979,100.029Z" style="fill-rule:nonzero;"/>
<path id="path16-4-9-2" d="M679.982,400.013L820.029,400.006L820.051,499.989L679.979,500.013L679.982,400.013Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-4" d="M679.976,199.994L820.024,199.987L820.046,299.97L679.974,299.994L679.976,199.994Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-5" d="M679.971,-0.001L820.019,-0.008L820.041,99.976L679.968,100L679.971,-0.001Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-6" d="M680.059,1299.92L819.94,1299.91L819.962,1399.89L680.056,1399.92L680.059,1299.92Z" style="fill-rule:nonzero;"/>
<path id="path16-4-7-9" d="M680.05,1099.93L819.931,1099.92L819.953,1199.9L680.047,1199.93L680.05,1099.93Z" style="fill-rule:nonzero;"/>
<path id="path16-4-3-3" d="M680.056,870.139L819.937,870.132L819.959,999.943L680.053,999.967L680.056,870.139Z" style="fill-rule:nonzero;"/>
<path id="path16-4-9-7" d="M680.034,1399.93L819.915,1399.92L819.937,1499.9L680.031,1499.93L680.034,1399.93Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-2-9" d="M680.059,1199.95L819.94,1199.94L819.962,1299.92L680.056,1299.95L680.059,1199.95Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-4-6" d="M680.053,999.932L819.935,999.922L819.957,1099.9L680.051,1099.93L680.053,999.932Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-64" d="M999.997,680.014L1000.01,820.062L869.917,820.084L869.893,680.012L999.997,680.014Z" style="fill-rule:nonzero;"/>
<path id="path16-4-7-1" d="M1199.99,680.005L1200,820.053L1100.02,820.075L1099.99,680.003L1199.99,680.005Z" style="fill-rule:nonzero;"/>
<path id="path16-4-3-8" d="M1399.95,680.011L1399.96,820.059L1299.98,820.081L1299.96,680.008L1399.95,680.011Z" style="fill-rule:nonzero;"/>
<path id="path16-4-9-2-93" d="M1099.97,680.014L1099.98,820.062L999.994,820.084L999.97,680.012L1099.97,680.014Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-4-61" d="M1299.99,680.009L1300,820.056L1200.02,820.078L1199.99,680.006L1299.99,680.009Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-5-9" d="M1499.98,680.003L1499.99,820.051L1400.01,820.073L1399.99,680.001L1499.98,680.003Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-64-8" d="M199.951,679.964L199.961,820.012L99.979,820.034L99.955,679.962L199.951,679.964Z" style="fill-rule:nonzero;"/>
<path id="path16-4-7-1-5" d="M399.945,679.955L399.955,820.003L299.972,820.025L299.948,679.952L399.945,679.955Z" style="fill-rule:nonzero;"/>
<path id="path16-4-3-8-6" d="M630.016,679.961L630.026,820.008L499.936,820.03L499.912,679.958L630.016,679.961Z" style="fill-rule:nonzero;"/>
<path id="path16-4-9-59-2" d="M99.944,679.939L99.954,819.986L-0.029,820.008L-0.053,679.936L99.944,679.939Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-2-93-7" d="M299.924,679.964L299.934,820.011L199.948,820.033L199.924,679.961L299.924,679.964Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path16-4-9-4-61-8" d="M499.943,679.958L499.953,820.006L399.97,820.028L399.946,679.956L499.943,679.958Z" style="fill:white;fill-rule:nonzero;"/>
<g id="use5368-6-7">
<g id="g11-8-5">
<path id="path10-49-6" d="M749.739,599.854C667.55,599.997 600,667.665 600,749.854C600,749.962 600,750.069 600,750.176C600.143,832.266 667.649,899.772 749.739,899.915C749.847,899.915 749.954,899.915 750.061,899.915C832.25,899.915 899.918,832.365 900.061,750.176C900.061,750.069 900.061,749.961 900.061,749.854C900.061,667.566 832.349,599.854 750.061,599.854C749.954,599.854 749.847,599.854 749.739,599.854Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path11-4-0" d="M749.739,677.928C708.694,678.159 675.073,712.043 675.161,753.089C675.39,793.914 708.914,827.438 749.739,827.667C790.785,827.756 824.67,794.134 824.9,753.089C824.9,753.035 824.9,752.982 824.9,752.928C824.9,711.784 791.044,677.928 749.9,677.928C749.847,677.928 749.793,677.928 749.739,677.928Z" style="fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1200 1200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5368">
<g id="g11">
<path id="path11" d="M520.001,0.002L520.002,440.002L680.004,440.003L680.004,0.003L520.001,0.002Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<path id="path1-07" d="M0.002,520.004L520.002,519.999L520,0.002L440.001,0.01L440.001,439.999L0.005,440L0.002,520.004Z" style="fill-opacity:0.65;fill-rule:nonzero;"/>
<g id="use5368-9">
<g id="g11-9">
<path id="path11-5" d="M1200,520.004L759.999,520.005L759.998,680.007L1200,680.007L1200,520.004Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<path id="path1-07-1" d="M679.997,0.005L680.002,520.005L1200,520.003L1199.99,440.004L760,440.004L759.999,0.008L679.997,0.005Z" style="fill-opacity:0.65;fill-rule:nonzero;"/>
<g id="use5368-2">
<g id="g11-5">
<path id="path11-3" d="M0.004,680.003L440.004,680.002L440.005,520L0.005,520L0.004,680.003Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<path id="path1-07-6" d="M520.006,1200L520.001,680.002L0.004,680.004L0.012,760.002L440.001,760.003L440.002,1200L520.006,1200Z" style="fill-opacity:0.65;fill-rule:nonzero;"/>
<g id="use5368-3">
<g id="g11-0">
<path id="path11-0" d="M680.003,1199.99L680.002,759.993L520,759.992L520,1199.99L680.003,1199.99Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<path id="path1-07-63" d="M1200,679.991L680.002,680.001L680.004,1200L760.002,1199.99L760.003,759.999L1200,759.998L1200,679.991Z" style="fill-opacity:0.65;fill-rule:nonzero;"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 300 300" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5368-6">
<g id="g11-8">
<path id="path10-49" d="M149.933,0.164C67.744,0.307 0.193,67.975 0.193,150.164C0.193,150.271 0.193,150.378 0.194,150.486C0.337,232.576 67.842,300.082 149.933,300.225C150.04,300.225 150.147,300.225 150.254,300.225C232.443,300.225 300.111,232.675 300.254,150.486C300.255,150.378 300.255,150.271 300.255,150.164C300.255,67.876 232.542,0.163 150.254,0.163C150.147,0.163 150.04,0.164 149.933,0.164Z" style="fill-rule:nonzero;"/>
<path id="path11-4" d="M149.933,78.238C108.888,78.469 75.266,112.353 75.354,153.399C75.583,194.224 109.107,227.748 149.933,227.977C190.978,228.066 224.863,194.444 225.094,153.399C225.094,153.345 225.094,153.291 225.094,153.238C225.094,112.094 191.238,78.238 150.094,78.238C150.04,78.238 149.986,78.238 149.933,78.238Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1058 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5330">
<g id="path25">
<path id="path1" d="M257.94,1550.45L1008.38,800.018L257.94,49.581L49.485,258.036L591.467,800.018L49.485,1342L257.94,1550.45" style="fill:white;fill-rule:nonzero;"/>
<path id="path2" d="M292.654,1585.29L1043.58,834.977C1063.08,815.649 1063.08,784.134 1043.58,764.808L292.654,14.495C273.398,-4.594 242.357,-4.594 223.101,14.495L14.441,223.154C-4.646,242.41 -4.646,273.452 14.441,292.707L521.626,799.892L14.441,1307.08C-4.646,1326.33 -4.646,1357.37 14.441,1376.63L223.101,1585.29C242.356,1604.38 273.4,1604.38 292.654,1585.29ZM257.57,1480.65L119.079,1342.16L661.481,800.025L119.079,258.239L258.186,119.748L938.33,799.892L257.57,1480.65Z" style="fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1480" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<path id="use5358" d="M120.184,1120.55L120.184,1360.62L600.323,1360.62L1160.49,800.458L1480.58,480.365L1120.48,120.26L120.185,1120.55" style="fill:white;fill-rule:nonzero;stroke:white;stroke-width:240.07px;"/>
<path id="use5360" d="M152.452,1332.56L588.349,1331.12L1022.54,894.749L704.089,576.578L150.517,1125.47L150.347,1331.86" style="fill:white;fill-rule:nonzero;stroke:rgb(13,13,13);stroke-width:100px;"/>
<path id="use5362" d="M831.277,437.279L1162.14,771.286L1453.75,481.193L1120.47,146.211L830.859,436.056" style="fill-rule:nonzero;stroke:rgb(13,13,13);stroke-width:80.02px;"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 700" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5320">
<path id="use23" d="M527.305,485.195L393.843,351.734L527.305,218.272L349.356,40.323L37.946,351.734L349.356,663.144L527.305,485.195" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:75px;"/>
</g>
<g id="use5320-0">
<path id="use23-5" d="M1072.56,216.576L1206.03,350.037L1072.56,483.499L1250.51,661.448L1561.92,350.037L1250.51,38.627L1072.56,216.576" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:75px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 941 B

+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5322">
<path id="path18" d="M48.734,1555.91L48.734,1316.18L194.555,1302.18L194.555,1142.36L793.883,543.034L927.749,676.9" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
<path id="use18" d="M48.735,1555.91L288.467,1555.91L302.465,1410.09L462.286,1410.09L1061.62,810.766L927.749,676.9" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
<path id="path19" d="M448.286,1156.36L767.928,836.72" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
<path id="path20" d="M847.838,277.346L1327.3,756.809L1167.48,916.63L688.018,437.167L847.839,277.347" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
<path id="path21" d="M1330.58,51.352C1269.53,50.467 1210.65,74.355 1167.48,117.528L927.748,357.259L1247.39,676.901L1487.12,437.17C1574.8,349.495 1574.8,205.203 1487.12,117.528C1445.55,75.959 1389.36,52.205 1330.58,51.352Z" style="fill:white;fill-rule:nonzero;stroke:rgb(19,19,19);stroke-width:100px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5350">
<path id="path22" d="M1547.91,528.922C1547.91,617.064 1473.78,688.023 1381.7,688.023L218.217,688.023C126.137,688.022 52.007,617.063 52.007,528.921" style="fill:white;fill-rule:nonzero;stroke:rgb(13,13,13);stroke-width:103.5px;"/>
<path id="path23" d="M467.532,361.324L799.957,51.614L1132.38,361.324L966.168,520.426L799.957,369.818L633.746,520.426L463.026,361.324" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:103.5px;"/>
<path id="path24" d="M1547.91,1066.19C1547.91,978.053 1473.78,907.094 1381.7,907.094L218.217,907.094C126.137,907.094 52.007,978.054 52.007,1066.2" style="fill:white;fill-rule:nonzero;stroke:rgb(13,13,13);stroke-width:103.5px;"/>
<path id="path25" d="M467.532,1236.59L799.957,1546.3L1132.38,1236.59L966.168,1077.49L799.957,1228.1L633.746,1077.49L463.026,1236.59" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:103.5px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path1-9" d="M449.761,838.543C439.916,800.95 430.072,753.626 408.976,682.937C392.2,627.087 374.62,596.814 361.761,559.312C346.19,513.693 331.323,487.023 311.934,440.902C297.971,407.916 275.368,335.827 266.025,296.523C254.071,245.49 269.34,203.88 290.537,175.607C315.953,141.617 387.177,126.478 426.857,140.414C464.126,153.448 501.597,191.749 518.876,219.421C547.807,265.543 554.739,282.788 590.903,374.027C630.381,473.488 647.563,566.33 652.282,597.709L660.784,650.008C660.91,650.754 660.784,650.787 660.784,650.025C657.262,546.856 650.369,343.747 652.577,231.854C652.779,219.221 659.006,173 661.012,160.166C668.848,110.034 691.65,79.956 728.626,62.008C770.008,41.856 821.645,40.453 869.364,60.304C911.859,77.65 932.251,115.449 938.377,162.773C939.784,173.701 947.823,261.733 947.722,273.764C946.416,376.534 948.32,438.295 949.222,491.736C949.627,514.897 949.525,654.665 950.933,639.021C957.059,573.248 960.379,319.284 985.489,243.785C999.958,200.372 1026.17,168.989 1065.26,150.642C1108.55,130.288 1177.07,143.623 1206.3,175.005C1234.93,205.585 1251.1,244.387 1254.72,290.609C1257.93,331.215 1252.81,380.544 1252.71,415.435C1252.71,502.363 1250.6,548.184 1249,628.092C1248.89,631.903 1247.49,657.972 1251.3,646.34C1260.74,618.269 1270.19,591.998 1278.02,571.648C1282.94,559.112 1302.23,510.084 1314.09,485.519C1325.54,462.058 1335.28,448.522 1355.78,416.538C1375.87,385.157 1397.47,371.621 1422.88,360.291C1477.13,336.73 1534.29,371.52 1553.58,419.546C1562.22,441.103 1554.48,491.034 1550.76,530.337C1544.64,595.206 1525.25,661.28 1515.41,695.574C1502.55,740.386 1487.88,819.399 1481.25,856.088C1474.02,895.599 1457.74,994.652 1445.18,1038.57C1436.54,1068.75 1407.92,1136.62 1379.69,1177.33C1379.69,1177.33 1271.8,1302.67 1259.94,1359.01C1248.18,1415.46 1252.1,1415.86 1249.8,1455.76C1248.09,1484.02 1254.86,1518.53 1258.98,1536.37C1260.45,1542.71 1256.17,1549.03 1249.66,1549.72C1225.43,1552.31 1170.97,1557.05 1137.98,1551.72C1098.71,1545.5 1050.09,1467.39 1037.53,1443.63C1020.25,1410.75 983.383,1417.06 969.016,1441.32C946.416,1479.73 897.795,1548.61 863.432,1552.92C798.928,1561.01 667.77,1556.33 560.894,1555.06C554.204,1554.98 549.122,1548.93 549.921,1542.34C553.341,1514.1 557.71,1446.01 525.297,1418.77C494.657,1392.7 441.918,1340.16 410.374,1312.49L326.794,1220.14C298.264,1184.05 263.606,1110.56 201.925,1021.12C166.966,970.593 98.756,912.34 72.939,862.813C50.537,820.195 39.687,767.16 53.852,729.96C76.454,670.401 121.66,640.026 190.674,646.542C242.811,651.558 275.862,667.193 315.04,700.382C337.643,719.433 372.602,753.928 390.383,775.383C406.757,794.93 410.776,803.053 428.255,826.418C451.36,857.194 458.594,872.435 449.753,838.544L449.761,838.543Z" style="fill:white;"/>
<path id="path2-5" d="M449.761,838.543C439.916,800.95 430.072,753.626 408.976,682.937C392.2,627.087 374.62,596.814 361.761,559.312C346.19,513.693 331.323,487.023 311.934,440.902C297.971,407.916 275.368,335.827 266.025,296.523C254.071,245.49 269.34,203.88 290.537,175.607C315.953,141.617 387.177,126.478 426.857,140.414C464.126,153.448 501.597,191.749 518.876,219.421C547.807,265.543 554.739,282.788 590.903,374.027C630.381,473.488 647.563,566.33 652.282,597.709L660.784,650.008C660.91,650.754 660.784,650.787 660.784,650.025C657.262,546.856 650.369,343.747 652.577,231.854C652.779,219.221 659.006,173 661.012,160.166C668.848,110.034 691.65,79.956 728.626,62.008C770.008,41.856 821.645,40.453 869.364,60.304C911.859,77.65 932.251,115.449 938.377,162.773C939.784,173.701 947.823,261.733 947.722,273.764C946.416,376.534 948.32,438.295 949.222,491.736C949.627,514.897 949.525,654.665 950.933,639.021C957.059,573.248 960.379,319.284 985.489,243.785C999.958,200.372 1026.17,168.989 1065.26,150.642C1108.55,130.288 1177.07,143.623 1206.3,175.005C1234.93,205.585 1251.1,244.387 1254.72,290.609C1257.93,331.215 1252.81,380.544 1252.71,415.435C1252.71,502.363 1250.6,548.184 1249,628.092C1248.89,631.903 1247.49,657.972 1251.3,646.34C1260.74,618.269 1270.19,591.998 1278.02,571.648C1282.94,559.112 1302.23,510.084 1314.09,485.519C1325.54,462.058 1335.28,448.522 1355.78,416.538C1375.87,385.157 1397.47,371.621 1422.88,360.291C1477.13,336.73 1534.29,371.52 1553.58,419.546C1562.22,441.103 1554.48,491.034 1550.76,530.337C1544.64,595.206 1525.25,661.28 1515.41,695.574C1502.55,740.386 1487.88,819.399 1481.25,856.088C1474.02,895.599 1457.74,994.652 1445.18,1038.57C1436.54,1068.75 1407.92,1136.62 1379.69,1177.33C1379.69,1177.33 1271.8,1302.67 1259.94,1359.01C1248.18,1415.46 1252.1,1415.86 1249.8,1455.76C1248.09,1484.02 1254.86,1518.53 1258.98,1536.37C1260.45,1542.71 1256.17,1549.03 1249.66,1549.72C1225.43,1552.31 1170.97,1557.05 1137.98,1551.72C1098.71,1545.5 1050.09,1467.39 1037.53,1443.63C1020.25,1410.75 983.383,1417.06 969.016,1441.32C946.416,1479.73 897.795,1548.61 863.432,1552.92C798.928,1561.01 667.77,1556.33 560.894,1555.06C554.204,1554.98 549.122,1548.93 549.921,1542.34C553.341,1514.1 557.71,1446.01 525.297,1418.77C494.657,1392.7 441.918,1340.16 410.374,1312.49L326.794,1220.14C298.264,1184.05 263.606,1110.56 201.925,1021.12C166.966,970.593 98.756,912.34 72.939,862.813C50.537,820.195 39.687,767.16 53.852,729.96C76.454,670.401 121.66,640.026 190.674,646.542C242.811,651.558 275.862,667.193 315.04,700.382C337.643,719.433 372.602,753.928 390.383,775.383C406.757,794.93 410.776,803.053 428.255,826.418C451.36,857.194 458.594,872.435 449.753,838.544L449.761,838.543Z" style="fill:none;stroke:black;stroke-width:86.02px;"/>
<path id="path3-9-3" d="M1151.35,1266.32L1151.35,938.999" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path4-2-5" d="M950.855,1266.55L950.855,939.415" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path5-8-9" d="M751.102,939.311L751.102,1266.45" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
</svg>

After

Width:  |  Height:  |  Size: 6.2 KiB

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path1" d="M377.499,343.73C426.451,324.911 523.028,336.435 548.526,393.738C570.245,442.584 650.115,607.62 651.136,590.072C653.581,551.059 648.69,466.69 665.105,422.602C677.041,390.461 700.493,360.224 735.071,349.545C764.135,340.453 798.3,337.282 828.482,343.731C860.404,350.497 893.954,374.074 906.497,396.488C943.416,462.355 944.032,597.261 945.765,590.072C952.292,561.314 952.899,460.135 974.625,422.602C988.999,397.757 1025.31,375.554 1044.68,371.96C1074.67,366.462 1111.59,364.77 1143,371.113C1168.38,376.294 1202.76,407.483 1212.04,422.602C1234.38,458.972 1246.92,561.737 1250.68,597.895C1252.32,612.803 1258.23,556.345 1280.57,520.081C1321.97,452.523 1468.62,439.413 1474.13,587.64C1476.78,656.783 1476.17,653.616 1476.17,700.131C1476.17,754.687 1474.95,787.671 1472.09,827.213C1469.03,869.395 1460.26,965.081 1447.51,1011.39C1438.74,1043.21 1409.68,1114.79 1380.92,1157.72C1380.92,1157.72 1271.39,1289.87 1259.46,1349.29C1247.53,1408.81 1251.5,1409.23 1249.06,1451.32C1247.36,1481.74 1254.53,1519.05 1258.66,1537.48C1260.02,1543.56 1255.96,1549.6 1249.76,1550.3C1225.62,1553 1169.49,1558.18 1135.55,1552.49C1095.67,1545.93 1046.32,1463.68 1033.57,1438.52C1016.03,1403.84 978.601,1410.5 964.017,1436.09C941.173,1476.58 891.711,1549.21 856.938,1553.77C791.198,1562.32 657.574,1557.33 548.939,1556.01C542.534,1555.93 537.651,1550.17 538.42,1543.81C541.902,1514.81 546.923,1441.43 513.561,1412.3C482.457,1384.81 428.916,1329.41 396.894,1300.23L312.045,1202.85C283.184,1164.79 209.858,1104.64 185.28,992.995C163.558,894.029 165.7,845.506 189.054,805.859C212.714,765.579 257.382,743.585 276.147,739.779C297.359,735.341 346.719,735.657 365.381,746.33C388.124,759.336 397.302,763.142 415.149,787.671C438.605,820.127 446.967,835.886 436.871,800.465C429.121,772.762 404.033,737.56 392.611,697.913C381.495,659.747 290.508,515.535 292.65,453.897C293.466,430.532 303.154,372.382 377.499,343.73Z" style="fill:white;"/>
<path id="path2" d="M377.499,343.73C426.451,324.911 523.028,336.435 548.526,393.738C570.245,442.584 650.115,607.62 651.136,590.072C653.581,551.059 648.69,466.69 665.105,422.602C677.041,390.461 700.493,360.224 735.071,349.545C764.135,340.453 798.3,337.282 828.482,343.731C860.404,350.497 893.954,374.074 906.497,396.488C943.416,462.355 944.032,597.261 945.765,590.072C952.292,561.314 952.899,460.135 974.625,422.602C988.999,397.757 1025.31,375.554 1044.68,371.96C1074.67,366.462 1111.59,364.77 1143,371.113C1168.38,376.294 1202.76,407.483 1212.04,422.602C1234.38,458.972 1246.92,561.737 1250.68,597.895C1252.32,612.803 1258.23,556.345 1280.57,520.081C1321.97,452.523 1468.62,439.413 1474.13,587.64C1476.78,656.783 1476.17,653.616 1476.17,700.131C1476.17,754.687 1474.95,787.671 1472.09,827.213C1469.03,869.395 1460.26,965.081 1447.51,1011.39C1438.74,1043.21 1409.68,1114.79 1380.92,1157.72C1380.92,1157.72 1271.39,1289.87 1259.46,1349.29C1247.53,1408.81 1251.5,1409.23 1249.06,1451.32C1247.36,1481.74 1254.53,1519.05 1258.66,1537.48C1260.02,1543.56 1255.96,1549.6 1249.76,1550.3C1225.62,1553 1169.49,1558.18 1135.55,1552.49C1095.67,1545.93 1046.32,1463.68 1033.57,1438.52C1016.03,1403.84 978.601,1410.5 964.017,1436.09C941.173,1476.58 891.711,1549.21 856.938,1553.77C791.198,1562.32 657.574,1557.33 548.939,1556.01C542.534,1555.93 537.651,1550.17 538.42,1543.81C541.902,1514.81 546.923,1441.43 513.561,1412.3C482.457,1384.81 428.916,1329.41 396.894,1300.23L312.045,1202.85C283.184,1164.79 209.858,1104.64 185.28,992.995C163.558,894.029 165.7,845.506 189.054,805.859C212.714,765.579 257.382,743.585 276.147,739.779C297.359,735.341 346.719,735.657 365.381,746.33C388.124,759.336 397.302,763.142 415.149,787.671C438.605,820.127 446.967,835.886 436.871,800.465C429.121,772.762 404.033,737.56 392.611,697.913C381.495,659.747 290.508,515.535 292.65,453.897C293.466,430.532 303.154,372.382 377.499,343.73Z" style="fill:none;stroke:black;stroke-width:82.92px;"/>
<path id="path3-9-3-6" d="M1150.13,1264.13L1150.13,936.812" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path4-2-5-6" d="M949.636,1264.36L949.636,937.227" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path5-8-9-9" d="M749.882,937.124L749.882,1264.26" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path1-8" d="M348.563,1238.14C318.526,1203.4 282.038,1132.38 217.1,1046.16C180.294,997.392 89.02,905.563 61.839,858.921C38.254,817.696 40.792,799.22 46.398,765.059C56.34,704.29 124.451,656.976 197.111,663.358C252.001,668.105 298.537,701.293 340.42,732.646C397.368,775.154 424.689,844.157 455.044,907.561C461.539,921.128 465.488,925.874 463.099,910.602C455.632,862.874 371.413,433.107 370.467,428.283L370.414,428.018L328.711,216.301C314.043,141.845 346.303,54.111 423.395,44.939C499.827,35.847 570.41,84.792 590.579,157.338L634.826,316.479C637.976,327.814 640.516,339.138 642.493,350.724C653.407,414.832 691.107,636.639 692.457,651.584C692.227,643.565 690.965,580.031 689.854,523.39C688.742,466.73 722.675,423.936 780.72,423.936C921.886,423.936 980.293,497.324 980.293,535.912C980.293,479.924 1057.5,440.828 1107.16,440.828C1180.57,440.828 1231.39,458.115 1248.33,501.458C1265.27,544.801 1273.91,665.116 1274.8,669.422C1277.43,682.084 1283.01,604.872 1318.91,574.673C1379.24,523.934 1473.31,553.139 1485.5,643.582C1488.94,669.138 1489.72,718.563 1489.72,761.131C1489.72,811.158 1488.45,841.254 1485.5,877.448C1482.21,916.149 1473.12,1003.63 1459.9,1046.01C1450.96,1074.65 1421.65,1138.48 1392.42,1177.96C1391.44,1179.29 1390.49,1180.52 1389.5,1181.84C1377.03,1198.33 1288,1317.44 1276.49,1368.09C1264.02,1422.47 1268.14,1422.86 1265.7,1461.46C1264.02,1488.12 1270.8,1520.63 1275.13,1538.11C1276.78,1544.73 1272.23,1551.4 1265.29,1552.07C1239.64,1554.58 1182.59,1559.12 1147.99,1554.07C1106.64,1547.97 1106.22,1484.39 1093.01,1461.37C1074.81,1429.63 1022.18,1419.57 1007.06,1442.98C983.266,1480.04 932.076,1546.52 895.902,1550.68C828.011,1558.49 689.986,1554.06 577.477,1552.76C570.419,1552.67 565.072,1546.38 565.955,1539.54C569.528,1511.74 573.648,1447.21 539.901,1421.21C507.647,1396.15 469.767,1353.96 436.557,1327.26L348.563,1238.14Z" style="fill:white;fill-rule:nonzero;"/>
<path id="path2-4" d="M980.293,535.912C980.293,497.324 921.886,423.936 780.721,423.936C722.675,423.936 688.743,466.73 689.855,523.39C691.081,586.017 692.493,657.071 692.493,652.195C692.493,644.814 653.61,416.005 642.494,350.724C640.517,339.137 637.976,327.814 634.827,316.479L590.58,157.338C570.411,84.792 499.827,35.847 423.396,44.939C346.304,54.111 314.044,141.845 328.711,216.301L370.415,428.018C370.442,428.167 370.442,428.134 370.468,428.283C371.414,433.107 455.633,862.874 463.1,910.602C465.489,925.874 461.54,921.128 455.044,907.561C424.69,844.157 397.369,775.154 340.421,732.646C298.538,701.293 252.002,668.105 197.111,663.358C124.452,656.976 56.34,704.29 46.399,765.059C40.793,799.22 38.254,817.696 61.84,858.921C89.021,905.563 180.295,997.392 217.1,1046.16C282.039,1132.38 318.527,1203.4 348.564,1238.14L436.559,1327.26C469.769,1353.96 507.649,1396.15 539.902,1421.21C573.65,1447.21 569.529,1511.75 565.956,1539.54C565.074,1546.38 570.421,1552.67 577.479,1552.76C689.988,1554.06 828.012,1558.49 895.904,1550.68C932.077,1546.52 983.267,1480.04 1007.06,1442.98C1022.19,1419.57 1074.81,1429.63 1093.01,1461.37C1106.22,1484.39 1106.64,1547.97 1147.99,1554.07C1182.59,1559.12 1239.64,1554.58 1265.29,1552.07C1272.23,1551.4 1276.78,1544.73 1275.14,1538.11C1270.8,1520.63 1264.02,1488.12 1265.7,1461.46C1268.14,1422.86 1264.02,1422.47 1276.5,1368.09C1288,1317.44 1377.03,1198.33 1389.5,1181.84C1390.5,1180.52 1391.44,1179.29 1392.42,1177.96C1421.66,1138.48 1450.96,1074.65 1459.9,1046.01C1473.12,1003.63 1482.22,916.149 1485.5,877.448C1488.45,841.254 1489.73,811.158 1489.73,761.131C1489.73,718.563 1488.94,669.138 1485.5,643.582C1473.31,553.139 1379.25,523.934 1318.91,574.673C1283.01,604.872 1277.43,682.084 1274.8,669.422C1273.91,665.116 1265.27,544.801 1248.33,501.458C1231.39,458.115 1180.57,440.828 1107.17,440.828C1057.5,440.828 980.294,479.924 980.294,535.912L980.293,535.912ZM980.293,535.912C980.293,579.626 981.476,616.372 982.702,643.582C985.164,698.553 980.293,638.534 980.293,583.511L980.293,535.912Z" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:87.18px;"/>
<path id="path3-9" d="M1150.05,1263.76L1150.05,936.442" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path4-2" d="M949.555,1263.99L949.555,936.858" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
<path id="path5-8" d="M749.802,936.754L749.802,1263.89" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:78.11px;stroke-linecap:round;"/>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1480" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5324">
<path id="path22" d="M49.571,1430.48L1410.07,51.267L1550.32,193.468L1122.74,626.935L1176.84,760.577L710.385,1233.45C553.823,1392.17 49.571,1430.48 49.571,1430.48" style="fill:rgb(245,245,245);fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 739 B

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1000 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="arrow">
<path id="path5" d="M333.53,465.813C311.561,463.185 289.552,470.391 273.391,485.504L24.046,746.229C-7.631,775.87 -7.632,826.121 24.044,855.764L273.391,1116.49C295.213,1136.9 327.066,1142.41 354.476,1130.52C381.885,1118.63 399.624,1091.6 399.631,1061.73L399.631,540.271C399.622,502.298 371.235,470.321 333.53,465.813Z" style="fill-rule:nonzero;"/>
<path id="path6" d="M324.632,1061.73L75.285,800.996L324.632,540.272L324.632,1061.73Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket">
<path id="path7" d="M731.374,0.289C636.401,0.289 549.716,34.287 489.229,96.387C428.743,158.486 398.925,246.211 399.506,342.756L399.504,342.303L399.504,1260.73C399.504,1357.03 429.204,1444.49 489.522,1506.58C549.84,1568.67 636.401,1602.75 731.374,1602.75L868.656,1602.75C941.022,1602.75 1000.94,1548.21 1000.94,1474.34L1000.94,1420.94C1000.94,1347.08 938.35,1292.54 865.984,1292.54L780.581,1292.54C750.113,1292.54 732.255,1284.48 720.989,1273.58C709.723,1262.68 699.946,1245.48 699.946,1207.33L699.946,395.707C699.946,354.447 709.125,336.586 717.651,327.809C726.178,319.031 741.571,310.498 780.581,310.498L868.591,310.498C940.957,310.498 998.479,246.793 998.479,182.094L998.479,128.691C998.479,90.636 981.72,60.434 960.005,38.666C938.289,16.898 909.329,0.289 871.262,0.289L731.374,0.289Z" style="fill-rule:nonzero;"/>
<path id="path8" d="M868.657,1527.75C900.39,1527.75 925.935,1501.96 925.935,1474.35L925.935,1420.94C925.935,1393.33 900.39,1367.54 868.657,1367.54L783.252,1367.54C692.798,1367.54 627.619,1314.13 627.619,1207.33L627.619,395.706C627.619,288.9 679.496,235.498 783.252,235.498L871.263,235.498C902.997,235.498 923.478,209.709 923.478,182.095L923.478,128.691C923.478,101.077 896.694,75.289 871.263,75.289L731.374,75.289C575.741,75.289 471.021,182.095 471.986,342.303L471.986,1260.73C471.986,1420.94 575.741,1527.75 731.374,1527.75L868.657,1527.75Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="strip">
<path id="path3" d="M872.9,1274.13C942.411,1274.13 1000.71,1215.83 1000.71,1146.31L1000.71,453.001C1000.71,383.489 942.411,325.188 872.9,325.188L826.383,325.188C756.872,325.188 698.571,383.489 698.571,453.001L698.571,1146.31C698.571,1215.83 756.872,1274.13 826.383,1274.13L872.9,1274.13Z" style="fill-rule:nonzero;"/>
<path id="path4" d="M872.899,1199.13L827.643,1199.13C798.385,1199.13 774.83,1175.57 774.83,1146.32L774.83,453.001C774.83,423.743 798.385,400.188 827.643,400.188L872.899,400.188C902.158,400.188 925.712,423.743 925.712,453.001L925.712,1146.32C925.712,1175.57 902.158,1199.13 872.899,1199.13Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path1" d="M563.719,66.221L378.046,251.894L188.651,63.319L63.412,188.376L252.76,377.238L65.701,564.356L191.849,690.323L379.152,503.173L567.948,692.454L693.143,567.992L503.787,378.635L690.565,191.732L563.719,66.221Z" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:88.7px;"/>
<g id="use5368">
<g id="g11">
<path id="path10" d="M949.759,450.05L949.759,750.78" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:250px;stroke-linecap:round;stroke-miterlimit:4.3;"/>
<path id="path11" d="M949.759,450.05L949.759,750.78" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:100px;stroke-linecap:round;"/>
</g>
</g>
<g id="use5368-7">
<g id="g11-7">
<path id="path10-4" d="M950.06,1149.8L950.06,1450.53" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:250px;stroke-linecap:round;stroke-miterlimit:4.3;"/>
<path id="path11-9" d="M950.06,1149.8L950.06,1450.53" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:100px;stroke-linecap:round;"/>
</g>
</g>
<g id="use5368-8">
<g id="g11-6">
<path id="path10-8" d="M449.219,950.532L749.949,950.532" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:250px;stroke-linecap:round;stroke-miterlimit:4.3;"/>
<path id="path11-6" d="M449.219,950.532L749.949,950.532" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:100px;stroke-linecap:round;"/>
</g>
</g>
<g id="use5368-7-3">
<g id="g11-7-0">
<path id="path10-4-1" d="M1148.97,950.231L1449.7,950.231" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:250px;stroke-linecap:round;stroke-miterlimit:4.3;"/>
<path id="path11-9-9" d="M1148.97,950.231L1449.7,950.231" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:100px;stroke-linecap:round;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1058" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5330">
<g id="path25">
<path id="path1" d="M1550.74,800.322L800.301,49.886L49.864,800.322L258.319,1008.78L800.301,466.795L1342.28,1008.78L1550.74,800.322" style="fill:white;fill-rule:nonzero;"/>
<path id="path2" d="M1585.57,765.608L835.26,14.679C815.932,-4.819 784.417,-4.819 765.091,14.679L14.778,765.608C-4.311,784.864 -4.311,815.905 14.778,835.161L223.437,1043.82C242.692,1062.91 273.734,1062.91 292.99,1043.82L800.175,536.636L1307.36,1043.82C1326.62,1062.91 1357.66,1062.91 1376.91,1043.82L1585.57,835.161C1604.66,815.906 1604.66,784.862 1585.57,765.608ZM1480.93,800.692L1342.44,939.183L800.308,396.781L258.521,939.183L120.031,800.077L800.175,119.932L1480.93,800.692Z" style="fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 700 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5320">
<path id="use23" d="M217.743,527.223L351.204,393.761L484.666,527.223L662.615,349.274L351.204,37.863L39.794,349.274L217.743,527.223" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:75px;"/>
</g>
<g id="use5320-0">
<path id="use23-5" d="M483.602,1073.03L350.141,1206.5L216.679,1073.03L38.73,1250.98L350.141,1562.39L661.551,1250.98L483.602,1073.03" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:75px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 939 B

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<g id="use5316">
<path id="path20" d="M674.088,505.039L800.338,378.789L926.588,505.039L1094.92,336.706L800.338,42.123L505.755,336.706L674.088,505.039" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:84.17px;"/>
<path id="use20" d="M1094.92,673.371L1221.17,799.621L1094.92,925.871L1263.25,1094.2L1557.84,799.621L1263.25,505.038L1094.92,673.371" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:84.17px;"/>
<path id="use21" d="M926.489,1094.2L800.239,1220.45L673.989,1094.2L505.656,1262.54L800.239,1557.12L1094.82,1262.54L926.489,1094.2" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:84.17px;"/>
<path id="use22" d="M505.755,925.871L379.506,799.621L505.755,673.372L337.423,505.039L42.84,799.621L337.423,1094.2L505.755,925.871" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:84.17px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5368">
<g id="g11">
<path id="path10" d="M699.977,0.002L699.977,450.001L899.997,450.001L899.997,0.022L699.977,0.002Z" style="fill-rule:nonzero;"/>
<path id="path11" d="M759.97,59.988L759.939,389.92L840.013,389.92L840.037,59.964L759.97,59.988Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<g id="use5368-3">
<g id="g11-0">
<path id="path10-0" d="M699.967,700.022L699.967,900.02L899.986,900.02L899.986,700.042L699.967,700.022Z" style="fill-rule:nonzero;"/>
<path id="path11-6" d="M759.96,760.007L759.928,840.086L839.954,840.037L839.977,760.032L759.96,760.007Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<g id="use5368-1">
<g id="g11-2">
<path id="path10-8" d="M699.852,1149.89L699.852,1599.89L899.872,1599.89L899.872,1149.91L699.852,1149.89Z" style="fill-rule:nonzero;"/>
<path id="path11-1" d="M759.845,1209.88L759.814,1539.81L839.889,1539.81L839.912,1209.86L759.845,1209.88Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<g id="use5368-4">
<g id="g11-4">
<path id="path10-2" d="M0.047,900.003L450.046,900.003L450.046,699.983L0.067,699.983L0.047,900.003Z" style="fill-rule:nonzero;"/>
<path id="path11-15" d="M60.033,840.01L389.965,840.041L389.965,759.966L60.009,759.943L60.033,840.01Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
<g id="use5368-1-5">
<g id="g11-2-5">
<path id="path10-8-9" d="M1149.94,900.127L1599.94,900.127L1599.94,700.108L1149.96,700.108L1149.94,900.127Z" style="fill-rule:nonzero;"/>
<path id="path11-1-0" d="M1209.92,840.135L1539.86,840.166L1539.86,760.091L1209.9,760.068L1209.92,840.135Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:square;stroke-linejoin:round;">
<path id="use5332" d="M50.146,1551.41L150.108,1151.56L1249.7,51.96L1549.59,351.849L449.995,1451.45L50.146,1551.41Z" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:100px;"/>
<path id="path1" d="M1011.87,306.849L1082.4,236.385L1365.6,518.937L1294.82,589.669L1011.87,306.849Z" style="fill-rule:nonzero;"/>
</svg>

After

Width:  |  Height:  |  Size: 782 B

+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path2" d="M749.552,749.138L1450.47,749.186L1450.55,1450.3L749.509,1450.59L749.552,749.138Z" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:300px;"/>
<path id="path2-7" d="M749.94,750.005L1450,749.592L1450.12,1449.82L750.353,1449.72L749.94,750.005Z" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:140px;"/>
<path id="path1" d="M239.883,40.228L239.873,239.557L40.062,239.894L40.099,460.065C40.099,460.065 156.665,460.214 240.099,460.084L239.959,659.64L459.918,659.846L460.101,460.25L660.131,460.02L659.869,240.009L460.058,240.009L460.067,39.899L239.883,40.228Z" style="fill:white;fill-rule:nonzero;stroke:black;stroke-width:80px;"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1100 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
<path id="path2" d="M51.043,122.801L50.539,1422L319.107,1160.01L474.385,1534.85L739.86,1425.8L584.91,1049.03L979.145,1049.19L51.043,122.801Z" style="fill:white;fill-rule:nonzero;stroke:rgb(0,0,255);stroke-width:77.39px;"/>
</svg>

After

Width:  |  Height:  |  Size: 639 B

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1000 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="arrow">
<path id="path7" d="M666.599,465.057C628.893,469.566 600.506,501.543 600.498,539.518L600.498,1060.97C600.505,1090.85 618.243,1117.87 645.653,1129.77C673.062,1141.66 704.916,1136.15 726.738,1115.74L976.726,855.014C1008.4,825.372 1008.4,775.12 976.726,745.479L726.738,484.75C710.578,469.637 688.569,462.43 666.599,465.057Z" style="fill-rule:nonzero;"/>
<path id="path8" d="M675.498,539.517L925.487,800.246L675.498,1060.97L675.498,539.517Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket">
<path id="path10" d="M135.126,-1.504C62.76,-1.504 0.39,53.032 0.39,126.898L0.39,180.301C0.39,254.167 62.76,308.705 135.126,308.705L219.403,308.705C249.871,308.705 267.727,316.762 278.993,327.66C290.259,338.559 300.036,355.766 300.036,393.912L300.036,1205.54C300.036,1246.8 290.858,1264.66 282.331,1273.43C273.805,1282.21 258.414,1290.74 219.403,1290.74L127.941,1290.74C55.575,1290.74 0.727,1354.45 0.727,1419.15L0.727,1472.55C0.727,1510.61 17.484,1540.81 39.199,1562.58C60.915,1584.34 89.874,1600.95 127.941,1600.95L268.822,1600.95C363.795,1600.95 450.48,1566.95 510.966,1504.86C571.452,1442.76 601.331,1355.03 600.75,1258.49L600.752,1258.94L600.752,340.51C600.752,244.215 570.991,156.757 510.673,94.666C450.355,32.575 363.795,-1.504 268.822,-1.504L135.126,-1.504Z" style="fill-rule:nonzero;"/>
<path id="path11" d="M133.076,73.495C101.343,73.495 75.799,99.283 75.799,126.898L75.799,180.301C75.799,207.916 101.343,233.704 133.076,233.704L216.944,233.704C307.398,233.704 372.577,287.107 372.577,393.913L372.577,1205.54C372.577,1312.34 320.699,1365.75 216.944,1365.75L127.941,1365.75C96.208,1365.75 75.726,1391.53 75.726,1419.15L75.726,1472.55C75.726,1500.17 102.511,1525.95 127.941,1525.95L268.822,1525.95C424.455,1525.95 529.175,1419.15 528.21,1258.94L528.21,340.51C528.21,180.301 424.455,73.495 268.822,73.495L133.076,73.495Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="strip">
<path id="path5" d="M129.116,324.419C59.605,324.419 1.302,382.722 1.302,452.233L1.302,1147.34C1.302,1216.85 59.605,1275.15 129.116,1275.15L172.094,1275.15C241.605,1275.15 299.906,1216.85 299.906,1147.34L299.906,452.233C299.906,382.722 241.605,324.419 172.094,324.419L129.116,324.419Z" style="fill-rule:nonzero;"/>
<path id="path6" d="M129.116,399.419L171.614,399.419C200.872,399.419 224.427,422.974 224.427,452.233L224.427,1147.34C224.427,1176.6 200.872,1200.15 171.614,1200.15L129.116,1200.15C99.857,1200.15 76.302,1176.6 76.302,1147.34L76.302,452.233C76.302,422.974 99.857,399.419 129.116,399.419Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1058" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="use5330">
<g id="path25">
<path id="path1" d="M49.615,257.827L800.051,1008.26L1550.49,257.827L1342.03,49.373L800.051,591.354L258.07,49.373L49.615,257.827" style="fill:white;fill-rule:nonzero;"/>
<path id="path2" d="M14.779,292.542L765.092,1043.47C784.42,1062.97 815.935,1062.97 835.261,1043.47L1585.57,292.542C1604.66,273.286 1604.66,242.244 1585.57,222.988L1376.91,14.329C1357.66,-4.759 1326.62,-4.759 1307.36,14.329L800.177,521.513L292.993,14.329C273.737,-4.759 242.695,-4.759 223.439,14.329L14.779,222.988C-4.312,242.243 -4.312,273.287 14.779,292.542ZM119.417,257.457L257.908,118.966L800.044,661.368L1341.83,118.966L1480.32,258.073L800.177,938.217L119.417,257.457Z" style="fill-rule:nonzero;"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="arrow">
<path id="path3" d="M914.707,465.813C877.183,470.3 848.614,502.48 848.605,540.271L848.605,1061.73C848.615,1102.87 882.472,1136.71 923.613,1136.71C942.631,1136.71 960.955,1129.48 974.845,1116.49L1253.52,855.764C1268.67,841.588 1277.28,821.743 1277.28,800.996C1277.28,780.249 1268.67,760.405 1253.52,746.229L974.845,485.504C958.694,470.4 936.663,463.187 914.707,465.813ZM998.605,713.148L1092.5,800.996L998.605,888.848L998.605,713.148Z" style="fill-rule:nonzero;"/>
<path id="path4" d="M923.606,540.272L1202.28,800.996L923.606,1061.73L923.606,540.272Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket">
<path id="path5" d="M1115.04,0.289C1042.67,0.289 982.764,54.825 982.764,128.691L982.764,182.094C982.764,255.96 1042.67,310.498 1115.04,310.498L1213.4,310.498C1243.86,310.498 1261.72,318.557 1272.99,329.455C1284.25,340.354 1294.03,357.561 1294.03,395.707L1294.03,1207.33C1294.03,1248.59 1284.85,1266.45 1276.32,1275.23C1267.8,1284 1252.41,1292.54 1213.4,1292.54L1109.64,1292.54C1037.28,1292.54 982.428,1356.24 982.428,1420.94L982.428,1474.34C982.428,1512.4 999.185,1542.6 1020.9,1564.37C1042.62,1586.14 1071.57,1602.75 1109.64,1602.75L1265.27,1602.75C1360.25,1602.75 1446.93,1568.75 1507.42,1506.65C1567.9,1444.55 1600.24,1356.83 1599.66,1260.28L1599.66,1260.73L1599.66,342.303C1599.66,246.008 1567.44,158.55 1507.12,96.459C1446.81,34.368 1360.25,0.289 1265.27,0.289L1115.04,0.289ZM1132.76,150.289L1265.27,150.289C1325.93,150.289 1369.07,169.613 1399.53,200.977C1430,232.34 1449.66,278.389 1449.66,342.303L1449.66,1260.73C1449.66,1260.88 1449.66,1261.03 1449.66,1261.18C1450.05,1324.85 1430.51,1370.63 1399.96,1401.99C1369.42,1433.34 1325.93,1452.75 1265.27,1452.75L1132.43,1452.75L1132.43,1442.54L1213.4,1442.54C1278.14,1442.54 1340.57,1424.37 1383.92,1379.75C1427.27,1335.12 1444.03,1272.88 1444.03,1207.33L1444.03,395.707C1444.03,327.048 1421.22,264.149 1377.28,221.645C1333.34,179.14 1273.38,160.498 1213.4,160.498L1132.76,160.498L1132.76,150.289Z" style="fill-rule:nonzero;"/>
<path id="path6" d="M1115.04,75.289C1083.31,75.289 1057.76,101.077 1057.76,128.691L1057.76,182.095C1057.76,209.709 1083.31,235.498 1115.04,235.498L1213.4,235.498C1303.85,235.498 1369.03,288.9 1369.03,395.706L1369.03,1207.33C1369.03,1314.13 1317.15,1367.54 1213.4,1367.54L1109.64,1367.54C1077.91,1367.54 1057.43,1393.33 1057.43,1420.94L1057.43,1474.35C1057.43,1501.96 1084.21,1527.75 1109.64,1527.75L1265.27,1527.75C1420.91,1527.75 1525.63,1420.94 1524.66,1260.73L1524.66,342.303C1524.66,182.095 1420.91,75.289 1265.27,75.289L1115.04,75.289Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="arrow1" serif:id="arrow">
<path id="path7" d="M706.207,465.813C684.25,463.187 662.219,470.4 646.068,485.504L367.394,746.229C352.245,760.405 343.636,780.249 343.636,800.997C343.636,821.744 352.244,841.588 367.392,855.764L646.068,1116.49C659.959,1129.48 678.283,1136.71 697.301,1136.71C738.441,1136.71 772.298,1102.87 772.308,1061.73L772.308,540.271C772.299,502.48 743.731,470.3 706.207,465.813ZM622.308,713.148L622.308,888.848L528.41,800.996L622.308,713.148Z" style="fill-rule:nonzero;"/>
<path id="path8" d="M697.308,1061.73L418.633,800.996L697.308,540.272L697.308,1061.73Z" style="fill:white;fill-rule:nonzero;"/>
</g>
<g id="bracket1" serif:id="bracket">
<path id="path9" d="M354.879,0.289C259.906,0.289 173.22,34.287 112.734,96.387C52.248,158.486 19.913,246.211 20.494,342.756L20.492,342.303L20.492,1260.73C20.492,1357.03 52.71,1444.49 113.027,1506.58C173.345,1568.67 259.906,1602.75 354.879,1602.75L505.111,1602.75C577.477,1602.75 637.389,1548.21 637.389,1474.34L637.389,1420.94C637.389,1347.08 577.477,1292.54 505.111,1292.54L406.756,1292.54C376.289,1292.54 358.434,1284.48 347.168,1273.58C335.902,1262.68 326.125,1245.48 326.125,1207.33L326.125,395.707C326.125,354.447 335.302,336.586 343.828,327.809C352.354,319.032 367.746,310.498 406.756,310.498L510.512,310.498C582.878,310.498 637.726,246.793 637.726,182.094L637.726,128.691C637.726,90.636 620.967,60.434 599.252,38.666C577.536,16.898 548.579,0.289 510.512,0.289L354.879,0.289ZM354.879,150.289L487.726,150.289L487.726,160.498L406.756,160.498C342.011,160.498 279.587,178.665 236.236,223.291C192.885,267.917 176.125,330.161 176.125,395.707L176.125,1207.33C176.125,1275.99 198.936,1338.89 242.873,1381.39C286.81,1423.89 346.769,1442.54 406.756,1442.54L487.389,1442.54L487.389,1452.75L354.879,1452.75C294.219,1452.75 251.087,1433.42 220.619,1402.06C190.151,1370.69 170.492,1324.65 170.492,1260.73L170.492,342.303C170.493,342.152 170.493,342.002 170.492,341.852C170.109,278.188 189.649,232.404 220.189,201.049C250.73,169.693 294.221,150.289 354.881,150.289L354.879,150.289Z" style="fill-rule:nonzero;"/>
<path id="path10" d="M505.111,1527.75C536.845,1527.75 562.389,1501.96 562.389,1474.35L562.389,1420.94C562.389,1393.33 536.845,1367.54 505.111,1367.54L406.757,1367.54C316.303,1367.54 251.124,1314.13 251.124,1207.33L251.124,395.706C251.124,288.9 303.002,235.498 406.757,235.498L510.512,235.498C542.245,235.498 562.726,209.709 562.726,182.095L562.726,128.691C562.726,101.077 535.942,75.289 510.512,75.289L354.879,75.289C199.247,75.289 94.527,182.095 95.492,342.303L95.492,1260.73C95.492,1420.94 199.247,1527.75 354.879,1527.75L505.111,1527.75Z" style="fill:white;fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB

+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1600 1600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
<path id="path2" d="M800.311,50.105C388.752,50.105 50.091,388.767 50.091,800.325C50.091,1211.88 388.753,1550.55 800.311,1550.55C1211.87,1550.55 1550.53,1211.88 1550.53,800.325C1550.53,388.767 1211.87,50.105 800.311,50.105ZM800.311,314.889C1066.61,314.889 1285.75,534.023 1285.75,800.325C1285.56,885.722 1262.84,969.576 1219.9,1043.39L557.248,380.739C631.06,337.793 714.914,315.076 800.311,314.889ZM380.726,557.262L1043.37,1219.91C969.562,1262.86 885.708,1285.58 800.311,1285.76C534.009,1285.76 314.875,1066.63 314.874,800.325C315.061,714.929 337.779,631.074 380.726,557.262Z" style="fill:white;fill-rule:nonzero;stroke:rgb(3,3,3);stroke-width:100px;"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More