Grida IR
The Grida IR is the in-memory scene graph used by all Grida rendering, layout, and editing pipelines. It is the single representation that CSS, HTML, SVG, and .grida files all target.
Canonical sources:
Rust runtime model: crates/grida/src/node/schema.rs
FlatBuffers schema: format/grida.fbs
TypeScript model: packages/grida-canvas-schema/grida.ts
Node Rust Type Description InitialContainer InitialContainerNodeRecViewport root (like <html>). Structural only, no visual properties. Container ContainerNodeRecBox with children. Supports layout, paint, effects, clip. Group GroupNodeRecLogical grouping. Blend mode + opacity, no own paint. Tray TrayNodeRecSpecialized container (component-like). Rectangle RectangleNodeRecFilled/stroked rectangle with corner radius. Ellipse EllipseNodeRecEllipse with arc data (start/end/inner ratio). Line LineNodeRecStraight line segment. Path PathNodeRecArbitrary SVG-style path. Polygon PolygonNodeRecArbitrary polygon vertices. RegularPolygon RegularPolygonNodeRecN-sided regular polygon. RegularStarPolygon RegularStarPolygonNodeRecStar with inner/outer radii. Vector VectorNodeRecVector network (Figma-style). BooleanOperation BooleanPathOperationNodeRecUnion/subtract/intersect/exclude of child paths. TextSpan TextSpanNodeRecSingle-style text run. AttributedText AttributedTextNodeRecRich text (multiple styled runs). Image ImageNodeRecRaster image (embedded or referenced). Error ErrorNodeRecPlaceholder for failed imports.
Fields shared across most node types:
Field Type Description activeboolWhether node is visible/active opacityf320.0 (transparent) to 1.0 (opaque) blend_modeLayerBlendModePassThrough or Blend(BlendMode) transformAffineTransform2D affine (3x2 matrix) maskOption<LayerMaskType>Alpha or luminance mask effectsLayerEffectsBlur, backdrop blur, shadows, glass, noise
Field Type Applies to sizeSize { width, height }Rectangle, Line, Image, etc. corner_radiusRectangularCornerRadiusRectangle, Container (per-corner) corner_smoothingCornerSmoothingRectangle, Container (iOS-style)
Both use Paints (ordered list of Paint):
Paint Variant Description SolidSolidPaint { color, blend_mode, active }LinearGradientStart/end points, color stops RadialGradientCenter, radius, color stops SweepGradientCenter, start/end angle, color stops ImageImagePaint { src, fit, tile }
Field Type stroke_widthStrokeWidth (Uniform f32 or Rectangular per-side)stroke_style.stroke_alignStrokeAlign (Inside, Outside, Center)stroke_style.stroke_capStrokeCap (Butt, Round, Square)stroke_style.stroke_joinStrokeJoin (Miter, Round, Bevel)stroke_style.stroke_miter_limitStrokeMiterLimitstroke_style.stroke_dash_arrayOption<StrokeDashArray>
Field Type Description layout_modeLayoutModeNormal or Flexlayout_directionAxisHorizontal or Verticallayout_wrapOption<LayoutWrap>NoWrap or Wraplayout_main_axis_alignmentOption<MainAxisAlignment>Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly, Stretch layout_cross_axis_alignmentOption<CrossAxisAlignment>Start, Center, End, Stretch layout_paddingOption<EdgeInsets>top, right, bottom, left layout_gapOption<LayoutGap>main_axis_gap, cross_axis_gap
Field Type Description layout_growf32Flex grow factor (0.0 = no grow) layout_positioningLayoutPositioningAuto or Absolute
Not yet in schema: flex-shrink, margin, align-self, order.
Field Type layout_target_widthOption<f32>layout_target_heightOption<f32>layout_min_widthOption<f32>layout_max_widthOption<f32>layout_min_heightOption<f32>layout_max_heightOption<f32>layout_target_aspect_ratioOption<(f32, f32)>
Field Type Description blurOption<FeLayerBlur>Layer blur (Gaussian or Progressive) backdrop_blurOption<FeBackdropBlur>Backdrop blur shadowsVec<FilterShadowEffect>DropShadow or InnerShadow glassOption<FeLiquidGlass>Liquid glass effect noisesVec<FeNoiseEffect>Noise grain effects
FeShadow { dx, dy, blur, spread, color, active }
Wrapped in FilterShadowEffect::DropShadow(FeShadow) or FilterShadowEffect::InnerShadow(FeShadow).
Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity.
LayerBlendMode::PassThrough = non-isolated (children blend with backdrop).
LayerBlendMode::Blend(mode) = isolated compositing with specified mode.
Field Type textStringtext_styleTextStyleRectext_alignTextAlign (Left, Right, Center, Justify)text_align_verticalTextAlignVertical (Top, Center, Bottom)widthOption<f32> (wrapping width)heightOption<f32> (container height for vertical alignment)
Field Type font_sizef32font_weightFontWeight(u32)font_familyStringfont_style_italicboolline_heightTextLineHeight (Factor or Fixed)letter_spacingTextLetterSpacing (Fixed or Percentage)word_spacingTextWordSpacing (Fixed or Percentage)text_transformTextTransform (None, Uppercase, Lowercase, Capitalize)text_decorationOption<TextDecorationRec>
Field Type text_decoration_lineTextDecorationLine (None, Underline, Overline, LineThrough)text_decoration_colorOption<CGColor>text_decoration_styleOption<TextDecorationStyle> (Solid, Double, Dotted, Dashed, Wavy)text_decoration_skip_inkOption<bool>text_decoration_thicknessOption<f32>
ContainerNodeRec.clip: bool -- when true, children are clipped to the container's rounded-rect bounds. The container's own stroke and outer effects are not clipped.
2D affine transform as a 3x2 matrix:
| m00 m01 m02 | | scaleX skewX translateX |
| m10 m11 m12 | = | skewY scaleY translateY |
| 0 0 1 | | 0 0 1 |
Identity = [[1,0,0],[0,1,0]]. Every node with geometry has a transform field.