@sepveneto/dao 0.0.4 → 0.1.0
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/README.md +58 -0
- package/dist/Loader.d.ts +3 -3
- package/dist/ResourceManager.d.ts +8 -2
- package/dist/app/Application.d.ts +18 -0
- package/dist/app/ResizePlugin.d.ts +16 -0
- package/dist/app/__tests__/Application.test.d.ts +1 -0
- package/dist/app/index.d.ts +1 -0
- package/dist/assets/Assets.d.ts +1 -0
- package/dist/dao.cjs +2 -2
- package/dist/dao.cjs.map +1 -0
- package/dist/dao.js +2175 -426
- package/dist/dao.js.map +1 -0
- package/dist/events/FederatedEvent.d.ts +15 -0
- package/dist/events/FederatedEventMap.d.ts +13 -0
- package/dist/events/__tests__/EventSystem.test.d.ts +1 -0
- package/dist/main.d.ts +8 -28
- package/dist/maths/Bounds.d.ts +31 -0
- package/dist/maths/Matrix.d.ts +85 -0
- package/dist/maths/Point.d.ts +17 -0
- package/dist/maths/const.d.ts +14 -0
- package/dist/maths/index.d.ts +18 -0
- package/dist/maths/shapes/Polygon.d.ts +10 -0
- package/dist/maths/shapes/Rectangle.d.ts +11 -0
- package/dist/renderer/CanvasPool.d.ts +11 -0
- package/dist/renderer/InstructionSet.d.ts +18 -0
- package/dist/renderer/index.d.ts +66 -0
- package/dist/renderer/texture/RenderTexture.d.ts +7 -0
- package/dist/renderer/texture/Texture.d.ts +25 -0
- package/dist/renderer/texture/TextureSource.d.ts +50 -0
- package/dist/scene/ViewContainer.d.ts +22 -0
- package/dist/scene/batcher/Batcher.d.ts +10 -0
- package/dist/scene/batcher/BatcherPipe.d.ts +34 -0
- package/dist/scene/batcher/index.d.ts +2 -0
- package/dist/scene/container/Container.d.ts +198 -0
- package/dist/scene/container/RenderGroup.d.ts +24 -0
- package/dist/scene/container/__tests__/Container.Sort.test.d.ts +1 -0
- package/dist/scene/container/__tests__/RenderGroup.test.d.ts +1 -0
- package/dist/scene/container/__tests__/transform-visibility.test.d.ts +1 -0
- package/dist/scene/container/__tests__/transform.test.d.ts +1 -0
- package/dist/scene/container/destroyTypes.d.ts +9 -0
- package/dist/scene/container/mixins/childrenHelperMixin.d.ts +5 -0
- package/dist/scene/container/mixins/effectMixin.d.ts +16 -0
- package/dist/scene/container/mixins/measureMixin.d.ts +14 -0
- package/dist/scene/container/mixins/sortMixin.d.ts +13 -0
- package/dist/scene/container/utils/updateRenderGroupTransform.d.ts +4 -0
- package/dist/scene/container/utils.d.ts +2 -0
- package/dist/scene/graphics/Graphics.d.ts +19 -0
- package/dist/scene/graphics/GraphicsContext.d.ts +61 -0
- package/dist/scene/graphics/GraphicsPipe.d.ts +15 -0
- package/dist/scene/graphics/index.d.ts +3 -0
- package/dist/scene/graphics/path/GraphicsPath.d.ts +25 -0
- package/dist/scene/graphics/path/ShapePath.d.ts +27 -0
- package/dist/scene/graphics/path/buildAdaptiveBezier.d.ts +14 -0
- package/dist/scene/index.d.ts +6 -0
- package/dist/scene/mask/StencilMask.d.ts +14 -0
- package/dist/scene/mask/StencilMaskPipe.d.ts +16 -0
- package/dist/scene/sprite/Sprite.d.ts +22 -0
- package/dist/scene/sprite/SpritePipe.d.ts +12 -0
- package/dist/scene/sprite/index.d.ts +2 -0
- package/dist/scene/text/Text.d.ts +40 -0
- package/dist/scene/text/TextPipe.d.ts +24 -0
- package/dist/scene/text/TextStyle.d.ts +632 -0
- package/dist/scene/text/TextSystem.d.ts +19 -0
- package/dist/scene/text/__tests__/Text.test.d.ts +1 -0
- package/dist/scene/text/index.d.ts +2 -0
- package/dist/scene/text/utils.d.ts +74 -0
- package/dist/system/CanvasContextSystem.d.ts +15 -0
- package/dist/system/EventSystem.d.ts +49 -5
- package/dist/system/ExtractSystem.d.ts +18 -0
- package/dist/system/RenderGroupSystem.d.ts +16 -0
- package/dist/system/ViewSystem.d.ts +22 -0
- package/dist/system/index.d.ts +2 -0
- package/dist/ticker/Ticker.d.ts +290 -0
- package/dist/ticker/TickerListener.d.ts +21 -0
- package/dist/ticker/index.d.ts +2 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/type.d.ts +16 -0
- package/dist/utils/uid.d.ts +19 -0
- package/package.json +19 -3
- package/dist/Camera.d.ts +0 -46
- package/dist/Container.d.ts +0 -17
- package/dist/Display.d.ts +0 -60
- package/dist/Factory.d.ts +0 -7
- package/dist/GameObject.d.ts +0 -17
- package/dist/Projection.d.ts +0 -25
- package/dist/Renderer.d.ts +0 -6
- package/dist/Scene.d.ts +0 -27
- package/dist/SortStragety.d.ts +0 -10
- package/dist/World.d.ts +0 -7
- package/dist/system/InputSystem.d.ts +0 -37
- package/dist/system/SortSystem.d.ts +0 -8
- package/dist/system/TweenManager.d.ts +0 -49
- package/dist/utils.d.ts +0 -5
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { DestroyOptions } from '../container/destroyTypes';
|
|
2
|
+
/**
|
|
3
|
+
* The alignment of the text.
|
|
4
|
+
*
|
|
5
|
+
* - 'left': Aligns text to the left edge.
|
|
6
|
+
* - 'center': Centers text horizontally.
|
|
7
|
+
* - 'right': Aligns text to the right edge.
|
|
8
|
+
* - 'justify': Justifies text, aligning both left and right edges.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { TextStyle } from 'pixi.js';
|
|
12
|
+
* const style = new TextStyle({
|
|
13
|
+
* align: 'center', // or 'left', 'right', 'justify'
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
* @category text
|
|
17
|
+
* @standard
|
|
18
|
+
*/
|
|
19
|
+
export type TextStyleAlign = 'left' | 'center' | 'right' | 'justify';
|
|
20
|
+
/**
|
|
21
|
+
* The font style input for text styles. Controls the slant or italicization of the text.
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* // Create text with normal font style
|
|
25
|
+
* const normalText = new Text({
|
|
26
|
+
* text: 'Normal Style Text',
|
|
27
|
+
* style: {
|
|
28
|
+
* fontStyle: 'normal',
|
|
29
|
+
* fontSize: 24
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Create italic text
|
|
34
|
+
* const italicText = new Text({
|
|
35
|
+
* text: 'Italic Style Text',
|
|
36
|
+
* style: {
|
|
37
|
+
* fontStyle: 'italic',
|
|
38
|
+
* fontSize: 24,
|
|
39
|
+
* fontFamily: 'Arial'
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Create oblique text
|
|
44
|
+
* const obliqueText = new Text({
|
|
45
|
+
* text: 'Oblique Style Text',
|
|
46
|
+
* style: {
|
|
47
|
+
* fontStyle: 'oblique',
|
|
48
|
+
* fontSize: 24,
|
|
49
|
+
* fontFamily: 'Times New Roman'
|
|
50
|
+
* }
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Dynamic style changes
|
|
54
|
+
* let isItalic = false;
|
|
55
|
+
* text.style = {
|
|
56
|
+
* ...text.style,
|
|
57
|
+
* fontStyle: isItalic ? 'italic' : 'normal'
|
|
58
|
+
* };
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Supported values:
|
|
62
|
+
* - 'normal': Regular upright text with no slant
|
|
63
|
+
* - 'italic': True italics using specifically designed italic glyphs
|
|
64
|
+
* - 'oblique': Slanted version of the regular glyphs
|
|
65
|
+
* @remarks
|
|
66
|
+
* - 'italic' uses specially designed glyphs with cursive characteristics
|
|
67
|
+
* - 'oblique' is a mechanical slant of the normal glyphs
|
|
68
|
+
* - Not all fonts include true italic designs; some may fall back to oblique
|
|
69
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-style | MDN font-style}
|
|
70
|
+
* @category text
|
|
71
|
+
* @standard
|
|
72
|
+
*/
|
|
73
|
+
export type TextStyleFontStyle = 'normal' | 'italic' | 'oblique';
|
|
74
|
+
/**
|
|
75
|
+
* The font variant input for text styles. Controls the capitalization and presentation of letters.
|
|
76
|
+
* Used to enable special rendering like small caps.
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* // Create text with normal font variant
|
|
80
|
+
* const normalText = new Text({
|
|
81
|
+
* text: 'Normal Text',
|
|
82
|
+
* style: {
|
|
83
|
+
* fontVariant: 'normal',
|
|
84
|
+
* fontSize: 24
|
|
85
|
+
* }
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* // Create text with small-caps variant
|
|
89
|
+
* const smallCapsText = new Text({
|
|
90
|
+
* text: 'Small Caps Text',
|
|
91
|
+
* style: {
|
|
92
|
+
* fontVariant: 'small-caps',
|
|
93
|
+
* fontSize: 24,
|
|
94
|
+
* fontFamily: 'Arial'
|
|
95
|
+
* }
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Use in a TextStyle instance
|
|
99
|
+
* const style = new TextStyle({
|
|
100
|
+
* fontVariant: 'small-caps',
|
|
101
|
+
* fontSize: 32,
|
|
102
|
+
* fill: 0x4a4a4a
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* // Update variant dynamically
|
|
106
|
+
* text.style = {
|
|
107
|
+
* ...text.style,
|
|
108
|
+
* fontVariant: text.style.fontVariant === 'normal' ? 'small-caps' : 'normal'
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* Supported values:
|
|
113
|
+
* - 'normal': Regular text rendering with standard capitalization
|
|
114
|
+
* - 'small-caps': Renders lowercase letters as smaller versions of capital letters
|
|
115
|
+
* @remarks
|
|
116
|
+
* Small caps are only available if the font supports them.
|
|
117
|
+
* Not all fonts include true small caps glyphs.
|
|
118
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant | MDN font-variant}
|
|
119
|
+
* @category text
|
|
120
|
+
* @standard
|
|
121
|
+
*/
|
|
122
|
+
export type TextStyleFontVariant = 'normal' | 'small-caps';
|
|
123
|
+
/**
|
|
124
|
+
* The font weight input for text styles. Controls the thickness or boldness of the text.
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* // Create text with different font weights
|
|
128
|
+
* const normalText = new Text({
|
|
129
|
+
* text: 'Normal Weight',
|
|
130
|
+
* style: { fontWeight: 'normal' }
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* const boldText = new Text({
|
|
134
|
+
* text: 'Bold Weight',
|
|
135
|
+
* style: { fontWeight: 'bold' }
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* // Using numeric weights
|
|
139
|
+
* const lightText = new Text({
|
|
140
|
+
* text: 'Light Weight',
|
|
141
|
+
* style: { fontWeight: '300' }
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* const mediumText = new Text({
|
|
145
|
+
* text: 'Medium Weight',
|
|
146
|
+
* style: { fontWeight: '500' }
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* const heavyText = new Text({
|
|
150
|
+
* text: 'Heavy Weight',
|
|
151
|
+
* style: { fontWeight: '900' }
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* // Responsive weight changes
|
|
155
|
+
* const adaptiveText = new Text({
|
|
156
|
+
* text: 'Adaptive Weight',
|
|
157
|
+
* style: { fontWeight: window.innerWidth > 600 ? 'bold' : 'normal' }
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* Supported values:
|
|
162
|
+
* - 'normal': Standard weight (equivalent to 400)
|
|
163
|
+
* - 'bold': Bold weight (equivalent to 700)
|
|
164
|
+
* - 'bolder': One weight darker than the parent element
|
|
165
|
+
* - 'lighter': One weight lighter than the parent element
|
|
166
|
+
* - '100': Thin (Hairline)
|
|
167
|
+
* - '200': Extra Light (Ultra Light)
|
|
168
|
+
* - '300': Light
|
|
169
|
+
* - '400': Normal
|
|
170
|
+
* - '500': Medium
|
|
171
|
+
* - '600': Semi Bold (Demi Bold)
|
|
172
|
+
* - '700': Bold
|
|
173
|
+
* - '800': Extra Bold (Ultra Bold)
|
|
174
|
+
* - '900': Heavy (Black)
|
|
175
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight | MDN font-weight}
|
|
176
|
+
* @category text
|
|
177
|
+
* @standard
|
|
178
|
+
*/
|
|
179
|
+
export type TextStyleFontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
180
|
+
/**
|
|
181
|
+
* The line join style for text strokes. Determines how lines connect at corners.
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* // Create text with miter joins (sharp corners)
|
|
185
|
+
* const sharpText = new Text({
|
|
186
|
+
* text: 'Sharp Corners',
|
|
187
|
+
* style: {
|
|
188
|
+
* fontSize: 36,
|
|
189
|
+
* stroke: {
|
|
190
|
+
* color: '#4a1850',
|
|
191
|
+
* width: 4,
|
|
192
|
+
* lineJoin: 'miter' // Sharp corners
|
|
193
|
+
* }
|
|
194
|
+
* }
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* // Create text with round joins
|
|
198
|
+
* const roundText = new Text({
|
|
199
|
+
* text: 'Rounded Corners',
|
|
200
|
+
* style: {
|
|
201
|
+
* fontSize: 36,
|
|
202
|
+
* stroke: {
|
|
203
|
+
* color: '#4a1850',
|
|
204
|
+
* width: 4,
|
|
205
|
+
* lineJoin: 'round' // Smooth rounded corners
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* });
|
|
209
|
+
*
|
|
210
|
+
* // Create text with beveled joins
|
|
211
|
+
* const bevelText = new Text({
|
|
212
|
+
* text: 'Beveled Corners',
|
|
213
|
+
* style: {
|
|
214
|
+
* fontSize: 36,
|
|
215
|
+
* stroke: {
|
|
216
|
+
* color: '#4a1850',
|
|
217
|
+
* width: 4,
|
|
218
|
+
* lineJoin: 'bevel' // Flattened corners
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
* Available values:
|
|
224
|
+
* - 'miter': Creates sharp corners by extending the outer edges until they meet
|
|
225
|
+
* - 'round': Creates smooth, rounded corners using a circular arc
|
|
226
|
+
* - 'bevel': Creates flattened corners by filling an additional triangle between the outer edges
|
|
227
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin | MDN lineJoin}
|
|
228
|
+
* @category text
|
|
229
|
+
* @standard
|
|
230
|
+
*/
|
|
231
|
+
export type TextStyleLineJoin = 'miter' | 'round' | 'bevel';
|
|
232
|
+
/**
|
|
233
|
+
* The text baseline for text styles.
|
|
234
|
+
*
|
|
235
|
+
* This can be:
|
|
236
|
+
* - 'alphabetic': The alphabetic baseline
|
|
237
|
+
* - 'top': The top of the text
|
|
238
|
+
* - 'hanging': The hanging baseline
|
|
239
|
+
* - 'middle': The middle of the text
|
|
240
|
+
* - 'ideographic': The ideographic baseline
|
|
241
|
+
* - 'bottom': The bottom of the text
|
|
242
|
+
* @category text
|
|
243
|
+
* @standard
|
|
244
|
+
*/
|
|
245
|
+
export type TextStyleTextBaseline = 'alphabetic' | 'top' | 'hanging' | 'middle' | 'ideographic' | 'bottom';
|
|
246
|
+
/**
|
|
247
|
+
* Controls how whitespace (spaces, tabs, and line breaks) is handled within the text.
|
|
248
|
+
* This affects text wrapping and spacing behavior.
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* // Normal mode (collapse spaces and newlines)
|
|
252
|
+
* const normalText = new Text({
|
|
253
|
+
* text: 'Hello World\n\nNew Line',
|
|
254
|
+
* style: {
|
|
255
|
+
* whiteSpace: 'normal',
|
|
256
|
+
* fontSize: 24
|
|
257
|
+
* }
|
|
258
|
+
* }); // Renders as: "Hello World New Line"
|
|
259
|
+
*
|
|
260
|
+
* // Pre mode (preserve all whitespace)
|
|
261
|
+
* const preText = new Text({
|
|
262
|
+
* text: 'Hello World\n\nNew Line',
|
|
263
|
+
* style: {
|
|
264
|
+
* whiteSpace: 'pre',
|
|
265
|
+
* fontSize: 24
|
|
266
|
+
* }
|
|
267
|
+
* }); // Preserves spaces and line breaks exactly
|
|
268
|
+
*
|
|
269
|
+
* // Pre-line mode (preserve newlines, collapse spaces)
|
|
270
|
+
* const preLineText = new Text({
|
|
271
|
+
* text: 'Hello World\n\nNew Line',
|
|
272
|
+
* style: {
|
|
273
|
+
* whiteSpace: 'pre-line',
|
|
274
|
+
* fontSize: 24
|
|
275
|
+
* }
|
|
276
|
+
* }); // Preserves line breaks, collapses multiple spaces
|
|
277
|
+
*
|
|
278
|
+
* // With word wrap enabled
|
|
279
|
+
* const wrappedText = new Text({
|
|
280
|
+
* text: 'A long text with multiple spaces\nand line breaks',
|
|
281
|
+
* style: {
|
|
282
|
+
* whiteSpace: 'pre-line',
|
|
283
|
+
* wordWrap: true,
|
|
284
|
+
* wordWrapWidth: 200,
|
|
285
|
+
* fontSize: 24
|
|
286
|
+
* }
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* Supported values:
|
|
291
|
+
* - 'normal': Collapses all whitespace (spaces, tabs, line breaks) into a single space
|
|
292
|
+
* - 'pre': Preserves all whitespace characters exactly as written
|
|
293
|
+
* - 'pre-line': Preserves line breaks but collapses multiple spaces into a single space
|
|
294
|
+
* @remarks
|
|
295
|
+
* - 'normal' is best for single-line text or when you want to ignore formatting
|
|
296
|
+
* - 'pre' is useful for code blocks or when exact spacing is important
|
|
297
|
+
* - 'pre-line' is good for formatted text where you want to keep line breaks but clean up spaces
|
|
298
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/white-space | MDN white-space}
|
|
299
|
+
* @see {@link TextStyle#wordWrap} For controlling text wrapping
|
|
300
|
+
* @category text
|
|
301
|
+
* @standard
|
|
302
|
+
*/
|
|
303
|
+
export type TextStyleWhiteSpace = 'normal' | 'pre' | 'pre-line';
|
|
304
|
+
/**
|
|
305
|
+
* Defines a drop shadow effect for text rendering.
|
|
306
|
+
* Drop shadows add depth and emphasis to text by creating a shadow offset from the text.
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* // Create text with basic drop shadow
|
|
310
|
+
* const text = new Text({
|
|
311
|
+
* text: 'Shadow Text',
|
|
312
|
+
* style: {
|
|
313
|
+
* fontSize: 48,
|
|
314
|
+
* dropShadow: {
|
|
315
|
+
* alpha: 0.5, // 50% opacity shadow
|
|
316
|
+
* angle: Math.PI / 6, // 30 degrees
|
|
317
|
+
* blur: 4, // Soft shadow edge
|
|
318
|
+
* color: '#000000', // Black shadow
|
|
319
|
+
* distance: 6 // Shadow offset
|
|
320
|
+
* }
|
|
321
|
+
* }
|
|
322
|
+
* });
|
|
323
|
+
*
|
|
324
|
+
* // Dynamic shadow updates
|
|
325
|
+
* text.style.dropShadow = {
|
|
326
|
+
* alpha: Math.sin(Date.now() / 1000) * 0.5 + 0.5, // Pulsing opacity
|
|
327
|
+
* angle: Date.now() / 1000, // Rotating angle
|
|
328
|
+
* blur: 4,
|
|
329
|
+
* color: '#000000',
|
|
330
|
+
* distance: 6
|
|
331
|
+
* };
|
|
332
|
+
* ```
|
|
333
|
+
* @category text
|
|
334
|
+
* @standard
|
|
335
|
+
*/
|
|
336
|
+
export type TextDropShadow = {
|
|
337
|
+
/**
|
|
338
|
+
* The opacity of the drop shadow.
|
|
339
|
+
* - Range: 0 to 1
|
|
340
|
+
* - 0 = fully transparent
|
|
341
|
+
* - 1 = fully opaque
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* // Set drop shadow opacity to 50%
|
|
345
|
+
* dropShadow: {
|
|
346
|
+
* alpha: 0.5
|
|
347
|
+
* }
|
|
348
|
+
* ```
|
|
349
|
+
* @default 1
|
|
350
|
+
*/
|
|
351
|
+
alpha: number;
|
|
352
|
+
/**
|
|
353
|
+
* The angle of the drop shadow in radians.
|
|
354
|
+
* - 0 = right
|
|
355
|
+
* - Math.PI/2 = down
|
|
356
|
+
* - Math.PI = left
|
|
357
|
+
* - Math.PI*1.5 = up
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* // Set drop shadow angle to 30 degrees
|
|
361
|
+
* dropShadow: {
|
|
362
|
+
* angle: Math.PI / 6 // 30 degrees
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
* @default Math.PI/6 (30 degrees)
|
|
366
|
+
*/
|
|
367
|
+
angle: number;
|
|
368
|
+
/**
|
|
369
|
+
* The blur radius of the shadow.
|
|
370
|
+
* - 0 = sharp shadow
|
|
371
|
+
* - Higher values = softer shadow
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* // Set drop shadow blur radius to 10 pixels
|
|
375
|
+
* dropShadow: {
|
|
376
|
+
* blur: 10
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
* @default 0
|
|
380
|
+
*/
|
|
381
|
+
blur: number;
|
|
382
|
+
/**
|
|
383
|
+
* The color of the drop shadow.
|
|
384
|
+
* Accepts any valid CSS color string, hex number, or RGB/RGBA values.
|
|
385
|
+
* @example '#000000', 'rgba(0,0,0,0.5)', 0x000000
|
|
386
|
+
* @default 'black'
|
|
387
|
+
*/
|
|
388
|
+
color: string;
|
|
389
|
+
/**
|
|
390
|
+
* The distance of the drop shadow from the text.
|
|
391
|
+
* Measured in pixels.
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* // Set drop shadow distance to 5 pixels
|
|
395
|
+
* dropShadow: {
|
|
396
|
+
* distance: 5
|
|
397
|
+
* }
|
|
398
|
+
* ```
|
|
399
|
+
* @default 5
|
|
400
|
+
*/
|
|
401
|
+
distance: number;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* Constructor options used for `TextStyle` instances. Defines the visual appearance and layout of text.
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* // Basic text style
|
|
408
|
+
* const basicStyle = new TextStyle({
|
|
409
|
+
* fontSize: 24,
|
|
410
|
+
* fill: 'black',
|
|
411
|
+
* fontFamily: 'Arial'
|
|
412
|
+
* });
|
|
413
|
+
*
|
|
414
|
+
* // Rich text style with multiple features
|
|
415
|
+
* const richStyle = new TextStyle({
|
|
416
|
+
* fontFamily: ['Arial', 'Helvetica', 'sans-serif'],
|
|
417
|
+
* fontSize: 36,
|
|
418
|
+
* fontWeight: 'bold',
|
|
419
|
+
* fill: 'red',
|
|
420
|
+
* stroke: { color: '#4a1850', width: 5 },
|
|
421
|
+
* align: 'center',
|
|
422
|
+
* dropShadow: {
|
|
423
|
+
* color: '#000000',
|
|
424
|
+
* blur: 4,
|
|
425
|
+
* distance: 6,
|
|
426
|
+
* angle: Math.PI / 6
|
|
427
|
+
* },
|
|
428
|
+
* wordWrap: true,
|
|
429
|
+
* wordWrapWidth: 440,
|
|
430
|
+
* lineHeight: 40,
|
|
431
|
+
* textBaseline: 'middle'
|
|
432
|
+
* });
|
|
433
|
+
* ```
|
|
434
|
+
* @see {@link TextStyle} For the main style class
|
|
435
|
+
* @category text
|
|
436
|
+
* @standard
|
|
437
|
+
*/
|
|
438
|
+
export interface TextStyleOptions {
|
|
439
|
+
/**
|
|
440
|
+
* Alignment for multiline text, does not affect single line text
|
|
441
|
+
* @default 'left'
|
|
442
|
+
*/
|
|
443
|
+
align?: TextStyleAlign;
|
|
444
|
+
/**
|
|
445
|
+
* Whether to allow line breaks within words.
|
|
446
|
+
* Requires wordWrap to be true.
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* // Enable word breaking
|
|
450
|
+
* const style = new TextStyle({
|
|
451
|
+
* breakWords: true,
|
|
452
|
+
* wordWrap: true,
|
|
453
|
+
* wordWrapWidth: 200
|
|
454
|
+
* });
|
|
455
|
+
* ```
|
|
456
|
+
* @default false
|
|
457
|
+
*/
|
|
458
|
+
breakWords?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Drop shadow configuration for the text.
|
|
461
|
+
* Can be boolean or a TextDropShadow object.
|
|
462
|
+
* @default null
|
|
463
|
+
*/
|
|
464
|
+
dropShadow?: boolean | Partial<TextDropShadow>;
|
|
465
|
+
/**
|
|
466
|
+
* Fill style for the text.
|
|
467
|
+
* Can be a color, gradient, or pattern.
|
|
468
|
+
* @default 'black'
|
|
469
|
+
*/
|
|
470
|
+
fill?: string;
|
|
471
|
+
/**
|
|
472
|
+
* Font family or families to use.
|
|
473
|
+
* Can be single name or array of fallbacks.
|
|
474
|
+
* @example
|
|
475
|
+
* ```ts
|
|
476
|
+
* // Single font family
|
|
477
|
+
* fontFamily: 'Arial'
|
|
478
|
+
* // Multiple font families
|
|
479
|
+
* fontFamily: ['Helvetica', 'Arial', 'sans-serif']
|
|
480
|
+
* ```
|
|
481
|
+
* @default 'Arial'
|
|
482
|
+
*/
|
|
483
|
+
fontFamily?: string | string[];
|
|
484
|
+
/**
|
|
485
|
+
* Font size in pixels or as string.
|
|
486
|
+
*
|
|
487
|
+
* Equivalents are '26px','20pt','160%' or '1.6em')
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* // Numeric size
|
|
491
|
+
* fontSize: 26
|
|
492
|
+
* // String size
|
|
493
|
+
* fontSize: '26px'
|
|
494
|
+
* // Percentage size
|
|
495
|
+
* fontSize: '160%' // 1.6 times the parent element's font size
|
|
496
|
+
* // Em size
|
|
497
|
+
* fontSize: '1.6em' // 1.6 times the parent element's font size
|
|
498
|
+
* @default 26
|
|
499
|
+
*/
|
|
500
|
+
fontSize?: number | string;
|
|
501
|
+
/**
|
|
502
|
+
* Font style (normal, italic, oblique).
|
|
503
|
+
* @default 'normal'
|
|
504
|
+
*/
|
|
505
|
+
fontStyle?: TextStyleFontStyle;
|
|
506
|
+
/**
|
|
507
|
+
* Font variant (normal, small-caps).
|
|
508
|
+
* @default 'normal'
|
|
509
|
+
*/
|
|
510
|
+
fontVariant?: TextStyleFontVariant;
|
|
511
|
+
/**
|
|
512
|
+
* Font weight (normal, bold, bolder, lighter, 100-900).
|
|
513
|
+
* @default 'normal'
|
|
514
|
+
*/
|
|
515
|
+
fontWeight?: TextStyleFontWeight;
|
|
516
|
+
/** The height of the line, a number that represents the vertical space that a letter uses. */
|
|
517
|
+
leading?: number;
|
|
518
|
+
/** The amount of spacing between letters, default is 0 */
|
|
519
|
+
letterSpacing?: number;
|
|
520
|
+
/** The line height, a number that represents the vertical space that a letter uses */
|
|
521
|
+
lineHeight?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Padding around the text.
|
|
524
|
+
*
|
|
525
|
+
* Occasionally some fonts are cropped. Adding some padding will prevent this from
|
|
526
|
+
* happening by adding padding to all sides of the text.
|
|
527
|
+
*/
|
|
528
|
+
padding?: number;
|
|
529
|
+
/**
|
|
530
|
+
* Stroke style for text outline.
|
|
531
|
+
* @default null
|
|
532
|
+
*/
|
|
533
|
+
stroke?: string;
|
|
534
|
+
/**
|
|
535
|
+
* Vertical alignment baseline.
|
|
536
|
+
* @default 'alphabetic'
|
|
537
|
+
*/
|
|
538
|
+
textBaseline?: TextStyleTextBaseline;
|
|
539
|
+
/**
|
|
540
|
+
* Whether to trim transparent edges.
|
|
541
|
+
* > [!NOTE] This is an expensive operation and should only be used when necessary.
|
|
542
|
+
* @default false
|
|
543
|
+
*/
|
|
544
|
+
trim?: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* How to handle whitespace.
|
|
547
|
+
*
|
|
548
|
+
* It needs wordWrap to be set to true for this to have an effect.
|
|
549
|
+
* @default 'pre'
|
|
550
|
+
*/
|
|
551
|
+
whiteSpace?: TextStyleWhiteSpace;
|
|
552
|
+
/** Indicates if word wrap should be used */
|
|
553
|
+
wordWrap?: boolean;
|
|
554
|
+
/** The width at which text will wrap, it needs wordWrap to be set to true */
|
|
555
|
+
wordWrapWidth?: number;
|
|
556
|
+
/**
|
|
557
|
+
* Custom styles to apply to specific tags within the text.
|
|
558
|
+
* Allows for rich text formatting using simple tag markup like `<red>text</red>`.
|
|
559
|
+
*
|
|
560
|
+
* Tags are only parsed when this property has entries. If `tagStyles` is empty or undefined,
|
|
561
|
+
* `<` characters in text are treated as literal.
|
|
562
|
+
*
|
|
563
|
+
* Nested tags are supported via a style stack - inner tags inherit from outer tags
|
|
564
|
+
* but can override specific properties.
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* const text = new Text({
|
|
568
|
+
* text: '<red>Red</red>, <blue>Blue</blue>, <big>Big</big>',
|
|
569
|
+
* style: {
|
|
570
|
+
* fontFamily: 'Arial',
|
|
571
|
+
* fontSize: 24,
|
|
572
|
+
* fill: 'white',
|
|
573
|
+
* tagStyles: {
|
|
574
|
+
* red: { fill: 'red' },
|
|
575
|
+
* blue: { fill: 'blue' },
|
|
576
|
+
* big: { fontSize: 48 }
|
|
577
|
+
* }
|
|
578
|
+
* }
|
|
579
|
+
* });
|
|
580
|
+
* ```
|
|
581
|
+
* @default undefined
|
|
582
|
+
*/
|
|
583
|
+
tagStyles?: Record<string, TextStyleOptions>;
|
|
584
|
+
}
|
|
585
|
+
export declare class TextStyle {
|
|
586
|
+
uid: number;
|
|
587
|
+
static defaultStyle: TextStyleOptions;
|
|
588
|
+
private _cachedFontString;
|
|
589
|
+
private _fontSize;
|
|
590
|
+
private _fontFamily;
|
|
591
|
+
private _fontStyle;
|
|
592
|
+
private _lineHeight;
|
|
593
|
+
private _leading;
|
|
594
|
+
private _fontVariant;
|
|
595
|
+
private _fontWeight;
|
|
596
|
+
private _letterSpacing;
|
|
597
|
+
private _textBaseline;
|
|
598
|
+
private _align;
|
|
599
|
+
private _wordWrap;
|
|
600
|
+
private _fill;
|
|
601
|
+
_tick: 0;
|
|
602
|
+
constructor(style: Partial<TextStyleOptions>);
|
|
603
|
+
get styleKey(): string;
|
|
604
|
+
get fontSize(): number;
|
|
605
|
+
set fontSize(value: number);
|
|
606
|
+
get fill(): string;
|
|
607
|
+
set fill(value: string);
|
|
608
|
+
get align(): TextStyleAlign;
|
|
609
|
+
set align(value: TextStyleAlign);
|
|
610
|
+
get wordWarp(): boolean;
|
|
611
|
+
set wordWrap(value: boolean);
|
|
612
|
+
get fontFamily(): string | string[];
|
|
613
|
+
set fontFamily(value: string | string[]);
|
|
614
|
+
get leading(): number;
|
|
615
|
+
set leading(value: number);
|
|
616
|
+
get fontStyle(): TextStyleFontStyle;
|
|
617
|
+
set fontStyle(value: TextStyleFontStyle);
|
|
618
|
+
get textBaseline(): TextStyleTextBaseline;
|
|
619
|
+
set textBaseline(value: TextStyleTextBaseline);
|
|
620
|
+
get lineHeight(): number;
|
|
621
|
+
set lineHeight(value: number);
|
|
622
|
+
get letterSpacing(): number;
|
|
623
|
+
set letterSpacing(value: number);
|
|
624
|
+
get fontVariant(): TextStyleFontVariant;
|
|
625
|
+
set fontVariant(value: TextStyleFontVariant);
|
|
626
|
+
get fontWeight(): TextStyleFontWeight;
|
|
627
|
+
set fontWeight(value: TextStyleFontWeight);
|
|
628
|
+
get _fontString(): string;
|
|
629
|
+
update(): void;
|
|
630
|
+
destroy(_options?: DestroyOptions): void;
|
|
631
|
+
}
|
|
632
|
+
export declare function fontStringFromTextStyle(style: TextStyle): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CanvasRenderer } from '../../renderer';
|
|
2
|
+
import { Text } from './Text';
|
|
3
|
+
import { TextStyle } from './TextStyle';
|
|
4
|
+
import { Texture } from '../../renderer/texture/Texture';
|
|
5
|
+
import { TextureSource } from '../../renderer/texture/TextureSource';
|
|
6
|
+
export declare class TextSystem {
|
|
7
|
+
static desc: {
|
|
8
|
+
readonly name: "text";
|
|
9
|
+
};
|
|
10
|
+
readonly renderer: CanvasRenderer;
|
|
11
|
+
private readonly _activeTexture;
|
|
12
|
+
constructor(renderer: CanvasRenderer);
|
|
13
|
+
getManagedTexture(text: Text): Texture<TextureSource<any>>;
|
|
14
|
+
getTexture(options: {
|
|
15
|
+
text: string;
|
|
16
|
+
style: TextStyle;
|
|
17
|
+
resolution: number;
|
|
18
|
+
}): Texture<TextureSource<HTMLCanvasElement | OffscreenCanvas>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|