Penpot plugins API
    Preparing search index...

    Interface ContextGeometryUtils

    Utility methods for geometric calculations in Penpot.

    const centerPoint = geometryUtils.center(shapes);
    console.log(centerPoint);
    interface ContextGeometryUtils {
        center(shapes: Shape[]): { x: number; y: number } | null;
    }
    Index

    Methods

    Methods

    • Calculates the center point of a given array of shapes. This method computes the geometric center (centroid) of the bounding boxes of the provided shapes.

      Parameters

      • shapes: Shape[]

        The array of shapes to calculate the center for.

      Returns { x: number; y: number } | null

      Returns the center point as an object with x and y coordinates, or null if the array is empty.

      const centerPoint = geometryUtils.center(shapes);
      console.log(centerPoint);