revideo-psdtool
    Preparing search index...

    Class Psd

    Hierarchy

    • Img
      • Psd
    Index

    Constructors

    Properties

    Accessors

    Methods

    [iterator] absoluteOpacity add anchorPosition appendedToView applyFlex applyFont applyState applyStyle applyText arcLength baseArcLength cacheBBox cacheCanvas cachedCanvas childAs childrenAs childrenBBox clone collectAsyncResources completion compositeRoot compositeToLocal compositeToWorld computedPosition computedSize curveDrawingInfo desiredSize dispose distanceToPercentage draw drawChildren drawOverlay drawRipple drawShape filledImageCanvas filterString findAll findAncestor findFirst findLast fullCacheBBox getAbsolutePosition getAbsoluteRotation getAbsoluteScale getCacheBBox getChildren getColorAtPoint getComputedLayout getHeight getOriginDelta getPath getPixelColor getPointAtDistance getPointAtPercentage getRipplePath getSpawner getState getWidth getX getY hasFilters hasShadow hit image imageCanvas insert instantiate isLayoutRoot layoutChildren layoutEnabled lineWidthCoefficient localToParent localToWorld lockSize move moveAbove moveBelow moveDown moveOffset moveTo moveToBottom moveToTop moveUp naturalSize offsetArcLength offsetComputedLayout parentAs parentTransform parentWorldSpaceCacheBBox parseChildren parseLength parsePixels peekChildren percentageToDistance processSubpath profile reactiveClone releaseSize remove removeChild removeChildren render renderFromSource reparent requestFontUpdate requestLayoutUpdate requiresCache requiresProfile restore ripple rippleSize save scalingRotationMatrix setAbsolutePosition setAbsoluteRotation setAbsoluteScale setChildren setHeight setParsedChildren setSpawner setupDrawFromCache setWidth setX setY snapshotClone sortedChildren spawnChildren spawnedChildren toPromise transformContext tweenCompositeOperation tweenHeight tweenSize tweenWidth updateLayout view worldSpaceCacheBBox worldToLocal worldToParent

    Constructors

    • Parameters

      • props: PsdProps

      Returns Psd

    Properties

    "[NODE_NAME]": string
    absolutePosition: SimpleVector2Signal<Psd>

    A helper signal for operating on the position in world space.

    Retrieving the position using this signal returns the position in world space. Similarly, setting the position using this signal transforms the new value to local space.

    If the new value is a function, the position of this node will be continuously updated to always match the position returned by the function. This can be useful to "pin" the node in a specific place or to make it follow another node's position.

    Unlike position, this signal is not compound - it doesn't contain separate signals for the x and y components.

    absoluteRotation: SimpleSignal<number, Psd>

    A helper signal for operating on the rotation in world space.

    Retrieving the rotation using this signal returns the rotation in world space. Similarly, setting the rotation using this signal transforms the new value to local space.

    If the new value is a function, the rotation of this node will be continuously updated to always match the rotation returned by the function.

    absoluteScale: SimpleVector2Signal<Psd>

    A helper signal for operating on the scale in world space.

    Retrieving the scale using this signal returns the scale in world space. Similarly, setting the scale using this signal transforms the new value to local space.

    If the new value is a function, the scale of this node will be continuously updated to always match the position returned by the function.

    Unlike scale, this signal is not compound - it doesn't contain separate signals for the x and y components.

    alignContent: SimpleSignal<FlexContent, Psd>
    alignItems: SimpleSignal<FlexItems, Psd>
    alignSelf: SimpleSignal<FlexItems, Psd>
    alpha: SimpleSignal<number, Psd>

    The alpha value of this image.

    Unlike opacity, the alpha value affects only the image itself, leaving the fill, stroke, and children intact.

    antialiased: SimpleSignal<boolean, Psd>
    arrowSize: SimpleSignal<number, Psd>

    Controls the size of the end and start arrows.

    To make the arrows visible make sure to enable startArrow and/or endArrow.

    basis: SimpleSignal<FlexBasis, Psd>
    bottom: SimpleVector2Signal<Psd>

    The position of the bottom edge of this node.

    When set, this shortcut property will modify the node's position so that the bottom edge ends up in the given place.

    When retrieved, it will return the position of the bottom edge in the parent space.

    bottomLeft: SimpleVector2Signal<Psd>

    The position of the bottom left corner of this node.

    When set, this shortcut property will modify the node's position so that the bottom left corner ends up in the given place.

    When retrieved, it will return the position of the bottom left corner in the parent space.

    bottomRight: SimpleVector2Signal<Psd>

    The position of the bottom right corner of this node.

    When set, this shortcut property will modify the node's position so that the bottom right corner ends up in the given place.

    When retrieved, it will return the position of the bottom right corner in the parent space.

    cache: SimpleSignal<boolean, Psd>
    cachePadding: SpacingSignal<Psd>

    Controls the padding of the cached canvas used by this node.

    By default, the size of the cache is determined based on the bounding box of the node and its children. That includes effects such as stroke or shadow. This property can be used to expand the cache area further. Usually used to account for custom effects created by shaders.

    canHaveSubpath: boolean
    children: Signal<ComponentChildren, Node[], Psd>
    clip: SimpleSignal<boolean, Psd>
    closed: SimpleSignal<boolean, Psd>

    Whether the curve should be closed.

    Closed curves have their start and end points connected.

    composite: SimpleSignal<boolean, Psd>
    compositeOperation: SimpleSignal<GlobalCompositeOperation, Psd>
    cornerSharpness: SimpleSignal<number, Psd>

    Controls the sharpness of smoothCorners.

    This property only affects the way rounded corners are drawn. To control the corner radius use the radius property.

    Requires smoothCorners to be enabled to have any effect. By default, corner sharpness is set to 0.6 which represents a smooth, circle-like rounding. At 0 the edges are squared off.

    <Rect
    size={300}
    smoothCorners={true}
    cornerSharpness={0.7}
    />
    creationStack?: string
    direction: SimpleSignal<FlexDirection, Psd>
    element: HTMLElement
    end: SimpleSignal<number, Psd>

    A percentage from the start after which the curve should be clipped.

    The portion of the curve that comes after the given percentage will be made invisible.

    This property is usefully for animating the curve appearing on the screen. The value of 0 means the very start of the curve (accounting for the startOffset) while 1 means the very end (accounting for the endOffset).

    endArrow: SimpleSignal<boolean, Psd>

    Whether to display an arrow at the end of the visible curve.

    Use arrowSize to control the size of the arrow.

    endOffset: SimpleSignal<number, Psd>

    The offset in pixels from the end of the curve.

    This property lets you specify where along the defined curve the actual visible portion ends. For example, setting it to 20 will make the last 20 pixels of the curve invisible.

    This property is useful for trimming the curve using a fixed distance. If you want to animate the curve appearing on the screen, use end instead.

    fill: CanvasStyleSignal<Psd>
    filters: FiltersSignal<Psd>
    fontFamily: SimpleSignal<string, Psd>
    fontSize: SimpleSignal<number, Psd>
    fontStyle: SimpleSignal<string, Psd>
    fontWeight: SimpleSignal<number, Psd>
    gap: Vector2LengthSignal<Psd>
    grow: SimpleSignal<number, Psd>
    hasSpawnedChildren: boolean
    isClass: boolean
    justifyContent: SimpleSignal<FlexContent, Psd>
    key: string
    layout: SimpleSignal<LayoutMode, Psd>
    left: SimpleVector2Signal<Psd>

    The position of the left edge of this node.

    When set, this shortcut property will modify the node's position so that the left edge ends up in the given place.

    When retrieved, it will return the position of the left edge in the parent space.

    letterSpacing: SimpleSignal<number, Psd>
    lineCap: SimpleSignal<CanvasLineCap, Psd>
    lineDash: SimpleSignal<number[], Psd>
    lineDashOffset: SimpleSignal<number, Psd>
    lineHeight: SimpleSignal<Length, Psd>
    lineJoin: SimpleSignal<CanvasLineJoin, Psd>
    lineWidth: SimpleSignal<number, Psd>
    margin: SpacingSignal<Psd>
    maxHeight: SimpleSignal<LengthLimit, Psd>
    maxWidth: SimpleSignal<LengthLimit, Psd>
    middle: SimpleVector2Signal<Psd>

    The position of the center of this node.

    When set, this shortcut property will modify the node's position so that the center ends up in the given place.

    If the offset has not been changed, this will be the same as the position.

    When retrieved, it will return the position of the center in the parent space.

    minHeight: SimpleSignal<LengthLimit, Psd>
    minWidth: SimpleSignal<LengthLimit, Psd>
    offset: Vector2Signal<Psd>

    Represents the offset of this node's origin.

    By default, the origin of a node is located at its center. The origin serves as the pivot point when rotating and scaling a node, but it doesn't affect the placement of its children.

    The value is relative to the size of this node. A value of 1 means as far to the right/bottom as possible. Here are a few examples of offsets:

    • [-1, -1] - top left corner
    • [1, -1] - top right corner
    • [0, 1] - bottom edge
    • [-1, 1] - bottom left corner
    opacity: SimpleSignal<number, Psd>

    Represents the opacity of this node in the range 0-1.

    The value is clamped to the range 0-1.

    padding: SpacingSignal<Psd>
    parent: SimpleSignal<Node | null, void>
    position: Vector2Signal<Psd>

    Represents the position of this node in local space of its parent.

    Initializing the position:

    // with a possible vector:
    <Node position={[1, 2]} />
    // with individual components:
    <Node x={1} y={2} />

    Accessing the position:

    // retrieving the vector:
    const position = node.position();
    // retrieving an individual component:
    const x = node.position.x();

    Setting the position:

    // with a possible vector:
    node.position([1, 2]);
    node.position(() => [1, 2]);
    // with individual components:
    node.position.x(1);
    node.position.x(() => 1);
    properties: Record<string, PropertyMetadata>
    psdSrc: SimpleSignal<string, Psd>
    psdToolData: SimpleSignal<Record<string, unknown>, Psd>
    psdToolRenderOptions: SimpleSignal<RenderOptions | undefined, Psd>
    radius: SpacingSignal<Psd>

    Rounds the corners of this rectangle.

    The value represents the radius of the quarter circle that is used to round the corners. If the value is a number, the same radius is used for all corners. Passing an array of two to four numbers will set individual radii for each corner. Individual radii correspond to different corners depending on the number of values passed:

    // top-left-and-bottom-right | top-right-and-bottom-left
    [10, 30]
    // top-left | top-right-and-bottom-left | bottom-right
    [10, 20, 30]
    // top-left | top-right | bottom-right | bottom-left
    [10, 20, 30, 40]

    One uniform radius:

    <Rect
    size={320}
    radius={40}
    fill={'white'}
    />

    Individual radii for each corner:

    <Rect
    size={320}
    radius={[10, 20, 30, 40]}
    fill={'white'}
    />
    ratio: SimpleSignal<number | null, Psd>
    realChildren: Node[]
    right: SimpleVector2Signal<Psd>

    The position of the right edge of this node.

    When set, this shortcut property will modify the node's position so that the right edge ends up in the given place.

    When retrieved, it will return the position of the right edge in the parent space.

    rippleStrength: SimpleSignal<number, Psd>
    rotation: SimpleSignal<number, Psd>

    Represents the rotation (in degrees) of this node relative to its parent.

    scale: Vector2Signal<Psd>

    Represents the scale of this node in local space of its parent.

    Initializing the scale:

    // with a possible vector:
    <Node scale={[1, 2]} />
    // with individual components:
    <Node scaleX={1} scaleY={2} />

    Accessing the scale:

    // retrieving the vector:
    const scale = node.scale();
    // retrieving an individual component:
    const scaleX = node.scale.x();

    Setting the scale:

    // with a possible vector:
    node.scale([1, 2]);
    node.scale(() => [1, 2]);
    // with individual components:
    node.scale.x(1);
    node.scale.x(() => 1);
    shaders: Signal<PossibleShaderConfig, ShaderConfig[], Psd>
    shadowBlur: SimpleSignal<number, Psd>
    shadowColor: ColorSignal<Psd>
    shadowOffset: Vector2Signal<Psd>
    shrink: SimpleSignal<number, Psd>
    size: Vector2LengthSignal<Psd>

    Represents the size of this node.

    A size is a two-dimensional vector, where x represents the width, and y represents the height.

    The value of both x and y is of type partials.Length which is either:

    • number - the desired length in pixels
    • ${number}% - a string with the desired length in percents, for example '50%'
    • null - an automatic length

    When retrieving the size, all units are converted to pixels, using the current state of the layout. For example, retrieving the width set to '50%', while the parent has a width of 200px will result in the number 100 being returned.

    When the node is not part of the layout, setting its size using percents refers to the size of the entire scene.

    Initializing the size:

    // with a possible vector:
    <Node size={['50%', 200]} />
    // with individual components:
    <Node width={'50%'} height={200} />

    Accessing the size:

    // retrieving the vector:
    const size = node.size();
    // retrieving an individual component:
    const width = node.size.x();

    Setting the size:

    // with a possible vector:
    node.size(['50%', 200]);
    node.size(() => ['50%', 200]);
    // with individual components:
    node.size.x('50%');
    node.size.x(() => '50%');
    sizeLockCounter: SimpleSignal<number, Psd>
    skew: Vector2Signal<Psd>

    Represents the skew of this node in local space of its parent.

    Initializing the skew:

    // with a possible vector:
    <Node skew={[40, 20]} />
    // with individual components:
    <Node skewX={40} skewY={20} />

    Accessing the skew:

    // retrieving the vector:
    const skew = node.skew();
    // retrieving an individual component:
    const skewX = node.skew.x();

    Setting the skew:

    // with a possible vector:
    node.skew([40, 20]);
    node.skew(() => [40, 20]);
    // with individual components:
    node.skew.x(40);
    node.skew.x(() => 40);
    smoothCorners: SimpleSignal<boolean, Psd>

    Enables corner smoothing.

    This property only affects the way rounded corners are drawn. To control the corner radius use the radius property.

    When enabled, rounded corners are drawn continuously using Bézier curves rather than quarter circles. The sharpness of the curve can be controlled with cornerSharpness.

    You can read more about corner smoothing in this article by Nick Lawrence.

    <Rect
    width={300}
    height={300}
    smoothCorners={true}
    />
    smoothing: SimpleSignal<boolean, Psd>

    Whether the image should be smoothed.

    When disabled, the image will be scaled using the nearest neighbor interpolation with no smoothing. The resulting image will appear pixelated.

    true
    
    spawner: SimpleSignal<ComponentChildren, Psd>

    Use children instead.

    src: SimpleSignal<string, Psd>

    The source of this image.

    Using a local image:

    import image from './example.png';
    // ...
    view.add(<Img src={image} />)

    Loading an image from the internet:

    view.add(<Img src="https://example.com/image.png" />)
    
    start: SimpleSignal<number, Psd>

    A percentage from the start before which the curve should be clipped.

    The portion of the curve that comes before the given percentage will be made invisible.

    This property is usefully for animating the curve appearing on the screen. The value of 0 means the very start of the curve (accounting for the startOffset) while 1 means the very end (accounting for the endOffset).

    startArrow: SimpleSignal<boolean, Psd>

    Whether to display an arrow at the start of the visible curve.

    Use arrowSize to control the size of the arrow.

    startOffset: SimpleSignal<number, Psd>

    The offset in pixels from the start of the curve.

    This property lets you specify where along the defined curve the actual visible portion starts. For example, setting it to 20 will make the first 20 pixels of the curve invisible.

    This property is useful for trimming the curve using a fixed distance. If you want to animate the curve appearing on the screen, use start instead.

    stroke: CanvasStyleSignal<Psd>
    strokeFirst: SimpleSignal<boolean, Psd>
    styles: CSSStyleDeclaration
    textAlign: SimpleSignal<CanvasTextAlign, Psd>
    textDirection: SimpleSignal<CanvasDirection, Psd>
    textWrap: SimpleSignal<TextWrap, Psd>
    top: SimpleVector2Signal<Psd>

    The position of the top edge of this node.

    When set, this shortcut property will modify the node's position so that the top edge ends up in the given place.

    When retrieved, it will return the position of the top edge in the parent space.

    topLeft: SimpleVector2Signal<Psd>

    The position of the top left corner of this node.

    When set, this shortcut property will modify the node's position so that the top left corner ends up in the given place.

    When retrieved, it will return the position of the top left corner in the parent space.

    topRight: SimpleVector2Signal<Psd>

    The position of the top right corner of this node.

    When set, this shortcut property will modify the node's position so that the top right corner ends up in the given place.

    When retrieved, it will return the position of the top right corner in the parent space.

    view2D: View2D
    wrap: SimpleSignal<FlexWrap, Psd>
    zIndex: SimpleSignal<number, Psd>

    Accessors

    • get columnGap(): Signal<Length, number, this>

      Returns Signal<Length, number, this>

    • get height(): Signal<Length, number, this>

      Returns Signal<Length, number, this>

    • get rowGap(): Signal<Length, number, this>

      Returns Signal<Length, number, this>

    • get width(): Signal<Length, number, this>

      Returns Signal<Length, number, this>

    • get x(): SimpleSignal<number, this>

      Returns SimpleSignal<number, this>

    • get y(): SimpleSignal<number, this>

      Returns SimpleSignal<number, this>

    Methods

    • Returns Generator<
          { key: string; meta: PropertyMetadata<any>; signal: SimpleSignal<any> },
          void,
          unknown,
      >

    • Returns number

    • Add the given node(s) as the children of this node.

      Parameters

      • node: ComponentChildren

        A node or an array of nodes to append.

      Returns this

      The nodes will be appended at the end of the children list.

      const node = <Layout />;
      node.add(<Rect />);
      node.add(<Circle />);

      Result:

      graph TD;
        layout([Layout])
        circle([Circle])
        rect([Rect])
          layout-->rect;
          layout-->circle;
      
    • Returns Vector2

    • Returns boolean

    • Returns void

    • Returns void

    • Apply the given state to the node, setting all matching signal values to the provided values.

      Parameters

      • state: NodeState

        The state to apply to the node.

      Returns void

    • Smoothly transition between the current state of the node and the given state.

      Parameters

      • state: NodeState

        The state to transition to.

      • duration: number

        The duration of the transition.

      • Optionaltiming: TimingFunction

        The timing function to use for the transition.

      Returns ThreadGenerator

    • Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • The visible arc length of this curve.

      Returns number

      This arc length accounts for both the offset and the start and end properties.

    • The base arc length of this curve.

      Returns number

      This is the entire length of this curve, not accounting for the offsets.

    • Get a bounding box for the contents rendered by this node as well as its children.

      Returns BBox

    • Returns CanvasRenderingContext2D

    • Get a cache canvas with the contents of this node rendered onto it.

      Returns Promise<CanvasRenderingContext2D>

    • Get the nth children cast to the specified type.

      Type Parameters

      • T extends Node = Node

      Parameters

      • index: number

        The index of the child to retrieve.

      Returns T | null

    • Get the children array cast to the specified type.

      Type Parameters

      • T extends Node = Node

      Returns T[]

    • Returns BBox

    • Create a copy of this node.

      Parameters

      • OptionalcustomProps: NodeState

        Properties to override.

      Returns this

    • Collect all asynchronous resources used by this node.

      Returns void

    • The percentage of the curve that's currently visible.

      Returns number

      The returned value is the ratio between the visible length (as defined by start and end) and the offset length of the curve.

    • Returns Node | null

    • Returns DOMMatrix

    • A matrix mapping composite space to world space.

      Returns DOMMatrix

      Certain effects such as blur and shadows ignore the current transformation. This matrix can be used to transform their parameters so that the effect appears relative to the closest composite root.

    • Returns Vector2

    • Returns Vector2

    • Returns CurveDrawingInfo

    • Returns SerializedVector2<DesiredLength>

    • Prepare this node to be disposed of.

      Returns void

      This method is called automatically when a scene is refreshed. It will be called even if the node is not currently attached to the tree.

      The goal of this method is to clean any external references to allow the node to be garbage collected.

    • Convert a distance along the curve to a percentage.

      Parameters

      • value: number

        The distance along the curve.

      Returns number

      The distance should be given in relation to the full curve, not accounting for startOffset and endOffset.

    • Parameters

      • context: CanvasRenderingContext2D

      Returns Promise<void>

    • Parameters

      • context: CanvasRenderingContext2D

      Returns Promise<void>

    • Draw an overlay for this node.

      Parameters

      • context: CanvasRenderingContext2D

        The context to draw with.

      • matrix: DOMMatrix

        A local-to-screen matrix.

      Returns void

      The overlay for the currently inspected node is displayed on top of the canvas.

      The provided context is in screen space. The local-to-screen matrix can be used to transform all shapes that need to be displayed. This approach allows to keep the line widths and gizmo sizes consistent, no matter how zoomed-in the view is.

    • Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • Returns CanvasRenderingContext2D

    • Returns string

    • Find all descendants of this node that match the given predicate.

      Type Parameters

      • T extends Node

      Parameters

      • predicate: (node: any) => node is T

        A function that returns true if the node matches.

      Returns T[]

    • Find all descendants of this node that match the given predicate.

      Type Parameters

      • T extends Node = Node

      Parameters

      • predicate: (node: any) => boolean

        A function that returns true if the node matches.

      Returns T[]

    • Find the closest ancestor of this node that matches the given predicate.

      Type Parameters

      • T extends Node

      Parameters

      • predicate: (node: Node) => node is T

        A function that returns true if the node matches.

      Returns T | null

    • Find the closest ancestor of this node that matches the given predicate.

      Type Parameters

      • T extends Node = Node

      Parameters

      • predicate: (node: Node) => boolean

        A function that returns true if the node matches.

      Returns T | null

    • Find the first descendant of this node that matches the given predicate.

      Type Parameters

      • T extends Node

      Parameters

      • predicate: (node: Node) => node is T

        A function that returns true if the node matches.

      Returns T | null

    • Find the first descendant of this node that matches the given predicate.

      Type Parameters

      • T extends Node = Node

      Parameters

      • predicate: (node: Node) => boolean

        A function that returns true if the node matches.

      Returns T | null

    • Find the last descendant of this node that matches the given predicate.

      Type Parameters

      • T extends Node

      Parameters

      • predicate: (node: Node) => node is T

        A function that returns true if the node matches.

      Returns T | null

    • Find the last descendant of this node that matches the given predicate.

      Type Parameters

      • T extends Node = Node

      Parameters

      • predicate: (node: Node) => boolean

        A function that returns true if the node matches.

      Returns T | null

    • Get a bounding box for the contents rendered by this node (including effects applied after caching).

      Returns BBox

      The returned bounding box should be in local space.

    • Returns Vector2

    • Returns number

    • Returns Vector2

    • Returns BBox

    • Returns Node[]

    • Get color of the image at the given position.

      Parameters

      • position: PossibleVector2

        The position in local space at which to sample the color.

      Returns ChromaColor

    • Returns BBox

    • Returns number

    • Parameters

      • origin: Origin

      Returns Vector2

    • Returns Path2D

    • Get color of the image at the given pixel.

      Parameters

      • position: PossibleVector2

        The pixel's position.

      Returns ChromaColor

    • Parameters

      • value: number

      Returns CurvePoint

    • Parameters

      • value: number

      Returns CurvePoint

    • Returns Path2D

    • Returns ComponentChildren

    • Return a snapshot of the node's current signal values.

      Returns NodeState

      This method will calculate the values of any reactive properties of the node at the time the method is called.

    • Returns number

    • Returns number

    • Returns number

    • Returns boolean

    • Returns boolean

    • Try to find a node intersecting the given position.

      Parameters

      • position: Vector2

        The searched position.

      Returns Node | null

    • Returns HTMLImageElement

    • Returns CanvasRenderingContext2D

    • Insert the given node(s) at the specified index in the children list.

      Parameters

      • node: ComponentChildren

        A node or an array of nodes to insert.

      • Optionalindex: number

        An index at which to insert the node(s).

      Returns this

      const node = (
      <Layout>
      <Rect />
      <Circle />
      </Layout>
      );

      node.insert(<Txt />, 1);

      Result:

      graph TD;
        layout([Layout])
        circle([Circle])
        text([Text])
        rect([Rect])
          layout-->rect;
          layout-->text;
          layout-->circle;
      
    • Create an instance of this node's class.

      Parameters

      • Optionalprops: NodeProps

        Properties to pass to the constructor.

      Returns this

    • Returns boolean

    • Returns Layout[]

    • Get the resolved layout mode of this node.

      Returns boolean

      When the mode is null, its value will be inherited from the parent.

      Use layout to get the raw mode set for this node (without inheritance).

    • Returns number

    • Get the local-to-parent matrix for this node.

      Returns DOMMatrix

      This matrix transforms vectors from local space of this node to local space of this node's parent.

    • Get the local-to-world matrix for this node.

      Returns DOMMatrix

      This matrix transforms vectors from local space of this node to world space.

      Calculate the absolute position of a point located 200 pixels to the right of the node:

      const local = new Vector2(0, 200);
      const world = transformVectorAsPoint(local, node.localToWorld());
    • Returns void

    • Rearrange this node in relation to its siblings.

      Parameters

      • Optionalby: number

        Number of places by which the node should be moved.

      Returns this

      Children are rendered starting from the beginning of the children list. We can change the rendering order by rearranging said list.

      A positive by arguments move the node up (it will be rendered on top of the elements it has passed). Negative values move it down.

    • Move the node above the provided node in the parent's layout.

      Parameters

      • node: Node

        The sibling node below which to move.

      • OptionaldirectlyAbove: boolean

        Whether the node should be positioned directly above the sibling. When true, will move the node even if it is already positioned above the sibling.

      Returns this

      The node will be moved above the provided node and from then on will be rendered on top of it. By default, if the node is already positioned higher than the sibling node, it will not get moved.

    • Move the node below the provided node in the parent's layout.

      Parameters

      • node: Node

        The sibling node below which to move.

      • OptionaldirectlyBelow: boolean

        Whether the node should be positioned directly below the sibling. When true, will move the node even if it is already positioned below the sibling.

      Returns this

      The node will be moved below the provided node and from then on will be rendered below it. By default, if the node is already positioned lower than the sibling node, it will not get moved.

    • Move the node down in relation to its siblings.

      Returns this

      The node will exchange places with the sibling right below it (if any) and from then on will be rendered under it.

    • Update the offset of this node and adjust the position to keep it in the same place.

      Parameters

      • offset: Vector2

        The new offset.

      Returns void

    • Move the node to the provided position relative to its siblings.

      Parameters

      • index: number

        The index to move the node to.

      Returns this

      If the node is getting moved to a lower position, it will be placed below the sibling that's currently at the provided index (if any). If the node is getting moved to a higher position, it will be placed above the sibling that's currently at the provided index (if any).

    • Move the node to the bottom in relation to its siblings.

      Returns this

      The node will be placed at the beginning of the children list and from then on will be rendered below all of its siblings.

    • Move the node to the top in relation to its siblings.

      Returns this

      The node will be placed at the end of the children list and from then on will be rendered on top of all of its siblings.

    • Move the node up in relation to its siblings.

      Returns this

      The node will exchange places with the sibling right above it (if any) and from then on will be rendered on top of it.

    • The natural size of this image.

      Returns Vector2

      The natural size is the size of the source image unaffected by the size and scale properties.

    • The offset arc length of this curve.

      Returns number

      This is the length of the curve that accounts for the offsets.

    • Parameters

      • box: BBox

      Returns BBox

    • Get the parent cast to the specified type.

      Type Parameters

      • T extends Node = Node

      Returns T | null

    • Returns Layout | null

    • Returns BBox

    • Parse any ComponentChildren into an array of nodes.

      Parameters

      • children: ComponentChildren

        The children to parse.

      Returns Node[]

    • Parameters

      • value: string | number | null

      Returns string

    • Parameters

      • value: number | null

      Returns string

    • Get the current children of this node.

      Returns readonly Node[]

      Unlike children, this method does not have any side effects. It does not register the children signal as a dependency, and it does not spawn any children. It can be used to safely retrieve the current state of the scene graph for debugging purposes.

    • Convert a percentage along the curve to a distance.

      Parameters

      • value: number

        The percentage along the curve.

      Returns number

      The returned distance is given in relation to the full curve, not accounting for startOffset and endOffset.

    • Parameters

      • _path: Path2D
      • _startPoint: Vector2 | null
      • _endPoint: Vector2 | null

      Returns void

    • Returns CurveProfile

    • Create a reactive copy of this node.

      Parameters

      • OptionalcustomProps: NodeState

        Properties to override.

      Returns this

      A reactive copy has all its properties dynamically updated to match the source node.

    • Returns void

    • Remove this node from the tree.

      Returns this

    • Remove the given child.

      Parameters

      • child: Node

      Returns void

    • Remove all children of this node.

      Returns void

    • Render this node onto the given canvas.

      Parameters

      • context: CanvasRenderingContext2D

        The context to draw with.

      Returns Promise<void>

    • Parameters

      • context: CanvasRenderingContext2D
      • source: CanvasImageSource
      • x: number
      • y: number

      Returns void

    • Change the parent of this node while keeping the absolute transform.

      Parameters

      • newParent: Node

        The new parent of this node.

      Returns void

      After performing this operation, the node will stay in the same place visually, but its parent will be changed.

    • Apply any new font changes to this node and all of its ancestors.

      Returns void

    • Find the closest layout root and apply any new layout changes.

      Returns void

    • Whether this node should be cached or not.

      Returns boolean

    • Check if the path requires a profile.

      Returns boolean

      The profile is only required if certain features are used. Otherwise, the profile generation can be skipped, and the curve can be drawn directly using the 2D context.

    • Restore the node to its last saved state.

      Returns void

      This method can be used together with the save method to restore a node to a previously saved state. Restoring a node to a previous state removes that state from the state stack.

      const node = <Circle width={100} height={100} fill={"lightseagreen"} />

      view.add(node);

      // Save the node's current state
      node.save();

      // Modify some of the node's properties
      yield* node.scale(2, 1);
      yield* node.fill('hotpink', 1);

      // Restore the node to its saved state
      node.restore();
    • Tween the node to its last saved state.

      Parameters

      • duration: number

        The duration of the transition.

      • Optionaltiming: TimingFunction

        The timing function to use for the transition.

      Returns ThreadGenerator

      This method can be used together with the save method to restore a node to a previously saved state. Restoring a node to a previous state removes that state from the state stack.

      const node = <Circle width={100} height={100} fill={"lightseagreen"} />

      view.add(node);

      // Save the node's current state
      node.save();

      // Modify some of the node's properties
      yield* node.scale(2, 1);
      yield* node.fill('hotpink', 1);

      // Tween the node to its saved state over 1 second
      yield* node.restore(1);
    • Parameters

      • Optionalduration: number

      Returns Generator<void | Promise<any> | ThreadGenerator | Promisable<any>, void, any>

    • Returns number

    • Push a snapshot of the node's current state onto the node's state stack.

      Returns void

      This method can be used together with the restore method to save a node's current state and later restore it. It is possible to store more than one state by calling save method multiple times.

    • Internal

      A simplified version of localToParent matrix used for transforming direction vectors.

      Returns DOMMatrix

    • Parameters

      • value: SignalValue<PossibleVector2>

      Returns void

    • Parameters

      • value: SignalValue<number>

      Returns void

    • Parameters

      • value: SignalValue<PossibleVector2>

      Returns void

    • Parameters

      • value: SignalValue<ComponentChildren>

      Returns void

    • Parameters

      • value: SignalValue<Length>

      Returns void

    • Set the children without parsing them.

      Parameters

      • value: Node[]

        The children to set.

      Returns void

      This method assumes that the caller took care of parsing the children and updating the hierarchy.

    • Parameters

      • value: SignalValue<ComponentChildren>

      Returns void

    • Prepare the given context for drawing a cached node onto it.

      Parameters

      • context: CanvasRenderingContext2D

        The context using which the cache will be drawn.

      Returns void

      This method is called before the contents of the cache canvas are drawn on the screen. It can be used to apply effects to the entire node together with its children, instead of applying them individually. Effects such as transparency, shadows, and filters use this technique.

      Whether the node is cached is decided by the requiresCache method.

    • Parameters

      • value: SignalValue<Length>

      Returns void

    • Parameters

      • value: SignalValue<number>

      Returns void

    • Parameters

      • value: SignalValue<number>

      Returns void

    • Create a copy of this node.

      Parameters

      • OptionalcustomProps: NodeState

        Properties to override.

      Returns this

      Unlike clone, a snapshot clone calculates any reactive properties at the moment of cloning and passes the raw values to the copy.

    • Returns Node[]

    • Parameters

      • reactive: boolean
      • children: ComponentChildren

      Returns void

    • Returns Node[]

    • Wait for any asynchronous resources that this node or its children have.

      Returns Promise<Psd>

      Certain resources like images are always loaded asynchronously. Awaiting this method makes sure that all such resources are done loading before continuing the animation.

    • Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • Parameters

      • value: SignalValue<GlobalCompositeOperation>
      • time: number
      • timingFunction: TimingFunction

      Returns Generator<void | Promise<any> | ThreadGenerator | Promisable<any>, void, any>

    • Parameters

      • value: SignalValue<Length>
      • time: number
      • timingFunction: TimingFunction
      • interpolationFunction: InterpolationFunction<Length>

      Returns ThreadGenerator

    • Parameters

      • value: SignalValue<SerializedVector2<Length>>
      • time: number
      • timingFunction: TimingFunction
      • interpolationFunction: InterpolationFunction<Vector2>

      Returns ThreadGenerator

    • Parameters

      • value: SignalValue<Length>
      • time: number
      • timingFunction: TimingFunction
      • interpolationFunction: InterpolationFunction<Length>

      Returns ThreadGenerator

    • Apply any new layout changes to this node and its children.

      Returns void

    • Returns View2D

    • Get a bounding box in world space for the contents rendered by this node as well as its children.

      Returns BBox

      This is the same the bounding box returned by cacheBBox only transformed to world space.

    • Get the world-to-local matrix for this node.

      Returns DOMMatrix

      This matrix transforms vectors from world space to local space of this node.

      Calculate the position relative to this node for a point located in the top-left corner of the screen:

      const world = new Vector2(0, 0);
      const local = transformVectorAsPoint(world, node.worldToLocal());
    • Get the world-to-parent matrix for this node.

      Returns DOMMatrix

      This matrix transforms vectors from world space to local space of this node's parent.