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.
- package/CHANGELOG.md +114 -0
- package/README.md +48 -68
- package/dist/SilkGraphics.d.ts +270 -55
- package/dist/SilkGraphics.js +909 -147
- package/dist/app.d.ts +32 -16
- package/dist/app.js +44 -10
- package/dist/atlas.d.ts +13 -6
- package/dist/atlas.js +13 -6
- package/dist/batch.d.ts +63 -0
- package/dist/batch.js +327 -0
- package/dist/color.d.ts +4 -1
- package/dist/color.js +9 -4
- package/dist/constants.js +31 -5
- package/dist/curves.d.ts +9 -3
- package/dist/curves.js +11 -5
- package/dist/glass/Glass.d.ts +62 -0
- package/dist/glass/Glass.js +135 -0
- package/dist/glass/GlassFilter.d.ts +33 -0
- package/dist/glass/GlassFilter.js +264 -0
- package/dist/glass/glass-wgsl.js +129 -0
- package/dist/glass/options.d.ts +63 -0
- package/dist/glass/options.js +55 -0
- package/dist/glass.d.ts +4 -0
- package/dist/glass.js +4 -0
- package/dist/glow/Glow.d.ts +60 -0
- package/dist/glow/Glow.js +65 -0
- package/dist/glow/aurora.d.ts +66 -0
- package/dist/glow/aurora.js +133 -0
- package/dist/glow/light.d.ts +38 -0
- package/dist/glow/light.js +83 -0
- package/dist/glow/recipes.d.ts +37 -0
- package/dist/glow/recipes.js +154 -0
- package/dist/glow/shapes.d.ts +13 -0
- package/dist/glow/shapes.js +34 -0
- package/dist/glow.d.ts +6 -0
- package/dist/glow.js +6 -0
- package/dist/gradient.d.ts +57 -4
- package/dist/gradient.js +142 -4
- package/dist/history.d.ts +194 -0
- package/dist/history.js +350 -0
- package/dist/hit.js +160 -26
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -3
- package/dist/layout/flex.js +409 -0
- package/dist/layout/node.d.ts +53 -0
- package/dist/layout/node.js +117 -0
- package/dist/layout/style.d.ts +115 -0
- package/dist/layout.d.ts +3 -0
- package/dist/layout.js +2 -0
- package/dist/motion.d.ts +14 -10
- package/dist/motion.js +14 -10
- package/dist/path.d.ts +150 -0
- package/dist/path.js +761 -0
- package/dist/selection.d.ts +133 -0
- package/dist/selection.js +194 -0
- package/dist/shader-slot.js +9 -0
- package/dist/shader-wgsl.js +946 -0
- package/dist/shader.js +480 -55
- package/dist/signal.d.ts +49 -0
- package/dist/signal.js +79 -0
- package/dist/stroke.js +271 -0
- package/dist/text/SilkText.d.ts +249 -0
- package/dist/text/SilkText.js +568 -0
- package/dist/text/atlas.d.ts +153 -0
- package/dist/text/atlas.js +316 -0
- package/dist/text/edt.d.ts +14 -0
- package/dist/text/edt.js +97 -0
- package/dist/text/label.d.ts +19 -0
- package/dist/text/label.js +38 -0
- package/dist/text/layout.d.ts +150 -0
- package/dist/text/layout.js +270 -0
- package/dist/text/segment.d.ts +34 -0
- package/dist/text/segment.js +98 -0
- package/dist/text/shader.js +355 -0
- package/dist/text.d.ts +7 -0
- package/dist/text.js +7 -0
- package/dist/ui/ButtonDock.d.ts +47 -0
- package/dist/ui/ButtonDock.js +110 -0
- package/dist/ui/RadialMenu.d.ts +222 -0
- package/dist/ui/RadialMenu.js +680 -0
- package/dist/ui/SilkButton.d.ts +149 -0
- package/dist/ui/SilkButton.js +323 -0
- package/dist/ui/ValuePill.d.ts +48 -0
- package/dist/ui/ValuePill.js +77 -0
- package/dist/ui/arc.d.ts +32 -0
- package/dist/ui/arc.js +58 -0
- package/dist/ui/brush.d.ts +117 -0
- package/dist/ui/brush.js +280 -0
- package/dist/ui/camera.d.ts +250 -0
- package/dist/ui/camera.js +634 -0
- package/dist/ui/color/ColorPicker.d.ts +72 -0
- package/dist/ui/color/ColorPicker.js +125 -0
- package/dist/ui/color/ColorSlider.d.ts +81 -0
- package/dist/ui/color/ColorSlider.js +227 -0
- package/dist/ui/color/ColorWheel.d.ts +34 -0
- package/dist/ui/color/ColorWheel.js +117 -0
- package/dist/ui/color/Eyedropper.d.ts +57 -0
- package/dist/ui/color/Eyedropper.js +159 -0
- package/dist/ui/color/OklchPicker.d.ts +45 -0
- package/dist/ui/color/OklchPicker.js +137 -0
- package/dist/ui/color/SwatchPalette.d.ts +60 -0
- package/dist/ui/color/SwatchPalette.js +160 -0
- package/dist/ui/color/SwatchPopup.d.ts +68 -0
- package/dist/ui/color/SwatchPopup.js +237 -0
- package/dist/ui/color/draw.d.ts +22 -0
- package/dist/ui/color/draw.js +128 -0
- package/dist/ui/color/model.d.ts +94 -0
- package/dist/ui/color/model.js +193 -0
- package/dist/ui/color/rings.d.ts +75 -0
- package/dist/ui/color/rings.js +247 -0
- package/dist/ui/color.d.ts +11 -0
- package/dist/ui/color.js +11 -0
- package/dist/ui/dial.d.ts +229 -0
- package/dist/ui/dial.js +553 -0
- package/dist/ui/driver.d.ts +24 -0
- package/dist/ui/driver.js +46 -0
- package/dist/ui/gesture.d.ts +66 -0
- package/dist/ui/gesture.js +116 -0
- package/dist/ui/gizmo.d.ts +199 -0
- package/dist/ui/gizmo.js +957 -0
- package/dist/ui/grid.d.ts +106 -0
- package/dist/ui/grid.js +228 -0
- package/dist/ui/group.d.ts +81 -0
- package/dist/ui/group.js +144 -0
- package/dist/ui/guides.d.ts +142 -0
- package/dist/ui/guides.js +379 -0
- package/dist/ui/halo.d.ts +164 -0
- package/dist/ui/halo.js +438 -0
- package/dist/ui/icon.d.ts +14 -0
- package/dist/ui/icon.js +40 -0
- package/dist/ui/index.d.ts +62 -0
- package/dist/ui/index.js +56 -0
- package/dist/ui/input.d.ts +28 -0
- package/dist/ui/input.js +49 -0
- package/dist/ui/inspector.d.ts +4 -0
- package/dist/ui/inspector.js +4 -0
- package/dist/ui/keys.d.ts +20 -0
- package/dist/ui/keys.js +65 -0
- package/dist/ui/label.d.ts +18 -0
- package/dist/ui/layers.d.ts +5 -0
- package/dist/ui/layers.js +5 -0
- package/dist/ui/layout/debug.d.ts +38 -0
- package/dist/ui/layout/debug.js +299 -0
- package/dist/ui/layout/flex-container.d.ts +150 -0
- package/dist/ui/layout/flex-container.js +441 -0
- package/dist/ui/layout/simulate.d.ts +49 -0
- package/dist/ui/layout/simulate.js +92 -0
- package/dist/ui/layout/smart-container.d.ts +180 -0
- package/dist/ui/layout/smart-container.js +302 -0
- package/dist/ui/layout.d.ts +5 -0
- package/dist/ui/layout.js +5 -0
- package/dist/ui/marquee.d.ts +124 -0
- package/dist/ui/marquee.js +321 -0
- package/dist/ui/measure.d.ts +138 -0
- package/dist/ui/measure.js +351 -0
- package/dist/ui/minimap.d.ts +2 -0
- package/dist/ui/minimap.js +2 -0
- package/dist/ui/modes.d.ts +186 -0
- package/dist/ui/modes.js +380 -0
- package/dist/ui/odometer.d.ts +104 -0
- package/dist/ui/odometer.js +244 -0
- package/dist/ui/outline.d.ts +104 -0
- package/dist/ui/outline.js +310 -0
- package/dist/ui/paint.js +22 -0
- package/dist/ui/panel.d.ts +4 -0
- package/dist/ui/panel.js +4 -0
- package/dist/ui/panels/Inspector.d.ts +228 -0
- package/dist/ui/panels/Inspector.js +516 -0
- package/dist/ui/panels/LayerTree.d.ts +193 -0
- package/dist/ui/panels/LayerTree.js +878 -0
- package/dist/ui/panels/Minimap.d.ts +140 -0
- package/dist/ui/panels/Minimap.js +412 -0
- package/dist/ui/panels/Panel.d.ts +273 -0
- package/dist/ui/panels/Panel.js +767 -0
- package/dist/ui/panels/ScrollView.d.ts +126 -0
- package/dist/ui/panels/ScrollView.js +358 -0
- package/dist/ui/panels/binding.d.ts +59 -0
- package/dist/ui/panels/binding.js +84 -0
- package/dist/ui/panels/fields.d.ts +265 -0
- package/dist/ui/panels/fields.js +760 -0
- package/dist/ui/panels/icons.d.ts +7 -0
- package/dist/ui/panels/icons.js +136 -0
- package/dist/ui/panels/pixi-tree.d.ts +35 -0
- package/dist/ui/panels/pixi-tree.js +82 -0
- package/dist/ui/panels/theme.d.ts +79 -0
- package/dist/ui/panels/theme.js +91 -0
- package/dist/ui/panels/tree.d.ts +130 -0
- package/dist/ui/panels/tree.js +199 -0
- package/dist/ui/pathgizmo.d.ts +253 -0
- package/dist/ui/pathgizmo.js +932 -0
- package/dist/ui/pill.d.ts +3 -0
- package/dist/ui/pill.js +2 -0
- package/dist/ui/ruler.d.ts +113 -0
- package/dist/ui/ruler.js +371 -0
- package/dist/ui/snap.d.ts +151 -0
- package/dist/ui/snap.js +380 -0
- package/dist/ui/spacing.d.ts +122 -0
- package/dist/ui/spacing.js +346 -0
- package/dist/ui/textedit.d.ts +304 -0
- package/dist/ui/textedit.js +1085 -0
- package/dist/ui/timeline.d.ts +175 -0
- package/dist/ui/timeline.js +488 -0
- package/dist/webgpu.d.ts +25 -0
- package/dist/webgpu.js +32 -0
- package/package.json +172 -1
- package/skills/pixi-silk/SKILL.md +138 -0
- package/skills/pixi-silk-app-rendering/SKILL.md +114 -0
- package/skills/pixi-silk-drawing/SKILL.md +154 -0
- package/skills/pixi-silk-editor/SKILL.md +200 -0
- package/skills/pixi-silk-layout/SKILL.md +150 -0
- package/skills/pixi-silk-migrate-from-graphics/SKILL.md +115 -0
- package/skills/pixi-silk-paint/SKILL.md +132 -0
- package/skills/pixi-silk-text/SKILL.md +127 -0
- package/skills/pixi-silk-widgets/SKILL.md +139 -0
package/dist/SilkGraphics.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
14
|
-
|
|
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
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
*
|
|
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,
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
231
|
+
/** Resets the drawing transform to identity. The `save()` stack is kept. */
|
|
138
232
|
resetTransform(): this;
|
|
139
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
177
|
-
*
|
|
178
|
-
* @param
|
|
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
|
-
/**
|
|
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
|
|
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,
|
|
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 (
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
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
|
|
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).
|
|
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)
|
|
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)
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
222
|
-
* within their stroke.
|
|
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
|