pixi-silk 0.1.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +48 -68
  3. package/dist/SilkGraphics.d.ts +270 -55
  4. package/dist/SilkGraphics.js +909 -147
  5. package/dist/app.d.ts +32 -16
  6. package/dist/app.js +44 -10
  7. package/dist/atlas.d.ts +13 -6
  8. package/dist/atlas.js +13 -6
  9. package/dist/batch.d.ts +63 -0
  10. package/dist/batch.js +327 -0
  11. package/dist/color.d.ts +4 -1
  12. package/dist/color.js +9 -4
  13. package/dist/constants.js +31 -5
  14. package/dist/curves.d.ts +9 -3
  15. package/dist/curves.js +11 -5
  16. package/dist/glass/Glass.d.ts +62 -0
  17. package/dist/glass/Glass.js +135 -0
  18. package/dist/glass/GlassFilter.d.ts +33 -0
  19. package/dist/glass/GlassFilter.js +264 -0
  20. package/dist/glass/glass-wgsl.js +129 -0
  21. package/dist/glass/options.d.ts +63 -0
  22. package/dist/glass/options.js +55 -0
  23. package/dist/glass.d.ts +4 -0
  24. package/dist/glass.js +4 -0
  25. package/dist/glow/Glow.d.ts +60 -0
  26. package/dist/glow/Glow.js +65 -0
  27. package/dist/glow/aurora.d.ts +66 -0
  28. package/dist/glow/aurora.js +133 -0
  29. package/dist/glow/light.d.ts +38 -0
  30. package/dist/glow/light.js +83 -0
  31. package/dist/glow/recipes.d.ts +37 -0
  32. package/dist/glow/recipes.js +154 -0
  33. package/dist/glow/shapes.d.ts +13 -0
  34. package/dist/glow/shapes.js +34 -0
  35. package/dist/glow.d.ts +6 -0
  36. package/dist/glow.js +6 -0
  37. package/dist/gradient.d.ts +57 -4
  38. package/dist/gradient.js +142 -4
  39. package/dist/history.d.ts +194 -0
  40. package/dist/history.js +350 -0
  41. package/dist/hit.js +160 -26
  42. package/dist/index.d.ts +6 -5
  43. package/dist/index.js +4 -3
  44. package/dist/layout/flex.js +409 -0
  45. package/dist/layout/node.d.ts +53 -0
  46. package/dist/layout/node.js +117 -0
  47. package/dist/layout/style.d.ts +115 -0
  48. package/dist/layout.d.ts +3 -0
  49. package/dist/layout.js +2 -0
  50. package/dist/motion.d.ts +14 -10
  51. package/dist/motion.js +14 -10
  52. package/dist/path.d.ts +150 -0
  53. package/dist/path.js +761 -0
  54. package/dist/selection.d.ts +133 -0
  55. package/dist/selection.js +194 -0
  56. package/dist/shader-slot.js +9 -0
  57. package/dist/shader-wgsl.js +946 -0
  58. package/dist/shader.js +480 -55
  59. package/dist/signal.d.ts +49 -0
  60. package/dist/signal.js +79 -0
  61. package/dist/stroke.js +271 -0
  62. package/dist/text/SilkText.d.ts +249 -0
  63. package/dist/text/SilkText.js +568 -0
  64. package/dist/text/atlas.d.ts +153 -0
  65. package/dist/text/atlas.js +316 -0
  66. package/dist/text/edt.d.ts +14 -0
  67. package/dist/text/edt.js +97 -0
  68. package/dist/text/label.d.ts +19 -0
  69. package/dist/text/label.js +38 -0
  70. package/dist/text/layout.d.ts +150 -0
  71. package/dist/text/layout.js +270 -0
  72. package/dist/text/segment.d.ts +34 -0
  73. package/dist/text/segment.js +98 -0
  74. package/dist/text/shader.js +355 -0
  75. package/dist/text.d.ts +7 -0
  76. package/dist/text.js +7 -0
  77. package/dist/ui/ButtonDock.d.ts +47 -0
  78. package/dist/ui/ButtonDock.js +110 -0
  79. package/dist/ui/RadialMenu.d.ts +222 -0
  80. package/dist/ui/RadialMenu.js +680 -0
  81. package/dist/ui/SilkButton.d.ts +149 -0
  82. package/dist/ui/SilkButton.js +323 -0
  83. package/dist/ui/ValuePill.d.ts +48 -0
  84. package/dist/ui/ValuePill.js +77 -0
  85. package/dist/ui/arc.d.ts +32 -0
  86. package/dist/ui/arc.js +58 -0
  87. package/dist/ui/brush.d.ts +117 -0
  88. package/dist/ui/brush.js +280 -0
  89. package/dist/ui/camera.d.ts +250 -0
  90. package/dist/ui/camera.js +634 -0
  91. package/dist/ui/color/ColorPicker.d.ts +72 -0
  92. package/dist/ui/color/ColorPicker.js +125 -0
  93. package/dist/ui/color/ColorSlider.d.ts +81 -0
  94. package/dist/ui/color/ColorSlider.js +227 -0
  95. package/dist/ui/color/ColorWheel.d.ts +34 -0
  96. package/dist/ui/color/ColorWheel.js +117 -0
  97. package/dist/ui/color/Eyedropper.d.ts +57 -0
  98. package/dist/ui/color/Eyedropper.js +159 -0
  99. package/dist/ui/color/OklchPicker.d.ts +45 -0
  100. package/dist/ui/color/OklchPicker.js +137 -0
  101. package/dist/ui/color/SwatchPalette.d.ts +60 -0
  102. package/dist/ui/color/SwatchPalette.js +160 -0
  103. package/dist/ui/color/SwatchPopup.d.ts +68 -0
  104. package/dist/ui/color/SwatchPopup.js +237 -0
  105. package/dist/ui/color/draw.d.ts +22 -0
  106. package/dist/ui/color/draw.js +128 -0
  107. package/dist/ui/color/model.d.ts +94 -0
  108. package/dist/ui/color/model.js +193 -0
  109. package/dist/ui/color/rings.d.ts +75 -0
  110. package/dist/ui/color/rings.js +247 -0
  111. package/dist/ui/color.d.ts +11 -0
  112. package/dist/ui/color.js +11 -0
  113. package/dist/ui/dial.d.ts +229 -0
  114. package/dist/ui/dial.js +553 -0
  115. package/dist/ui/driver.d.ts +24 -0
  116. package/dist/ui/driver.js +46 -0
  117. package/dist/ui/gesture.d.ts +66 -0
  118. package/dist/ui/gesture.js +116 -0
  119. package/dist/ui/gizmo.d.ts +199 -0
  120. package/dist/ui/gizmo.js +957 -0
  121. package/dist/ui/grid.d.ts +106 -0
  122. package/dist/ui/grid.js +228 -0
  123. package/dist/ui/group.d.ts +81 -0
  124. package/dist/ui/group.js +144 -0
  125. package/dist/ui/guides.d.ts +142 -0
  126. package/dist/ui/guides.js +379 -0
  127. package/dist/ui/halo.d.ts +164 -0
  128. package/dist/ui/halo.js +438 -0
  129. package/dist/ui/icon.d.ts +14 -0
  130. package/dist/ui/icon.js +40 -0
  131. package/dist/ui/index.d.ts +62 -0
  132. package/dist/ui/index.js +56 -0
  133. package/dist/ui/input.d.ts +28 -0
  134. package/dist/ui/input.js +49 -0
  135. package/dist/ui/inspector.d.ts +4 -0
  136. package/dist/ui/inspector.js +4 -0
  137. package/dist/ui/keys.d.ts +20 -0
  138. package/dist/ui/keys.js +65 -0
  139. package/dist/ui/label.d.ts +18 -0
  140. package/dist/ui/layers.d.ts +5 -0
  141. package/dist/ui/layers.js +5 -0
  142. package/dist/ui/layout/debug.d.ts +38 -0
  143. package/dist/ui/layout/debug.js +299 -0
  144. package/dist/ui/layout/flex-container.d.ts +150 -0
  145. package/dist/ui/layout/flex-container.js +441 -0
  146. package/dist/ui/layout/simulate.d.ts +49 -0
  147. package/dist/ui/layout/simulate.js +92 -0
  148. package/dist/ui/layout/smart-container.d.ts +180 -0
  149. package/dist/ui/layout/smart-container.js +302 -0
  150. package/dist/ui/layout.d.ts +5 -0
  151. package/dist/ui/layout.js +5 -0
  152. package/dist/ui/marquee.d.ts +124 -0
  153. package/dist/ui/marquee.js +321 -0
  154. package/dist/ui/measure.d.ts +138 -0
  155. package/dist/ui/measure.js +351 -0
  156. package/dist/ui/minimap.d.ts +2 -0
  157. package/dist/ui/minimap.js +2 -0
  158. package/dist/ui/modes.d.ts +186 -0
  159. package/dist/ui/modes.js +380 -0
  160. package/dist/ui/odometer.d.ts +104 -0
  161. package/dist/ui/odometer.js +244 -0
  162. package/dist/ui/outline.d.ts +104 -0
  163. package/dist/ui/outline.js +310 -0
  164. package/dist/ui/paint.js +22 -0
  165. package/dist/ui/panel.d.ts +4 -0
  166. package/dist/ui/panel.js +4 -0
  167. package/dist/ui/panels/Inspector.d.ts +228 -0
  168. package/dist/ui/panels/Inspector.js +516 -0
  169. package/dist/ui/panels/LayerTree.d.ts +193 -0
  170. package/dist/ui/panels/LayerTree.js +878 -0
  171. package/dist/ui/panels/Minimap.d.ts +140 -0
  172. package/dist/ui/panels/Minimap.js +412 -0
  173. package/dist/ui/panels/Panel.d.ts +273 -0
  174. package/dist/ui/panels/Panel.js +767 -0
  175. package/dist/ui/panels/ScrollView.d.ts +126 -0
  176. package/dist/ui/panels/ScrollView.js +358 -0
  177. package/dist/ui/panels/binding.d.ts +59 -0
  178. package/dist/ui/panels/binding.js +84 -0
  179. package/dist/ui/panels/fields.d.ts +265 -0
  180. package/dist/ui/panels/fields.js +760 -0
  181. package/dist/ui/panels/icons.d.ts +7 -0
  182. package/dist/ui/panels/icons.js +136 -0
  183. package/dist/ui/panels/pixi-tree.d.ts +35 -0
  184. package/dist/ui/panels/pixi-tree.js +82 -0
  185. package/dist/ui/panels/theme.d.ts +79 -0
  186. package/dist/ui/panels/theme.js +91 -0
  187. package/dist/ui/panels/tree.d.ts +130 -0
  188. package/dist/ui/panels/tree.js +199 -0
  189. package/dist/ui/pathgizmo.d.ts +253 -0
  190. package/dist/ui/pathgizmo.js +932 -0
  191. package/dist/ui/pill.d.ts +3 -0
  192. package/dist/ui/pill.js +2 -0
  193. package/dist/ui/ruler.d.ts +113 -0
  194. package/dist/ui/ruler.js +371 -0
  195. package/dist/ui/snap.d.ts +151 -0
  196. package/dist/ui/snap.js +380 -0
  197. package/dist/ui/spacing.d.ts +122 -0
  198. package/dist/ui/spacing.js +346 -0
  199. package/dist/ui/textedit.d.ts +304 -0
  200. package/dist/ui/textedit.js +1085 -0
  201. package/dist/ui/timeline.d.ts +175 -0
  202. package/dist/ui/timeline.js +488 -0
  203. package/dist/webgpu.d.ts +25 -0
  204. package/dist/webgpu.js +32 -0
  205. package/package.json +172 -1
  206. package/skills/pixi-silk/SKILL.md +138 -0
  207. package/skills/pixi-silk-app-rendering/SKILL.md +114 -0
  208. package/skills/pixi-silk-drawing/SKILL.md +154 -0
  209. package/skills/pixi-silk-editor/SKILL.md +200 -0
  210. package/skills/pixi-silk-layout/SKILL.md +150 -0
  211. package/skills/pixi-silk-migrate-from-graphics/SKILL.md +115 -0
  212. package/skills/pixi-silk-paint/SKILL.md +132 -0
  213. package/skills/pixi-silk-text/SKILL.md +127 -0
  214. package/skills/pixi-silk-widgets/SKILL.md +139 -0
@@ -1,8 +1,40 @@
1
- import { Gradient } from "./gradient.js";
2
1
  import { PointsInput } from "./curves.js";
2
+ import { Gradient } from "./gradient.js";
3
3
  import { Bounds, Buffer, ColorSource, DestroyOptions, Geometry, Mesh, PointData, Shader } from "pixi.js";
4
4
  //#region src/SilkGraphics.d.ts
5
- /** How a fill is painted: a colour, a gradient, opacity and an optional gaussian blur for glows and soft shadows. */
5
+ /**
6
+ * A blur that changes across the shape, like Figma's progressive layer blur. The radius goes from
7
+ * `from` at one edge of the shape to `to` at the opposite edge, along `angle`.
8
+ */
9
+ export interface ProgressiveBlur {
10
+ /** Blur at the start edge (standard deviation, local units). */
11
+ from: number;
12
+ /** Blur at the end edge. */
13
+ to: number;
14
+ /** Direction from the start edge to the end edge, in radians. Default `Math.PI / 2` (top to bottom). */
15
+ angle?: number;
16
+ }
17
+ /**
18
+ * A shadow drawn inside the shape from its own distance field, with Figma's semantics. The shape is
19
+ * moved by `x` and `y`, shrunk by `spread` and blurred. What it no longer covers is shaded.
20
+ */
21
+ export interface InnerShadow {
22
+ /** Colour, any Pixi `ColorSource`. Default black. */
23
+ color?: ColorSource;
24
+ /** Opacity from 0 to 1. Default 1. */
25
+ alpha?: number;
26
+ /** Horizontal offset, local units. Positive moves the shadow right. Default 0. */
27
+ x?: number;
28
+ /** Vertical offset, local units. Positive moves the shadow down. Default 0. */
29
+ y?: number;
30
+ /** Blur (standard deviation, local units). Default 0. */
31
+ blur?: number;
32
+ /** Grows the shadow inwards. Negative values make it thinner. Default 0. */
33
+ spread?: number;
34
+ /** `add` paints it plus-lighter: it brightens what is underneath. Default `normal`. */
35
+ blend?: "normal" | "add";
36
+ }
37
+ /** How a fill is painted: colour or gradient, opacity, blur with spread, blend mode and inner shadows. */
6
38
  export interface FillStyle {
7
39
  /** Colour, any Pixi `ColorSource`. With a gradient, it tints the gradient. */
8
40
  color?: ColorSource;
@@ -10,9 +42,43 @@ export interface FillStyle {
10
42
  alpha?: number;
11
43
  /** Gradient paint. `color` (if given) tints it. */
12
44
  gradient?: Gradient;
13
- /** Gaussian blur radius (standard deviation, local units). Great for glows and soft shadows. */
14
- blur?: number;
45
+ /**
46
+ * Gaussian blur (standard deviation, local units) for glows and soft shadows. A
47
+ * {@link ProgressiveBlur} changes the radius across the shape.
48
+ */
49
+ blur?: number | ProgressiveBlur;
50
+ /** Grows the shape by this many local units before it is blurred, like a Figma shadow spread. Negative shrinks it. */
51
+ spread?: number;
52
+ /**
53
+ * `add` paints plus-lighter: colours add to what is underneath, so overlapping glows bloom
54
+ * towards white. Default `normal`.
55
+ */
56
+ blend?: "normal" | "add";
57
+ /** One or more shadows inside closed shapes, drawn in order on top of the fill. */
58
+ innerShadow?: InnerShadow | InnerShadow[];
59
+ /**
60
+ * Paints every closed shape of the active path as one shape: their distance fields merge, so
61
+ * overlaps are painted once and blur, anti-aliasing and opacity show no seam where they meet.
62
+ * Polygons from `poly()` and `moveTo()` join in too, each subpath on its own. With `stroke()`,
63
+ * the stroke follows the outline of the union, and open paths merge into one stroke.
64
+ * Default false.
65
+ */
66
+ union?: boolean;
67
+ /**
68
+ * Combines the closed shapes of the active path into one shape.
69
+ * `subtract` takes every later shape out of the first one, `intersect` keeps what they all
70
+ * cover, and `exclude` keeps what an odd number of them cover. `union` is the same as
71
+ * `union: true`. A path from `moveTo()` or `svgPath()` takes part as one shape, even-odd.
72
+ * With `stroke()`, the stroke follows the outline of the result. See {@link SilkGraphics.boolean}
73
+ * for nested operations. Default none: every shape is painted on its own.
74
+ */
75
+ op?: ShapeOp;
15
76
  }
77
+ /**
78
+ * A shape operation: `union` merges, `subtract` cuts the later shapes out of the first,
79
+ * `intersect` keeps the overlap, and `exclude` keeps what is covered an odd number of times.
80
+ */
81
+ export type ShapeOp = "union" | "subtract" | "intersect" | "exclude";
16
82
  /** What `fill()` accepts: any Pixi colour, a gradient or a {@link FillStyle}. */
17
83
  export type FillInput = ColorSource | Gradient | FillStyle;
18
84
  /** Shape of the ends of open paths and of every dash: flat, round or square. */
@@ -34,11 +100,20 @@ export interface StrokeStyle extends FillStyle {
34
100
  dashOffset?: number;
35
101
  /** On closed outlines stretch the pattern so it tiles without a seam. Default true. */
36
102
  dashFit?: boolean;
37
- /** Accepted for Pixi compatibility. Joins are always round, the smoothest choice. */
38
- join?: "round" | "miter" | "bevel";
39
- /** Accepted for Pixi compatibility and ignored. */
103
+ /**
104
+ * How segments meet at the corners of paths, polygons and sharp rects, triangles and stars.
105
+ * `miter` extends the outer edges to a point, `bevel` cuts the corner flat, `round` rounds it.
106
+ * Default `miter`, as in Canvas 2D, SVG and Pixi.
107
+ */
108
+ join?: LineJoin;
109
+ /**
110
+ * A miter longer than this many half line widths becomes a bevel, as in Canvas 2D and SVG.
111
+ * Default 10.
112
+ */
40
113
  miterLimit?: number;
41
114
  }
115
+ /** Shape of the corners where two segments of a stroke meet. */
116
+ export type LineJoin = "miter" | "bevel" | "round";
42
117
  /** What `stroke()` accepts: any Pixi colour, a gradient or a {@link StrokeStyle}. */
43
118
  export type StrokeInput = ColorSource | Gradient | StrokeStyle;
44
119
  /** Options of `polyline()`: closed loops and monotone or Catmull-Rom smoothing of the points. */
@@ -67,13 +142,18 @@ export interface SilkGraphicsOptions {
67
142
  minStrokePx?: number;
68
143
  /** Pixi label of the object, for debugging. Default `SilkGraphics`. */
69
144
  label?: string;
145
+ /**
146
+ * Set false to keep this object out of batches: it gets a draw call of its own. Only matters
147
+ * after `enableSilkBatching()`. Default true.
148
+ */
149
+ batch?: boolean;
70
150
  }
71
151
  /**
72
152
  * Geometry behind every {@link SilkGraphics}: one unit quad plus an interleaved instance buffer
73
- * (40 floats per primitive). You rarely need it directly.
153
+ * of 44 floats (`STRIDE`) per primitive. You rarely need it directly.
74
154
  */
75
155
  export declare class SilkGeometry extends Geometry {
76
- /** Per-primitive data, grown on demand and reused across `clear()`. */
156
+ /** Per-primitive data, 44 floats each. It grows on demand and never shrinks, so `clear()` reuses it. */
77
157
  readonly instanceBuffer: Buffer;
78
158
  /** Bounds of everything drawn, in local units (includes stroke widths and blur). */
79
159
  readonly localBounds: Bounds;
@@ -82,8 +162,11 @@ export declare class SilkGeometry extends Geometry {
82
162
  }
83
163
  /**
84
164
  * A PixiJS display object with a `Graphics`-like API. Every primitive is a signed distance field
85
- * evaluated per pixel, so edges are smooth at any scale, rotation and device pixel ratio. Each
86
- * object is one instanced draw call.
165
+ * evaluated per pixel, so edges stay sharp at any zoom, rotation and device pixel ratio. Each
166
+ * object is one instanced draw call, and `enableSilkBatching()` merges neighbours further.
167
+ *
168
+ * It renders on WebGL2. For WebGPU, call `enableWebGPU()` from `pixi-silk/webgpu` before the first
169
+ * SilkGraphics, or create the app with `createSilkApp({ preference: 'webgpu' })`.
87
170
  *
88
171
  * Shapes go on the active path and are painted by {@link SilkGraphics.fill | fill()} or
89
172
  * {@link SilkGraphics.stroke | stroke()}. `stroke()` right after `fill()` paints the same shapes.
@@ -99,7 +182,7 @@ export declare class SilkGeometry extends Geometry {
99
182
  */
100
183
  export declare class SilkGraphics extends Mesh<SilkGeometry, Shader> {
101
184
  /** Settings for new objects. Change them before you create any SilkGraphics. */
102
- static defaults: Required<Omit<SilkGraphicsOptions, "label">>;
185
+ static defaults: Required<Omit<SilkGraphicsOptions, "label" | "batch">>;
103
186
  private _f;
104
187
  private _count;
105
188
  /** Shapes of the active path. fill() and stroke() consume them without clearing, like Pixi's GraphicsContext. */
@@ -114,35 +197,52 @@ export declare class SilkGraphics extends Mesh<SilkGeometry, Shader> {
114
197
  private readonly _box;
115
198
  private readonly _silk;
116
199
  private readonly _uniforms;
200
+ /** Edges of filled paths, one (ax, ay, bx, by) texel each, read by the shader. */
201
+ private _poly;
202
+ private _polyCount;
203
+ private _polyDirty;
204
+ private readonly _polySource;
117
205
  constructor(options?: SilkGraphicsOptions);
118
- /** Number of primitives (= instances in the single draw call). */
206
+ /**
207
+ * Number of primitives drawn, one instance each. A fill with blur, a dashed stroke or a long
208
+ * path can emit several. 0 after `clear()`.
209
+ */
119
210
  get primitiveCount(): number;
120
211
  /** Dither amplitude in 8-bit steps for gradients and blurs (0 disables). Default 1. */
121
212
  get dither(): number;
122
- /** Sets the dither amplitude of this object. */
213
+ /** Takes effect on the next render. With batching on, objects regroup by their settings. */
123
214
  set dither(v: number);
124
- /** Width of the anti-aliasing ramp in device pixels. 1 is a crisp box filter, larger is softer. */
215
+ /** Width of the anti-aliasing ramp in device pixels. 1 is a crisp box filter, larger is softer. Default 1. */
125
216
  get aaWidth(): number;
126
- /** Sets the anti-aliasing width of this object. */
217
+ /** Takes effect on the next render. With batching on, objects regroup by their settings. */
127
218
  set aaWidth(v: number);
128
- /** Strokes thinner than this many device pixels keep this width and fade instead (hairlines). */
219
+ /** Strokes thinner than this many device pixels keep this width and fade instead (hairlines). Default 1. */
129
220
  get minStrokePx(): number;
130
- /** Sets the hairline threshold of this object. */
221
+ /** Takes effect on the next render. With batching on, objects regroup by their settings. */
131
222
  set minStrokePx(v: number);
132
223
  private _setting;
133
- /** Pushes the current transform (Pixi GraphicsContext API). */
224
+ /**
225
+ * Pushes the current drawing transform on a stack, as in Pixi's GraphicsContext. The transform
226
+ * applies to shapes drawn after it, not to the display object.
227
+ */
134
228
  save(): this;
135
- /** Pops the transform pushed by the matching {@link SilkGraphics.save | save()}. */
229
+ /** Pops the transform pushed by the matching {@link SilkGraphics.save | save()}. Does nothing on an empty stack. */
136
230
  restore(): this;
137
- /** Resets the current transform to identity. */
231
+ /** Resets the drawing transform to identity. The `save()` stack is kept. */
138
232
  resetTransform(): this;
139
- /** Replaces the current transform with the matrix `[a c tx; b d ty]`. */
233
+ /**
234
+ * Replaces the drawing transform with the matrix `[a c tx; b d ty]`. Skew is not supported:
235
+ * shapes take the rotation and the scale of each axis, and widths take the uniform scale.
236
+ */
140
237
  setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this;
141
- /** Moves the coordinate system. Shapes drawn next are offset by (x, y). */
238
+ /** Moves the drawing coordinate system. Shapes drawn next are offset by (x, y), local units. `y` defaults to `x`. */
142
239
  translateTransform(x: number, y?: number): this;
143
- /** Scales the coordinate system. Stroke widths, dashes and blur scale with its uniform part. */
240
+ /**
241
+ * Scales the drawing coordinate system. `y` defaults to `x`. Stroke widths, dashes and blur
242
+ * scale with the uniform part, the square root of the determinant.
243
+ */
144
244
  scaleTransform(x: number, y?: number): this;
145
- /** Rotates the coordinate system by `angle` radians (clockwise on screen). Rotated primitives stay exact. */
245
+ /** Rotates the drawing coordinate system by `angle` radians, clockwise on screen. */
146
246
  rotateTransform(angle: number): this;
147
247
  private _x;
148
248
  private _y;
@@ -153,81 +253,147 @@ export declare class SilkGraphics extends Mesh<SilkGeometry, Shader> {
153
253
  /** Maps an angle through the transform's linear part. */
154
254
  private _angle;
155
255
  private get _mirrored();
156
- /** Axis-aligned rectangle (rotated by the current transform, if any). */
256
+ /** Rectangle with its top-left corner at (x, y). A negative width or height flips it to the other side. */
157
257
  rect(x: number, y: number, w: number, h: number): this;
158
258
  /**
159
259
  * Rectangle with rounded corners. `smoothing` above 0 turns the corners into squircles.
260
+ * Negative radii count as 0.
160
261
  *
161
- * @param radius - one radius or `[topLeft, topRight, bottomRight, bottomLeft]`
162
- * @param smoothing - 0..1 continuous-curvature ("squircle") corners, iOS uses about 0.6
262
+ * @param radius - one radius or `[topLeft, topRight, bottomRight, bottomLeft]`, local units.
263
+ * Missing entries copy the first (and the top-right for bottom-left), as in CSS.
264
+ * @param smoothing - 0..1 continuous-curvature ("squircle") corners, iOS uses about 0.6. Default 0.
163
265
  */
164
266
  roundRect(x: number, y: number, w: number, h: number, radius?: number | number[], smoothing?: number): this;
165
- /** Rounded rect with fully round ends. */
267
+ /** Rounded rect whose corner radius is half its shorter side, so the short ends are half circles. */
166
268
  pill(x: number, y: number, w: number, h: number): this;
167
- /** Circle centred on (x, y). */
269
+ /** Circle centred on (x, y). A negative radius counts as positive. */
168
270
  circle(x: number, y: number, radius: number): this;
169
- /** Ellipse centred on (x, y) with an exact distance field (no polygon approximation). */
271
+ /** Ellipse centred on (x, y) with radii `rx` and `ry`, local units. It is not a polygon. */
170
272
  ellipse(x: number, y: number, rx: number, ry: number): this;
171
- /** Open circular arc (stroke it). Angles work as in canvas. It starts its own subpath. */
273
+ /**
274
+ * Open circular arc, for strokes. Angles are radians and work as in Canvas 2D: 0 points right
275
+ * and positive angles turn clockwise on screen. It starts its own subpath. A fill paints nothing.
276
+ */
172
277
  arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): this;
173
- /** Open arc given start angle and signed sweep (positive = clockwise on screen). */
278
+ /** Open arc from a start angle and a signed sweep, radians. Positive sweeps clockwise on screen, clamped to one turn. */
174
279
  arcSweep(cx: number, cy: number, radius: number, startAngle: number, sweep: number): this;
175
280
  /**
176
- * Closed annular sector: pie slices, donut segments, gauge segments.
177
- * @param innerRadius - 0 for a pie slice
178
- * @param cornerRadius - rounds all corners
281
+ * Closed annular sector, for pie slices, donut segments and gauges. Angles are radians, and the
282
+ * sweep is clamped to one turn.
283
+ * @param innerRadius - 0 for a pie slice. Clamped to `radius`.
284
+ * @param cornerRadius - rounds all corners. Clamped to half the ring width.
179
285
  */
180
286
  sector(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, innerRadius?: number, cornerRadius?: number): this;
181
- /** Heart icon centred at (cx, cy), `size` wide. `rounding` (0..0.3) puffs it up. */
287
+ /** Heart icon centred at (cx, cy), `size` local units wide. `rounding` (0..0.3, default 0) puffs it up. */
182
288
  heart(cx: number, cy: number, size: number, rounding?: number): this;
183
- /** Star with `points` tips. `innerRadius` defaults to a classic star. */
289
+ /**
290
+ * Star with `points` tips (rounded, at least 3). Angles are radians. `innerRadius` defaults to
291
+ * half of `radius` and is capped at the inner radius of the regular polygon. `cornerRadius` rounds
292
+ * every corner.
293
+ */
184
294
  star(cx: number, cy: number, points: number, radius: number, innerRadius?: number, rotation?: number, cornerRadius?: number): this;
185
- /** Regular polygon (first vertex points up). */
295
+ /** Regular polygon with `sides` corners (rounded, at least 3), the first one pointing up. `rotation` is radians. */
186
296
  regularPoly(cx: number, cy: number, radius: number, sides: number, rotation?: number, cornerRadius?: number): this;
187
- /** Triangle through three points, with optionally rounded corners. */
297
+ /** Triangle through three points. `cornerRadius` (local units, default 0) rounds its corners. */
188
298
  triangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, cornerRadius?: number): this;
189
- /** Straight line (stroke it). */
299
+ /** Straight line from (x0, y0) to (x1, y1), as an open path. Stroke it. */
190
300
  line(x0: number, y0: number, x1: number, y1: number): this;
191
- /** Polyline through points (stroke it), optionally smoothed. */
301
+ /**
302
+ * Open or closed path through points, optionally smoothed. Stroke it, or fill it as one
303
+ * even-odd shape. Smoothing resamples the points every `step` local units.
304
+ */
192
305
  polyline(points: PointsInput, options?: PolylineOptions): this;
193
- /** Pixi-style polygon path. Only strokes are supported for arbitrary paths. */
306
+ /**
307
+ * Pixi-style polygon. `fill()` paints it as one shape (even-odd), so blur, spread, inner
308
+ * shadows and gradients work on bolts, drops and other free outlines.
309
+ */
194
310
  poly(points: PointsInput, close?: boolean): this;
195
311
  /**
196
312
  * Area under a series. Fill it, then `stroke` draws the top line. Points must be sorted by x.
197
- * @param lower - baseline y, or a second series with the same x values for bands
313
+ * The path transform's translation and scale apply, but rotation and skew do not: rotate the
314
+ * object instead. It warns once and ignores them.
315
+ * @param lower - baseline y, or a second series with the same number of points for bands.
316
+ * A different count warns and adds nothing.
198
317
  */
199
318
  area(points: PointsInput, lower: number | PointsInput, options?: AreaOptions): this;
200
- /** Starts a new, empty path (shapes drawn so far are kept). */
319
+ /** Starts a new, empty active path. Shapes already painted stay. Unpainted shapes are dropped. */
201
320
  beginPath(): this;
202
- /** Starts a new subpath at (x, y). Paths are stroke-only. */
321
+ /** Starts a new subpath at (x, y). `fill()` paints the path even-odd, `stroke()` follows it. */
203
322
  moveTo(x: number, y: number): this;
204
- /** Straight segment from the current point to (x, y). */
323
+ /** Straight segment from the current point to (x, y). Without a current point it starts a subpath at (x, y). */
205
324
  lineTo(x: number, y: number): this;
206
- /** Quadratic Bezier to (x, y), flattened adaptively. */
325
+ /** Quadratic Bezier to (x, y). It is flattened into 2 to 256 line segments, about one per 2 units of its control polygon. */
207
326
  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): this;
208
- /** Cubic Bezier to (x, y), flattened adaptively. */
327
+ /** Cubic Bezier to (x, y). It is flattened into 2 to 256 line segments, about one per 2 units of its control polygon. */
209
328
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): this;
210
- /** Closes the current subpath back to its first point. */
329
+ /** Closes the current subpath back to its first point. Does nothing after the path was painted. */
211
330
  closePath(): this;
331
+ /**
332
+ * Adds an SVG path (the `d` attribute) to the active path: M, L, H, V, C, S, Q, T, A and Z, in
333
+ * absolute and relative form. Fill it as one even-odd shape, stroke it, or combine it with
334
+ * other shapes. The current transform applies.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * g.svgPath('M12 2 L22 22 H2 Z M12 8 L17 18 H7 Z').fill(0xff9f0a);
339
+ * ```
340
+ */
341
+ svgPath(d: string): this;
342
+ /**
343
+ * Adds one shape to the active path: what `a` draws combined with what `b` draws by `op`. The
344
+ * shapes each callback adds are merged first, and a callback can call `boolean()` again to nest.
345
+ * Paint the result with `fill()` or `stroke()` like any shape. The callbacks only add shapes:
346
+ * do not paint inside them.
347
+ *
348
+ * The outline is anti-aliased as sharply as a circle. Inside the shape the distance is a close
349
+ * bound: a large blur, spread or inner shadow can round its
350
+ * inner corners slightly.
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * // a ring with a notch: a circle minus a smaller circle and a bar
355
+ * g.boolean('subtract', (g) => g.circle(50, 50, 40), (g) => g.circle(50, 50, 24).rect(46, 0, 8, 30))
356
+ * .fill(0x30d158)
357
+ * .stroke({ width: 2, color: 0xffffff });
358
+ * ```
359
+ */
360
+ boolean(op: ShapeOp, a: (g: this) => unknown, b: (g: this) => unknown): this;
212
361
  private _pathShape;
213
362
  private _currentSubpath;
214
- /** Fills the shapes of the active path (Pixi semantics: `rect().circle().fill()` fills both). */
363
+ /**
364
+ * Fills the shapes of the active path, as in Pixi: `rect().circle().fill()` fills both. Each
365
+ * shape is painted on its own unless `union` or `op` is set. Open arcs are skipped. The path
366
+ * stays active, so `stroke()` can follow, and the next shape you add starts a new path. Does
367
+ * nothing on an empty path.
368
+ */
215
369
  fill(style?: FillInput): this;
216
- /** Strokes the shapes of the active path. Right after `fill()` it merges into the same instances. */
370
+ /**
371
+ * Strokes the shapes of the active path. Right after `fill()` on closed shapes it shares their
372
+ * instances, so fill and stroke cost no more than the fill. A width of 0 or less paints nothing.
373
+ */
217
374
  stroke(style?: StrokeInput): this;
218
- /** Removes everything. Keeps the buffers for reuse, so redrawing every frame is cheap. */
375
+ /**
376
+ * Removes every shape and resets the drawing transform and its `save()` stack. It keeps the
377
+ * buffers and releases gradient rows, so redrawing every frame does not allocate.
378
+ */
219
379
  clear(): this;
220
380
  /**
221
- * Hit test against the real shapes (local coordinates): rings are hollow, lines count only
222
- * within their stroke. Used by Pixi's event system when `eventMode` is set.
381
+ * Hit test against the painted shapes, in local coordinates. Rings are hollow and lines count
382
+ * only within their stroke, at least 1 unit to each side. Blur does not widen the hit area. Pixi's event
383
+ * system calls it when `eventMode` is set.
223
384
  */
224
385
  override containsPoint(point: PointData): boolean;
386
+ /** Destroys the object with its geometry, shader and path texture, and releases its gradient rows. */
225
387
  override destroy(options?: DestroyOptions): void;
226
388
  private _begin;
227
389
  private _rewind;
390
+ /** Tapered strokes keep one capsule per segment. Every other stroke is one field per path. */
391
+ private _strokeSubpaths;
228
392
  private _releaseRamps;
229
393
  private _alloc;
230
394
  private _commit;
395
+ /** Appends the edges of every subpath of a filled path (each closed). Returns the first texel. */
396
+ private _pushEdges;
231
397
  private _setBounds;
232
398
  private _set4;
233
399
  /** Premultiplied color. With a gradient paint it multiplies the ramp (white = untinted). */
@@ -235,9 +401,58 @@ export declare class SilkGraphics extends Mesh<SilkGeometry, Shader> {
235
401
  /** Writes gradient geometry + atlas row. Returns flags to add. */
236
402
  private _gradient;
237
403
  private _frame;
404
+ /** Effects shared by every primitive: spread, progressive blur and plus-lighter. Returns flags to add. */
405
+ private _fx;
406
+ /** How far a paint reaches past the shape: three sigmas of its widest blur plus a positive spread. */
407
+ private static _reach;
238
408
  private _emitClosed;
409
+ /**
410
+ * Writes the parameters of a closed shape (the instance's `aShape0..2`, 12 floats) at `at` and
411
+ * returns its primitive id, or -1 when there is nothing to draw. Path fills push their edges.
412
+ */
413
+ private _shapeParams;
414
+ /** Flags, bounds, colours, gradient, dashes and inner shadows of a closed-shape instance at `o`. */
415
+ private _paintClosed;
416
+ /**
417
+ * One instance for the closed shapes of `shapes` combined by `op` (an {@link OP} id): a
418
+ * Prim.Union whose records the shader folds into one distance field. Overlaps are painted once
419
+ * and the outline is exact. A union takes every subpath of a path on its own, as it always did.
420
+ * The other operations take a path as one even-odd shape. Arcs and areas are skipped.
421
+ */
422
+ private _emitOps;
423
+ /**
424
+ * Appends the records (4 texels each) of `shapes` combined by `op`. The first operand is
425
+ * pushed and each later one folds into it. A boolean shape pushes both its sides and pops them
426
+ * with its own op. Returns the bounds of the result, or null when it has no closed shape.
427
+ * `at` is scratch space for the parameters of one shape.
428
+ */
429
+ private _opRecords;
430
+ /**
431
+ * One instance per inner shadow: a copy of the shape at `o`, painted only inside it, from the
432
+ * same distance field moved by the offset and shrunk by the spread.
433
+ */
434
+ private _emitInner;
239
435
  private _emitArc;
240
436
  private _emitPath;
437
+ /** Makes room for `n` more texels in the path texture and returns the first one. */
438
+ private _reserve;
439
+ /** Appends raw texels (4 floats each) to the path texture. Returns the first texel. */
440
+ private _pushTexels;
441
+ /**
442
+ * Strokes paths as one distance field (Prim.Path). Segments go to the path texture behind a
443
+ * header per subpath, with their lengths along the path after them. Instances own windows of
444
+ * segments: runs of short subpaths up to PATH_CHUNK segments in all, or chunks of PATH_CHUNK
445
+ * segments of a long one. Each instance also lists the windows of the other instances that come
446
+ * near its own. So every pixel of the stroke is shaded once, by the nearest segment, even where
447
+ * the path crosses itself far along its length (see `pathSD` in the shader).
448
+ */
449
+ private _emitStroke;
450
+ private _set4Poly;
451
+ /**
452
+ * One Prim.Path instance. Its window texels (header texel, first segment, count, owner key)
453
+ * list the windows it owns, then the windows of other instances near them.
454
+ */
455
+ private _pathInstance;
241
456
  private _emitArea;
242
457
  }
243
458
  //#endregion