meo-canvas - v8.0.1
    Preparing search index...

    Interface RootPropsWithWorkerBase

    Root props when worker mode is enabled (default behavior). Includes .release() method for memory cleanup.

    interface RootPropsWithWorkerBase {
        alignContent?: Align;
        alignItems?: Align;
        alignSelf?: Align;
        aspectRatio?: number;
        backgroundColor?: string;
        border?:
            | number
            | Partial<
                Record<
                    | "Top"
                    | "Bottom"
                    | "Left"
                    | "Right"
                    | "Start"
                    | "End"
                    | "Horizontal"
                    | "Vertical"
                    | "All",
                    number,
                >,
            >;
        borderColor?: string
        | EdgeColors;
        borderRadius?: number | CornerRadii;
        borderStyle?: Solid | Dashed | Dotted;
        boxShadow?: BoxShadowProps | BoxShadowProps[];
        boxSizing?: BoxSizing;
        children?: Children | Children[] | PageBuilder;
        color?: string;
        colorSpace?: ColorSpace;
        colorType?: ColorType;
        direction?: Direction;
        display?: Display;
        dither?: boolean;
        duration?: number;
        flexBasis?: number | "auto" | `${number}%`;
        flexDirection?: FlexDirection;
        flexGrow?: number;
        flexShrink?: number;
        flexWrap?: Wrap;
        fontFamily?: string;
        fonts?: FontRegistrationInfo[];
        fontSize?: number;
        fontStyle?: "normal" | "italic";
        fontVariant?: FontVariantSetting;
        fontWeight?:
            | number
            | "bold"
            | "normal"
            | "100"
            | "200"
            | "300"
            | "400"
            | "500"
            | "600"
            | "700"
            | "800"
            | "900";
        fps?: number;
        gap?: | number
        | `${number}%`
        | Partial<Record<"All" | "Column" | "Row", number | `${number}%`>>;
        gpu?: boolean;
        gradient?: Gradient;
        height?: number;
        imageConcurrency?: number;
        justifyContent?: Justify;
        key?: string;
        letterSpacing?: number | "normal" | `${number}px` | `${number}em`;
        lineGap?: number;
        lineHeight?: number;
        margin?:
            | number
            | "auto"
            | `${number}%`
            | Partial<
                Record<
                    | "Top"
                    | "Bottom"
                    | "Left"
                    | "Right"
                    | "Start"
                    | "End"
                    | "Horizontal"
                    | "Vertical"
                    | "All",
                    number
                    | "auto"
                    | `${number}%`,
                >,
            >;
        mask?: Mask;
        maxHeight?: number | `${number}%`;
        maxWidth?: number | `${number}%`;
        minHeight?: number | `${number}%`;
        minWidth?: number | `${number}%`;
        name?: string;
        opacity?: number;
        overflow?: Overflow;
        padding?:
            | number
            | `${number}%`
            | Partial<
                Record<
                    | "Top"
                    | "Bottom"
                    | "Left"
                    | "Right"
                    | "Start"
                    | "End"
                    | "Horizontal"
                    | "Vertical"
                    | "All",
                    number
                    | `${number}%`,
                >,
            >;
        pages?: number;
        position?:
            | number
            | `${number}%`
            | Partial<
                Record<
                    | "Top"
                    | "Bottom"
                    | "Left"
                    | "Right"
                    | "Start"
                    | "End"
                    | "Horizontal"
                    | "Vertical"
                    | "All",
                    number
                    | `${number}%`,
                >,
            >;
        positionType?: PositionType;
        scale?: number;
        textAlign?: "center" | "end" | "left" | "right" | "start" | "justify";
        textDecoration?:
            | "none"
            | string & {}
            | "underline"
            | "overline"
            | "line-through";
        transform?: TransformProps;
        useDiskCache?: boolean;
        verticalAlign?: "bottom"
        | "middle"
        | "top";
        width: number;
        wordSpacing?: number | "normal" | `${number}px` | `${number}em`;
        workerMode?: true;
        workers?: number;
        zIndex?: number;
    }

    Hierarchy (View Summary)

    Index
    alignContent?: Align

    Defines how lines are distributed along the cross axis when flexWrap is WRAP or WRAP_REVERSE. Has no effect when there is only one line of flex items.

    Yoga default (FLEX_START)

    alignItems?: Align

    Defines how flex items are aligned along the cross axis of the container.

    Yoga default (STRETCH)

    alignSelf?: Align

    Allows overriding the parent's alignItems value for a specific flex item.

    Yoga default (AUTO) - Inherits from alignItems.

    aspectRatio?: number

    Locks the aspect ratio (width / height) of the node. If set, Yoga might adjust the height based on the calculated width or vice versa.

    Ratio (e.g., 16 / 9).

    Yoga default (undefined)
    
    backgroundColor?: string

    Sets the background color of the node. Drawn beneath the content and padding, extending to the border edge. Accepts standard CSS color strings.

    undefined (transparent)
    
    border?:
        | number
        | Partial<
            Record<
                | "Top"
                | "Bottom"
                | "Left"
                | "Right"
                | "Start"
                | "End"
                | "Horizontal"
                | "Vertical"
                | "All",
                number,
            >,
        >

    Sets the width of the node's border. Can be a single number for all edges or an object specifying individual edges.

    Pixels.

    Yoga default (0 for each edge)
    
    borderColor?: string | EdgeColors

    Colour of the node's border — one colour for every edge, or a colour per edge.

    Accepts standard CSS colour strings ('red', '#FF0000', 'rgba(255,0,0,0.5)'). Given an object, an edge left out falls back to black. Where two edges of different colours meet at a rounded corner the arc is split between them, as CSS joins them.

    'black' (set in BoxNode constructor)
    
    Box({ border: 2, borderColor: '#cbd5e1' })
    Box({ border: { Left: 4 }, borderColor: { Left: '#2563eb' } })
    borderRadius?: number | CornerRadii

    Sets the radius of the node's corners, creating rounded effects. Can be a single number for all corners or an object specifying individual corners (TopLeft, TopRight, BottomLeft, BottomRight).

    Pixels.

    undefined (no rounding)
    
    borderStyle?: Solid | Dashed | Dotted

    Sets the style of the node's border.

    • Style.Border.Solid (0)
    • Style.Border.Dashed (1)
    • Style.Border.Dotted (2)
    Style.Border.Solid (set in BoxNode constructor)
    

    Applies one or more box-shadow effects to the node. Can be a single shadow object or an array of shadow objects. Shadows are drawn in the order specified.

    BoxShadowProps

    undefined (no shadow)
    
    boxSizing?: BoxSizing

    Defines how the width and height properties are interpreted regarding padding and border. CONTENT_BOX: Width/height apply only to the content area. Padding and border are added outside. BORDER_BOX: Width/height include content, padding, and border.

    Style.BoxSizing (CONTENT_BOX, BORDER_BOX)

    Style.BOX_SIZING_BORDER_BOX (set in setLayout)

    children?: Children | Children[] | PageBuilder

    Content to draw.

    Pass elements for a single-page render, or a function to render a sequence — one page per call. The function form requires either RootProps.pages or RootProps.duration.

    color?: string

    Text color. Accepts standard CSS color strings.

    'black'
    
    colorSpace?: ColorSpace

    Space the canvas composites in.

    Fixed for the whole render rather than chosen per export: colours are interpreted in it, and one outside its gamut is clipped as it is drawn. Exports convert out of it when asked.

    'srgb'
    
    colorType?: ColorType

    Pixel format the canvas composites in.

    Governs the precision everything is drawn at, and the depth the encoded formats that carry one write. RGBAF32 keeps colour outside sRGB rather than clipping it as it is drawn, and is what a sixteen-bit PNG or a wide-gamut export needs — at the cost of the CPU backend, since no GPU composites float.

    'rgba'
    
    direction?: Direction

    Sets the primary text and layout direction (Left-to-Right or Right-to-Left). Affects the meaning of Start and End edges for properties like position, margin, padding, border. INHERIT: Uses the direction of the parent node.

    Style.DIRECTION_LTR (set in setLayout)

    display?: Display

    Controls whether the node and its children are included in the layout calculation and rendering. FLEX: The node participates in a flex layout. NONE: The node and its subtree are ignored by layout and rendering.

    Yoga default (FLEX)

    dither?: boolean

    Dither this node's drawing, trading a little noise for the banding an eight-bit surface shows across a long, subtle gradient.

    Costs nothing where nothing bands: a flat fill, text and a blurred shadow encode to identical bytes either way, because a dither only perturbs a pixel whose colour falls between two the surface can hold. On a gradient reckon on about a third again the PNG bytes, and near nothing for WebP or JPEG, whose quantizers absorb the noise.

    Inherited by descendants, so setting it on Root covers the page and a node overrides it for its own subtree without touching its siblings. Pointless under a float colorType, which has the precision to draw the ramp outright.

    false
    
    Root({ width: 800, dither: true, children: [
    Box({ height: 400, gradient: { type: 'linear', direction: 'to-bottom', colors: ['#0b1220', '#1e2b4a'] } }),
    Box({ dither: false, children: [Text({ children: 'left alone' })] }),
    ] })
    duration?: number

    Length of the sequence in seconds; the page count becomes ceil(duration * fps). Mutually exclusive with RootProps.pages, and only meaningful when children is a function.

    flexBasis?: number | "auto" | `${number}%`

    Defines the default size of a flex item along the main axis before the remaining space is distributed.

    Pixels.

    Yoga default (AUTO)

    flexDirection?: FlexDirection

    Defines the direction of the main axis for flex items within this container.

    Yoga default (COLUMN)

    flexGrow?: number

    Defines the ability of a flex item to grow if necessary, relative to other items. A non-negative number indicating the proportion of available space the item should take.

    Yoga default (0) - Item does not grow.
    
    flexShrink?: number

    Defines the ability of a flex item to shrink if necessary, relative to other items. A non-negative number indicating the proportion of overflow space the item should lose.

    Yoga default (1 for non-root nodes, 0 for root) - Item can shrink.
    
    flexWrap?: Wrap

    Controls whether flex items are forced onto a single line or can wrap onto multiple lines.

    Yoga default (NO_WRAP)

    fontFamily?: string

    Font family (e.g., 'Arial', 'Helvetica', 'sans-serif'). Ensure the font is available in the rendering environment.

    'sans-serif'
    

    Font files to register for use in the canvas.

    fontSize?: number

    Font size.

    Pixels.

    16
    
    fontStyle?: "normal" | "italic"

    Font style.

    'normal'
    
    fontVariant?: FontVariantSetting

    Specifies font variation settings. Provides fine control over font variation axis. Accepts string in CSS font-variation-settings format.

    "normal" | "historical-forms" | "small-caps" | "all-small-caps" | "petite-caps" | "all-petite-caps" | "unicase" | "titling-caps" | "lining-nums" | "oldstyle-nums" | "proportional-nums" | ...
    
    undefined
    
    fontWeight?:
        | number
        | "bold"
        | "normal"
        | "100"
        | "200"
        | "300"
        | "400"
        | "500"
        | "600"
        | "700"
        | "800"
        | "900"

    Font weight (e.g., 'normal', 'bold', 400, 700).

    'normal'
    
    fps?: number

    Frame rate used to derive RootProps.duration and PageInfo.time. Defaults to 30.

    This describes the render, not the encode: pass fps to toBuffer('gif', { fps }) as well if the encoded animation should play at this rate.

    gap?:
        | number
        | `${number}%`
        | Partial<Record<"All" | "Column" | "Row", number | `${number}%`>>

    Defines the space between flex items along the main axis.

    Pixels.

    Yoga default (0)
    
    gpu?: boolean

    Rasterize on the GPU when one is available. false forces the CPU backend.

    Asking is not getting: a build without GPU support, a driver that declines, and a float colorType all fall back to the CPU. The rendered canvas reports what it settled on through gpu and engine.

    Set it false for output that must be identical between machines — GPU and CPU rasterizers resolve anti-aliased edges a level or two apart, which a pixel comparison sees.

    true
    
    gradient?: Gradient

    Sets a linear gradient as the background. Overrides backgroundColor if provided. colors: Array of CSS color strings for the gradient stops. direction: Array of four numbers [x0, y0, x1, y1] defining the start and end points of the gradient line, relative to the node's top-left corner.

    undefined
    
    height?: number

    Optional height of the canvas in pixels. If not set, height is calculated from content.

    imageConcurrency?: number

    Maximum number of images to fetch concurrently during render.

    5
    
    justifyContent?: Justify

    Defines how flex items are distributed along the main axis of the container.

    Yoga default (FLEX_START)

    key?: string

    Optional key identifier for component reconciliation.

    letterSpacing?: number | "normal" | `${number}px` | `${number}em`

    Sets the spacing between letters (tracking). Accepts CSS units like 'normal', '2px', '0.1em'.

    lineGap?: number

    Additional vertical spacing between lines of text.

    Pixels.

    0
    
    lineHeight?: number

    Height of each line box.

    Left unset, a line is the face's own height — its ascent plus its descent — which is what line-height: normal means in CSS and is a little over 1.3em for most text faces. Set smaller than that and the lines overlap rather than the box quietly growing, again as CSS does.

    Pixels.

    undefined (the face's own height)
    
    margin?:
        | number
        | "auto"
        | `${number}%`
        | Partial<
            Record<
                | "Top"
                | "Bottom"
                | "Left"
                | "Right"
                | "Start"
                | "End"
                | "Horizontal"
                | "Vertical"
                | "All",
                number
                | "auto"
                | `${number}%`,
            >,
        >

    Sets the margin space on the outside of the node's border. Can be a single number for all edges or an object specifying individual edges.

    Pixels.

    Yoga default (0 for each edge)
    
    mask?: Mask

    Limits what of this node is drawn — see Mask.

    Covers everything the node renders, its background, border, content and children alike. A shape or path clips; a gradient fades. Inherited by every component, so Text, Image, Chart and Grid take it too.

    undefined (nothing masked)
    
    Image({ src: avatar, width: 96, height: 96, mask: { shape: 'circle' } })
    Box({ mask: { gradient: { type: 'linear', direction: 'to-bottom', colors: ['#000', 'transparent'] } } })
    maxHeight?: number | `${number}%`

    Sets the maximum height of the node.

    Pixels if it's number, percentage of the parent's height if it's string.

    Yoga default (undefined / infinity)
    
    maxWidth?: number | `${number}%`

    Sets the maximum width of the node.

    Pixels if it's number, percentage of the parent's width if it's string.

    Yoga default (undefined / infinity)
    
    minHeight?: number | `${number}%`

    Sets the minimum height of the node.

    Pixels if it's number, percentage of the parent's height if it's string.

    Yoga default (0)
    
    minWidth?: number | `${number}%`

    Sets the minimum width of the node.

    Pixels if it's number, percentage of the parent's width if it's string.

    Yoga default (0)
    
    name?: string

    Optional display name for debugging purposes.

    opacity?: number

    Sets the opacity of the node and its children when drawing. A value between 0 (fully transparent) and 1 (fully opaque).

    The node's whole drawing — background, border, content and children — is composited once and then faded, as CSS does. Two overlapping children inside a half-transparent parent are exactly as dark as one of them, rather than compounding into a darker patch where they meet.

    Nesting multiplies: a child at 0.5 inside a parent at 0.5 draws at 0.25 against the page.

    1
    
    overflow?: Overflow

    Defines how content that overflows the node's bounds is handled. VISIBLE: Content is not clipped and may render outside the node's box. HIDDEN: Content is clipped and the rest is invisible. SCROLL: Yoga lays the node out as a scroll container, but nothing is clipped — a scroll container is a box a reader moves, and nothing here is interactive. It draws as VISIBLE.

    Yoga default (VISIBLE)

    padding?:
        | number
        | `${number}%`
        | Partial<
            Record<
                | "Top"
                | "Bottom"
                | "Left"
                | "Right"
                | "Start"
                | "End"
                | "Horizontal"
                | "Vertical"
                | "All",
                number
                | `${number}%`,
            >,
        >

    Sets the padding space on the inside of the node's border, around the content. Can be a single number for all edges or an object specifying individual edges.

    Pixels.

    Yoga default (0 for each edge)
    
    pages?: number

    Number of pages to render. Mutually exclusive with RootProps.duration. Only meaningful when children is a function.

    position?:
        | number
        | `${number}%`
        | Partial<
            Record<
                | "Top"
                | "Bottom"
                | "Left"
                | "Right"
                | "Start"
                | "End"
                | "Horizontal"
                | "Vertical"
                | "All",
                number
                | `${number}%`,
            >,
        >

    Specifies the offset distances for positioned elements (positionType: 'ABSOLUTE' or RELATIVE). Can be a single number for all edges or an object specifying individual edges (Top, Right, Bottom, Left, Start, End). Start and End are affected by direction (LTR/RTL).

    Pixels.

    Yoga default (undefined for each edge)
    
    positionType?: PositionType

    Specifies the positioning method used for the node. RELATIVE: Positioned according to the normal flow, then offset relative to that position. ABSOLUTE: Taken out of the flow and positioned against its immediate parent.

    That last part is where this differs from CSS, and the difference is Yoga's rather than this library's. CSS resolves an absolute node against the nearest positioned ancestor, skipping every static box in between; Yoga always uses the parent, whether or not it is positioned. A layout ported from the browser that relies on skipping an intermediate box will land somewhere else — give the node's own parent the offsets instead.

    Yoga default (RELATIVE)

    scale?: number

    Scale factor for high-DPI rendering.

    1
    
    2 // For 2x Retina displays
    
    textAlign?: "center" | "end" | "left" | "right" | "start" | "justify"

    Horizontal text alignment within the node's bounds.

    'left'
    
    textDecoration?:
        | "none"
        | string & {}
        | "underline"
        | "overline"
        | "line-through"

    Lines drawn on the text, in the notation CSS text-decoration uses.

    A line keyword on its own is the common case; a style, a colour and a thickness may follow in any order, and two line keywords may be combined. Anything that does not parse draws nothing rather than throwing. Inherited, so a heading and its nested spans are decorated together.

    undefined (no lines)
    
    Text('Sold out', { textDecoration: 'line-through' })
    Text('Heading', { textDecoration: 'underline 3px #2563eb' })
    Text('Misspelt', { textDecoration: 'underline wavy #dc2626' })
    Text('Both', { textDecoration: 'underline line-through' })
    transform?: TransformProps

    Defines the 2D transformations (translate, rotate, scale) applied to the node after layout.

    TransformProps

    undefined (no transformation)
    
    useDiskCache?: boolean

    Write fetched images to disk during this render for faster re-decode when the same source appears multiple times. Disk entries are deleted when the render completes — no cross-render sharing.

    false
    
    verticalAlign?: "bottom" | "middle" | "top"

    Vertical text alignment within the node's bounds. Note: Simple implementation aligns based on the first line.

    'top'
    
    width: number

    Width of the canvas in pixels. Required — everything else can be derived from the content, but text cannot wrap without knowing how much room it has.

    wordSpacing?: number | "normal" | `${number}px` | `${number}em`

    Sets the spacing between words. Accepts CSS units like 'normal', '10px', '0.5em'. This space is added to the intrinsic width of the space character.

    workerMode?: true

    Worker mode enabled or default (undefined defaults to true).

    workers?: number

    Number of worker threads (only available in worker mode).

    zIndex?: number

    Stack order among absolutely positioned siblings. A larger value paints over a smaller one, and equal values paint in the order they were declared.

    Only absolutely positioned nodes take part. An in-flow child is painted in flow order and is never lifted by a zIndex.

    Leaving it unset is CSS's z-index: auto, which shares a layer with 0 — so an absolutely positioned child still paints above in-flow siblings, whether it is declared before or after them. A negative value puts it below them instead, which is how a decoration is placed behind the content of its own parent.

    Box({
    positionType: Style.PositionType.Relative,
    children: [
    // Behind the content, though it is declared first.
    Box({ positionType: Style.PositionType.Absolute, zIndex: -1, backgroundColor: '#eef' }),
    Text('over the decoration'),
    ],
    })