Add porting plan and first pure slice: geometry, color, scene

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>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-24 21:23:48 +00:00
1 parent b9d1949688
commit 8c0685fe01
24 files changed
+5856 -1

No files matched your search

+124
View File
@@ -0,0 +1,124 @@
// Generated using `moon info`, DON'T EDIT IT
package "experiments/gpui/color"
import {
"moonbitlang/core/debug",
}
// Values
pub fn black() -> Hsla
pub fn blue() -> Hsla
pub fn checkerboard(Hsla, Double) -> Background
pub fn green() -> Hsla
pub fn hsla(Double, Double, Double, Double) -> Hsla
pub fn linear_color_stop(Hsla, Double) -> LinearColorStop
pub fn linear_gradient(Double, LinearColorStop, LinearColorStop) -> Background
pub fn opaque_grey(Double, Double) -> Hsla
pub fn pattern_slash(Hsla, Double, Double) -> Background
pub fn red() -> Hsla
pub fn rgb(UInt32) -> Rgba
pub fn rgba(UInt32) -> Rgba
pub fn solid_background(Hsla) -> Background
pub fn transparent_black() -> Hsla
pub fn transparent_white() -> Hsla
pub fn white() -> Hsla
pub fn yellow() -> Hsla
// Errors
#derive(@debug.Debug)
pub suberror ColorParseError {
ColorParseError(input~ : String, reason~ : String)
}
// Types and methods
#derive(Default, Eq, @debug.Debug)
pub(all) struct Background {
tag : BackgroundTag
color_space : ColorSpace
solid : Hsla
gradient_angle_or_pattern_height : Double
colors : (LinearColorStop, LinearColorStop)
}
pub fn Background::as_solid(Self) -> Hsla?
pub fn Background::is_transparent(Self) -> Bool
pub fn Background::opacity(Self, Double) -> Self
pub fn Background::with_color_space(Self, ColorSpace) -> Self
#derive(Eq, @debug.Debug)
pub(all) enum BackgroundTag {
Solid
LinearGradient
PatternSlash
Checkerboard
}
pub impl Default for BackgroundTag
#derive(Eq, @debug.Debug)
pub(all) enum ColorSpace {
Srgb
Oklab
}
pub impl Default for ColorSpace
pub impl Show for ColorSpace
#derive(Compare, Default, Eq, @debug.Debug)
pub(all) struct Hsla {
h : Double
s : Double
l : Double
a : Double
}
pub fn Hsla::alpha(Self, Double) -> Self
pub fn Hsla::blend(Self, Self) -> Self
pub fn Hsla::fade_out(Self, Double) -> Self
pub fn Hsla::grayscale(Self) -> Self
pub fn Hsla::is_opaque(Self) -> Bool
pub fn Hsla::is_transparent(Self) -> Bool
pub fn Hsla::opacity(Self, Double) -> Self
pub fn Hsla::to_background(Self) -> Background
pub fn Hsla::to_rgb(Self) -> Rgba
pub impl Show for Hsla
#derive(Default, Eq, @debug.Debug)
pub(all) struct LinearColorStop {
color : Hsla
percentage : Double
}
pub fn LinearColorStop::opacity(Self, Double) -> Self
#derive(Default, Eq, @debug.Debug)
pub(all) struct Rgba {
r : Double
g : Double
b : Double
a : Double
}
pub fn Rgba::alpha(Self, Double) -> Self
pub fn Rgba::blend(Self, Self) -> Self
pub fn Rgba::opacity(Self, Double) -> Self
pub fn Rgba::parse(String) -> Self raise ColorParseError
pub fn Rgba::to_background(Self) -> Background
pub fn Rgba::to_hex(Self) -> String
pub fn Rgba::to_hsla(Self) -> Hsla
pub fn Rgba::to_u32(Self) -> UInt32
pub impl Show for Rgba
// Type aliases
// Traits