MCPcopy
hub / github.com/pixijs/pixijs / Polygon

Class Polygon

src/maths/shapes/Polygon.ts:44–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 * @standard
43 */
44export class Polygon implements ShapePrimitive
45{
46 /**
47 * An array of the points of this polygon stored as a flat array of numbers.
48 * @example
49 * ```ts
50 * // Access points directly
51 * const polygon = new Polygon([0, 0, 100, 0, 50, 100]);
52 * console.log(polygon.points); // [0, 0, 100, 0, 50, 100]
53 *
54 * // Modify points
55 * polygon.points[0] = 10; // Move first x coordinate
56 * polygon.points[1] = 10; // Move first y coordinate
57 * ```
58 * @remarks
59 * - Stored as [x1, y1, x2, y2, ...]
60 * - Each pair represents a vertex
61 * - Length is always even
62 * - Can be modified directly
63 */
64 public points: number[];
65
66 /**
67 * Indicates if the polygon path is closed.
68 * @example
69 * ```ts
70 * // Create open polygon
71 * const polygon = new Polygon([0, 0, 100, 0, 50, 100]);
72 * polygon.closePath = false;
73 *
74 * // Check path state
75 * if (polygon.closePath) {
76 * // Last point connects to first
77 * }
78 * ```
79 * @remarks
80 * - True by default
81 * - False after moveTo
82 * - True after closePath
83 * @default true
84 */
85 public closePath: boolean;
86
87 /**
88 * The type of the object, mainly used to avoid `instanceof` checks
89 * @example
90 * ```ts
91 * // Check shape type
92 * const shape = new Polygon([0, 0, 100, 0, 50, 100]);
93 * console.log(shape.type); // 'polygon'
94 *
95 * // Use in type guards
96 * if (shape.type === 'polygon') {
97 * // TypeScript knows this is a Polygon
98 * console.log(shape.points.length);
99 * }
100 * ```
101 * @readonly

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected