import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4'; import { Polygon } from './polygon'; import type { GraphicsPath } from './graphics-path'; import type { ShapePrimitive } from './shape-primitive'; import type { StarType } from './poly-star'; export declare class ShapePath { private graphicsPath; currentPoly: Polygon | null; shapePrimitives: { shape: ShapePrimitive; transform?: Matrix4; }[]; constructor(graphicsPath: GraphicsPath); /** Builds the path. */ buildPath(): void; /** * Adds a cubic Bezier curve to the path. * It requires three points: the first two are control points and the third one is the end point. * The starting point is the last point in the current path. * @param cp1x - The x-coordinate of the first control point. * @param cp1y - The y-coordinate of the first control point. * @param cp2x - The x-coordinate of the second control point. * @param cp2y - The y-coordinate of the second control point. * @param x - The x-coordinate of the end point. * @param y - The y-coordinate of the end point. * @param smoothness - Optional parameter to adjust the smoothness of the curve. * @returns The instance of the current object for chaining. */ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number, smoothness?: number): ShapePath; moveTo(x: number, y: number): ShapePath; /** * Closes the current path by drawing a straight line back to the start. * If the shape is already closed or there are no points in the path, this method does nothing. * @returns The instance of the current object for chaining. */ closePath(): this; /** * Draws an ellipse at the specified location and with the given x and y radii. * An optional transformation can be applied, allowing for rotation, scaling, and translation. * @param x - The x-coordinate of the center of the ellipse. * @param y - The y-coordinate of the center of the ellipse. * @param radiusX - The horizontal radius of the ellipse. * @param radiusY - The vertical radius of the ellipse. * @param transform - An optional `Matrix` object to apply a transformation to the ellipse. This can include rotations. * @returns The instance of the current object for chaining. */ ellipse(x: number, y: number, radiusX: number, radiusY: number, transform?: Matrix4): this; polyStar(pointCount: number, outerRadius: number, innerRadius: number, outerRoundness: number, innerRoundness: number, starType: StarType, transform?: Matrix4): this; /** * Draws a rectangle shape. This method adds a new rectangle path to the current drawing. * @param x - The x-coordinate of the upper-left corner of the rectangle. * @param y - The y-coordinate of the upper-left corner of the rectangle. * @param w - The width of the rectangle. * @param h - The height of the rectangle. * @param transform - An optional `Matrix` object to apply a transformation to the rectangle. * @returns The instance of the current object for chaining. */ rect(x: number, y: number, w: number, h: number, roundness: number, transform?: Matrix4): this; /** * Draws a given shape on the canvas. * This is a generic method that can draw any type of shape specified by the `ShapePrimitive` parameter. * An optional transformation matrix can be applied to the shape, allowing for complex transformations. * @param shape - The shape to draw, defined as a `ShapePrimitive` object. * @param matrix - An optional `Matrix` for transforming the shape. This can include rotations, * scaling, and translations. * @returns The instance of the current object for chaining. */ drawShape(shape: ShapePrimitive, matrix?: Matrix4): this; /** * Starts a new polygon path from the specified starting point. * This method initializes a new polygon or ends the current one if it exists. * @param x - The x-coordinate of the starting point of the new polygon. * @param y - The y-coordinate of the starting point of the new polygon. * @returns The instance of the current object for chaining. */ private startPoly; /** * Ends the current polygon path. If `closePath` is set to true, * the path is closed by connecting the last point to the first one. * This method finalizes the current polygon and prepares it for drawing or adding to the shape primitives. * @param closePath - A boolean indicating whether to close the polygon by connecting the last point * back to the starting point. False by default. * @returns The instance of the current object for chaining. */ private endPoly; private ensurePoly; }