Porting plan + first pure slice: geometry, color, scene #1

Merged
nandi merged 3 commits from feat/geometry-color-scene into main 2026-11-29 06:14:37 +00:00
Owner

First vertical slice of the MoonBit port of Zed's GPUI.

What's here

  • docs/PORTING.md has six parts:
    • GPUI architecture summary.
    • Module map from GPUI to MoonBit packages, split into pure and platform code.
    • Mooncakes package survey with backend support.
    • Backend recommendation: js plus Canvas2D first, behind a small Platform trait. WebGPU and native come later.
    • Rust idioms (dyn Any/TypeId, associated types, Drop, macros, async) mapped to MoonBit designs.
    • Ordered roadmap M0–M12, with open design questions.
  • geometry:
    • Units: Pixels, ScaledPixels, DevicePixels, Rems.
    • Lengths: AbsoluteLength, DefiniteLength, Length, with parsing.
    • Types: Point, Size, Bounds, Edges, Corners, Anchor, Axis, ContentMask.
  • color:
    • Rgba and Hsla, with conversions, hex parsing and blending.
    • Background: solid, linear gradient, slash pattern, checkerboard.
  • scene:
    • Primitives: Quad, Shadow, PaintedPath, Underline, and monochrome, subpixel and polychrome sprites.
    • TransformationMatrix.
    • The BoundsTree draw-order R-tree.
    • Layers, finish (stable sort by order and texture), batches, and replay.
  • LICENSE (Apache-2.0) and NOTICE recording that the code is derived from GPUI.

Testing

moon check --target all and moon test --target all pass: 45 tests on each of wasm, wasm-gc, js and native. moon fmt and moon info are clean.

Some tests are ported from GPUI:

  • Pixels to int.
  • Bounds join and intersects.
  • Color hex parsing, alpha, opacity and background tests.
  • The bounds-tree insert test.
  • The randomized bounds-tree test, run over 200 seeds against a brute-force oracle.

Deviations

These are listed in PORTING.md §6:

  • Units are Double rather than f32.
  • PaintedPath stores polygon contours, not lyon-tiled paths.
  • Surfaces, native views and sprite animations are not ported yet.
  • batches() returns an Array.

Ecosystem findings

  • Milky2018/moon_taffy@0.5.3 does not compile on the current toolchain: it hits the new explicit trait-method extend rule. The layout milestone needs a vendored fix.
  • Milky2018/moon_cosmic checks on js and native.

🤖 Generated with Claude Code

First vertical slice of the MoonBit port of Zed's GPUI. ## What's here - **docs/PORTING.md** has six parts: - GPUI architecture summary. - Module map from GPUI to MoonBit packages, split into pure and platform code. - Mooncakes package survey with backend support. - Backend recommendation: js plus Canvas2D first, behind a small `Platform` trait. WebGPU and native come later. - Rust idioms (`dyn Any`/`TypeId`, associated types, `Drop`, macros, async) mapped to MoonBit designs. - Ordered roadmap M0–M12, with open design questions. - **`geometry`**: - Units: `Pixels`, `ScaledPixels`, `DevicePixels`, `Rems`. - Lengths: `AbsoluteLength`, `DefiniteLength`, `Length`, with parsing. - Types: `Point`, `Size`, `Bounds`, `Edges`, `Corners`, `Anchor`, `Axis`, `ContentMask`. - **`color`**: - `Rgba` and `Hsla`, with conversions, hex parsing and blending. - `Background`: solid, linear gradient, slash pattern, checkerboard. - **`scene`**: - Primitives: `Quad`, `Shadow`, `PaintedPath`, `Underline`, and monochrome, subpixel and polychrome sprites. - `TransformationMatrix`. - The `BoundsTree` draw-order R-tree. - Layers, `finish` (stable sort by order and texture), `batches`, and `replay`. - LICENSE (Apache-2.0) and NOTICE recording that the code is derived from GPUI. ## Testing `moon check --target all` and `moon test --target all` pass: 45 tests on each of wasm, wasm-gc, js and native. `moon fmt` and `moon info` are clean. Some tests are ported from GPUI: - Pixels to int. - Bounds join and intersects. - Color hex parsing, alpha, opacity and background tests. - The bounds-tree insert test. - The randomized bounds-tree test, run over 200 seeds against a brute-force oracle. ## Deviations These are listed in PORTING.md §6: - Units are `Double` rather than `f32`. - `PaintedPath` stores polygon contours, not lyon-tiled paths. - Surfaces, native views and sprite animations are not ported yet. - `batches()` returns an `Array`. ## Ecosystem findings - `Milky2018/moon_taffy@0.5.3` does not compile on the current toolchain: it hits the new explicit trait-method `extend` rule. The layout milestone needs a vendored fix. - `Milky2018/moon_cosmic` checks on js and native. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nandi added 1 commit 2026-11-24 21:24:06 +00:00
docs/PORTING.md maps GPUI's architecture onto MoonBit packages, separates
pure logic from platform code, surveys mooncakes packages and their backends,
recommends a js + Canvas2D first backend behind a small Platform trait, lists
the Rust idioms that need a different design, and gives an ordered roadmap.

First slice (pure, tested on wasm, wasm-gc, js and native):
- geometry: Pixels/ScaledPixels/DevicePixels/Rems, Absolute/Definite/Length
  with parsing, Point/Size/Bounds/Edges/Corners, Anchor, Axis, ContentMask
- color: Rgba/Hsla with conversions, hex parsing, blending, Background
  (solid, linear gradient, patterns)
- scene: primitives (Quad, Shadow, Path, Underline, sprites), transformation
  matrix, BoundsTree draw ordering, layers, finish/batches, replay

Derived from Zed's GPUI (Apache-2.0); see LICENSE and NOTICE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nandi added 1 commit 2026-11-24 21:53:39 +00:00
nandi added 1 commit 2026-11-29 06:11:48 +00:00
ci: run moon fmt, check and test on pull requests
CI / moon fmt, check, test (pull_request) Successful in 17s
6d8389a97c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nandi merged commit dc3645fa58 into main 2026-11-29 06:14:37 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: experiments/moon-gpui#1