Interface ContextTypesUtils

Utility methods for determining the types of Penpot shapes.

const isBoard = typesUtils.isBoard(shape);
console.log(isBoard);
interface ContextTypesUtils {
    isBoard(shape: Shape): shape is Board;
    isGroup(shape: Shape): shape is Group;
    isMask(shape: Shape): shape is Group;
    isBool(shape: Shape): shape is Boolean;
    isRectangle(shape: Shape): shape is Rectangle;
    isPath(shape: Shape): shape is Path;
    isText(shape: Shape): shape is Text;
    isEllipse(shape: Shape): shape is Ellipse;
    isSVG(shape: Shape): shape is SvgRaw;
}

Methods

  • Checks if the given shape is a board.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Board

    Returns true if the shape is a board, otherwise false.

  • Checks if the given shape is a group.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Group

    Returns true if the shape is a Group, otherwise false.

  • Checks if the given shape is a mask.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Group

    Returns true if the shape is a Group (acting as a mask), otherwise false.

  • Checks if the given shape is a boolean operation.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Boolean

    Returns true if the shape is a Bool, otherwise false.

  • Checks if the given shape is a rectangle.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Rectangle

    Returns true if the shape is a Rectangle, otherwise false.

  • Checks if the given shape is a path.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Path

    Returns true if the shape is a Path, otherwise false.

  • Checks if the given shape is a text element.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Text

    Returns true if the shape is a Text, otherwise false.

  • Checks if the given shape is an ellipse.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is Ellipse

    Returns true if the shape is a Ellipse, otherwise false.

  • Checks if the given shape is an SVG.

    Parameters

    • shape: Shape

      The shape to check.

    Returns shape is SvgRaw

    Returns true if the shape is a SvgRaw, otherwise false.