Skip to main content

Grida IR -- Format Reference

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-canvas/src/node/schema.rs
  • FlatBuffers schema: format/grida.fbs
  • TypeScript model: packages/grida-canvas-schema/grida.ts

Node Types

NodeRust TypeDescription
InitialContainerInitialContainerNodeRecViewport root (like <html>). Structural only, no visual properties.
ContainerContainerNodeRecBox with children. Supports layout, paint, effects, clip.
GroupGroupNodeRecLogical grouping. Blend mode + opacity, no own paint.
TrayTrayNodeRecSpecialized container (component-like).
RectangleRectangleNodeRecFilled/stroked rectangle with corner radius.
EllipseEllipseNodeRecEllipse with arc data (start/end/inner ratio).
LineLineNodeRecStraight line segment.
PathPathNodeRecArbitrary SVG-style path.
PolygonPolygonNodeRecArbitrary polygon vertices.
RegularPolygonRegularPolygonNodeRecN-sided regular polygon.
RegularStarPolygonRegularStarPolygonNodeRecStar with inner/outer radii.
VectorVectorNodeRecVector network (Figma-style).
BooleanOperationBooleanPathOperationNodeRecUnion/subtract/intersect/exclude of child paths.
TextSpanTextSpanNodeRecSingle-style text run.
AttributedTextAttributedTextNodeRecRich text (multiple styled runs).
ImageImageNodeRecRaster image (embedded or referenced).
ErrorErrorNodeRecPlaceholder for failed imports.

Common Properties

Fields shared across most node types:

FieldTypeDescription
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

Geometry

FieldTypeApplies to
sizeSize { width, height }Rectangle, Line, Image, etc.
corner_radiusRectangularCornerRadiusRectangle, Container (per-corner)
corner_smoothingCornerSmoothingRectangle, Container (iOS-style)

Paint

Fills & Strokes

Both use Paints (ordered list of Paint):

Paint VariantDescription
SolidSolidPaint { color, blend_mode, active }
LinearGradientStart/end points, color stops
RadialGradientCenter, radius, color stops
SweepGradientCenter, start/end angle, color stops
ImageImagePaint { src, fit, tile }

Stroke Properties

FieldType
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_limitStrokeMiterLimit
stroke_style.stroke_dash_arrayOption<StrokeDashArray>

Layout

Container Layout (LayoutContainerStyle)

FieldTypeDescription
layout_modeLayoutModeNormal or Flex
layout_directionAxisHorizontal or Vertical
layout_wrapOption<LayoutWrap>NoWrap or Wrap
layout_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

Child Layout (LayoutChildStyle)

FieldTypeDescription
layout_growf32Flex grow factor (0.0 = no grow)
layout_positioningLayoutPositioningAuto or Absolute

Not yet in schema: flex-shrink, margin, align-self, order.

Dimensions (LayoutDimensionStyle)

FieldType
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)>

Effects (LayerEffects)

FieldTypeDescription
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

Shadow (FeShadow)

FeShadow { dx, dy, blur, spread, color, active }

Wrapped in FilterShadowEffect::DropShadow(FeShadow) or FilterShadowEffect::InnerShadow(FeShadow).

Blend Modes (BlendMode)

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.

Text

TextSpanNodeRec

FieldType
textString
text_styleTextStyleRec
text_alignTextAlign (Left, Right, Center, Justify)
text_align_verticalTextAlignVertical (Top, Center, Bottom)
widthOption<f32> (wrapping width)
heightOption<f32> (container height for vertical alignment)

TextStyleRec

FieldType
font_sizef32
font_weightFontWeight(u32)
font_familyString
font_style_italicbool
line_heightTextLineHeight (Factor or Fixed)
letter_spacingTextLetterSpacing (Fixed or Percentage)
word_spacingTextWordSpacing (Fixed or Percentage)
text_transformTextTransform (None, Uppercase, Lowercase, Capitalize)
text_decorationOption<TextDecorationRec>

TextDecorationRec

FieldType
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>

Clip / Overflow

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.

Transform (AffineTransform)

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.