modern-canvas 0.7.14 → 0.8.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/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { AnimationItem } from 'lottie-web';
5
5
  import { Colord, RgbaColor, HslaColor, HsvaColor } from 'colord';
6
6
  import { Path2D, LineCap, LineJoin, LineStyle, Path2DSet } from 'modern-path2d';
7
7
  import { Text, MeasureResult } from 'modern-text';
8
- import { Node as Node$1, Direction } from 'yoga-layout/load';
8
+ import { Node as Node$1 } from 'yoga-layout/load';
9
9
 
10
10
  declare abstract class Loader {
11
11
  abstract install(assets: Assets): this;
@@ -444,7 +444,7 @@ declare class Matrix2 extends Matrix {
444
444
  */
445
445
  declare class Matrix3 extends Matrix {
446
446
  constructor(array?: number[]);
447
- invert(): this;
447
+ affineInvert(): this;
448
448
  }
449
449
 
450
450
  declare class Projection2D extends Matrix3 {
@@ -583,8 +583,8 @@ declare class Transform2D extends Matrix3 {
583
583
  y: number;
584
584
  }, output?: TransformableObject): TransformableObject;
585
585
  apply<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
586
- inverse(): this;
587
- applyInverse<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
586
+ affineInverse(): this;
587
+ applyAffineInverse<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
588
588
  isIdentity(): boolean;
589
589
  toObject(): TransformObject;
590
590
  }
@@ -1105,7 +1105,7 @@ declare class WebGLProgramModule extends WebGLModule {
1105
1105
  boundProgram: WebGLProgram | null;
1106
1106
  uniforms: {
1107
1107
  projectionMatrix: number[];
1108
- worldTransformMatrix: number[];
1108
+ viewMatrix: number[];
1109
1109
  };
1110
1110
  create(options?: WebGLProgramOptions): WebGLProgram;
1111
1111
  getMeta(program: WebGLProgram): WebGLProgramMeta;
@@ -1532,7 +1532,7 @@ interface Viewport {
1532
1532
  declare class Viewport extends Node implements Rectangulable {
1533
1533
  flipY: boolean;
1534
1534
  readonly projection: Projection2D;
1535
- readonly worldTransform: Transform2D;
1535
+ readonly canvasTransform: Transform2D;
1536
1536
  protected _framebufferIndex: number;
1537
1537
  protected _framebuffers: ViewportFramebuffer[];
1538
1538
  x: number;
@@ -1557,8 +1557,8 @@ declare class Viewport extends Node implements Rectangulable {
1557
1557
  activateWithCopy(renderer: WebGLRenderer, target: Viewport): void;
1558
1558
  render(renderer: WebGLRenderer, next?: () => void): void;
1559
1559
  getRect(): Rect2;
1560
- toGlobal<P extends Vector2Data = Vector2>(worldPos: Vector2Data, newPos?: P): P;
1561
- toWorld<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
1560
+ toCanvasGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
1561
+ toCanvasScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
1562
1562
  }
1563
1563
 
1564
1564
  interface RenderCall {
@@ -1948,8 +1948,7 @@ declare class Node2D extends CanvasItem {
1948
1948
  constructor(properties?: Partial<Node2DProperties>, nodes?: Node[]);
1949
1949
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1950
1950
  getTransformOrigin(): Vector2;
1951
- getTransform(cb?: (transform: Transform2D) => void): Transform2D;
1952
- updateTransform(): void;
1951
+ updateTransform(cb?: (transform: Transform2D) => void): void;
1953
1952
  updateGlobalTransform(): void;
1954
1953
  protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
1955
1954
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
@@ -1961,7 +1960,7 @@ declare class Node2D extends CanvasItem {
1961
1960
  interface Camera2DProperties extends Node2DProperties {
1962
1961
  }
1963
1962
  interface Camera2DEventMap extends Node2DEventMap {
1964
- updateWorldTransform: () => void;
1963
+ updateCanvasTransform: () => void;
1965
1964
  }
1966
1965
  interface Camera2D {
1967
1966
  on: (<K extends keyof Camera2DEventMap>(type: K, listener: Camera2DEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
@@ -1985,7 +1984,9 @@ declare class Camera2D extends Node2D {
1985
1984
  protected _input(event: InputEvent, key: InputEventKey): void;
1986
1985
  protected _onWheel(e: WheelInputEvent): void;
1987
1986
  updateTransform(): void;
1988
- updateWorldTransform(): void;
1987
+ updateCanvasTransform(): void;
1988
+ toGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
1989
+ toScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
1989
1990
  }
1990
1991
 
1991
1992
  interface BaseElement2DFill extends NormalizedFill {
@@ -2156,7 +2157,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
2156
2157
  protected _updateStyleProperty(key: string, value: any, _oldValue: any, _declaration?: PropertyDeclaration): void;
2157
2158
  protected _updateMaskImage(): void;
2158
2159
  getTransformOrigin(): Vector2;
2159
- getTransform(cb?: (transform: Transform2D) => void): Transform2D;
2160
+ updateTransform(cb?: (transform: Transform2D) => void): void;
2160
2161
  updateGlobalTransform(): void;
2161
2162
  getRect(): Rect2;
2162
2163
  protected _getPointArray(): Vector2Data[];
@@ -2220,6 +2221,76 @@ declare class Element2D extends BaseElement2D {
2220
2221
  protected _updateStyleProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2221
2222
  }
2222
2223
 
2224
+ declare const edgeMap: {
2225
+ left: number;
2226
+ top: number;
2227
+ right: number;
2228
+ bottom: number;
2229
+ start: number;
2230
+ end: number;
2231
+ horizontal: number;
2232
+ vertical: number;
2233
+ all: number;
2234
+ };
2235
+ declare const gutterMap: {
2236
+ column: number;
2237
+ row: number;
2238
+ all: number;
2239
+ };
2240
+ declare const alignMap: {
2241
+ auto: number;
2242
+ 'flex-start': number;
2243
+ center: number;
2244
+ 'flex-end': number;
2245
+ stretch: number;
2246
+ baseline: number;
2247
+ 'space-between': number;
2248
+ 'space-around': number;
2249
+ 'space-evenly': number;
2250
+ };
2251
+ declare const displayMap: {
2252
+ flex: number;
2253
+ none: number;
2254
+ contents: number;
2255
+ };
2256
+ declare const directionMap: {
2257
+ inherit: number;
2258
+ ltr: number;
2259
+ rtl: number;
2260
+ };
2261
+ declare const flexDirectionMap: {
2262
+ column: number;
2263
+ 'column-reverse': number;
2264
+ row: number;
2265
+ 'row-reverse': number;
2266
+ };
2267
+ declare const flexWrapMap: {
2268
+ 'no-wrap': number;
2269
+ wrap: number;
2270
+ 'Wrap-reverse': number;
2271
+ };
2272
+ declare const justifyMap: {
2273
+ 'flex-start': number;
2274
+ center: number;
2275
+ 'flex-end': number;
2276
+ 'space-between': number;
2277
+ 'space-around': number;
2278
+ 'space-evenly': number;
2279
+ };
2280
+ declare const overflowMap: {
2281
+ visible: number;
2282
+ hidden: number;
2283
+ scroll: number;
2284
+ };
2285
+ declare const positionTypeMap: {
2286
+ static: number;
2287
+ relative: number;
2288
+ absolute: number;
2289
+ };
2290
+ declare const boxSizingMap: {
2291
+ 'border-box': number;
2292
+ 'content-box': number;
2293
+ };
2223
2294
  interface ComputedLayout {
2224
2295
  left: number;
2225
2296
  right: number;
@@ -2239,7 +2310,7 @@ declare class FlexLayout {
2239
2310
  get offsetWidth(): number;
2240
2311
  get offsetHeight(): number;
2241
2312
  constructor(_element: FlexElement2D);
2242
- calculateLayout(width?: number | 'auto', height?: number | 'auto', direction?: Direction): void;
2313
+ calculateLayout(width?: number | 'auto', height?: number | 'auto', direction?: typeof displayMap[keyof typeof displayMap]): void;
2243
2314
  getComputedLayout(): ComputedLayout;
2244
2315
  updateStyleProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2245
2316
  }
@@ -2270,7 +2341,7 @@ declare class FlexElement2D extends BaseElement2D implements Rectangulable {
2270
2341
  protected _unparented(oldParent: Node): void;
2271
2342
  protected _updateStyleProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2272
2343
  updateTransform(): void;
2273
- calculateLayout(width?: number | 'auto', height?: number | 'auto', direction?: Direction): void;
2344
+ calculateLayout(width?: number | 'auto', height?: number | 'auto', direction?: typeof directionMap[keyof typeof directionMap]): void;
2274
2345
  }
2275
2346
 
2276
2347
  interface Image2DProperties extends Element2DProperties {
@@ -3141,12 +3212,12 @@ declare class TwistTransition extends Transition {
3141
3212
  apply(renderer: WebGLRenderer, source: Viewport): void;
3142
3213
  }
3143
3214
 
3144
- declare class GIFLoader extends Loader {
3215
+ declare class GifLoader extends Loader {
3145
3216
  load: (url: string) => Promise<AnimatedTexture>;
3146
3217
  install(assets: Assets): this;
3147
3218
  }
3148
3219
 
3149
- declare class JSONLoader extends Loader {
3220
+ declare class JsonLoader extends Loader {
3150
3221
  load: (url: string) => Promise<Record<string, any>>;
3151
3222
  install(assets: Assets): this;
3152
3223
  }
@@ -3174,8 +3245,8 @@ declare class VideoLoader extends Loader {
3174
3245
  type AssetHandler = (url: string, options?: any) => any | Promise<any>;
3175
3246
  interface Assets {
3176
3247
  font: FontLoader;
3177
- gif: GIFLoader;
3178
- json: JSONLoader;
3248
+ gif: GifLoader;
3249
+ json: JsonLoader;
3179
3250
  lottie: LottieLoader;
3180
3251
  text: TextLoader;
3181
3252
  texture: TextureLoader;
@@ -3310,5 +3381,5 @@ interface RenderOptions {
3310
3381
  }
3311
3382
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3312
3383
 
3313
- export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DOutline, BaseElement2DShadow, BaseElement2DShape, BaseElement2DStyle, BaseElement2DText, Camera2D, CanvasContext, CanvasItem, CanvasItemEditor, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, Control, CoreObject, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, Effect, EffectMaterial, Element2D, Element2DStyle, EmbossEffect, Engine, FlexElement2D, FlexElement2DStyle, FlexLayout, FontLoader, GIFLoader, GaussianBlurEffect, Geometry, GlitchEffect, GodrayEffect, GradientTexture, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, ImageTexture, IndexBuffer, Input, InputEvent, JSONLoader, KawaseBlurEffect, KawaseTransition, KeyboardInputEvent, LeftEraseTransition, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, OutlineEffect, PI, PI_2, PixelateEffect, PixelsTexture, PointerInputEvent, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, RawWeakMap, Rect2, RefCounted, Renderer, Resource, Ruler, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, SceneTree, ScrollBar, TextLoader, Texture2D, TextureLoader, TextureRect2D, Ticker, TiltShiftTransition, Timeline, TimelineNode, Transform2D, TransformRect2D, Transition, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, Window, XScrollBar, YScrollBar, ZoomBlurEffect, assets, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, render, timingFunctions, uid };
3384
+ export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DOutline, BaseElement2DShadow, BaseElement2DShape, BaseElement2DStyle, BaseElement2DText, Camera2D, CanvasContext, CanvasItem, CanvasItemEditor, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, Control, CoreObject, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, Effect, EffectMaterial, Element2D, Element2DStyle, EmbossEffect, Engine, FlexElement2D, FlexElement2DStyle, FlexLayout, FontLoader, GaussianBlurEffect, Geometry, GifLoader, GlitchEffect, GodrayEffect, GradientTexture, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, ImageTexture, IndexBuffer, Input, InputEvent, JsonLoader, KawaseBlurEffect, KawaseTransition, KeyboardInputEvent, LeftEraseTransition, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, OutlineEffect, PI, PI_2, PixelateEffect, PixelsTexture, PointerInputEvent, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, RawWeakMap, Rect2, RefCounted, Renderer, Resource, Ruler, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, SceneTree, ScrollBar, TextLoader, Texture2D, TextureLoader, TextureRect2D, Ticker, TiltShiftTransition, Timeline, TimelineNode, Transform2D, TransformRect2D, Transition, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, Window, XScrollBar, YScrollBar, ZoomBlurEffect, alignMap, assets, boxSizingMap, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, determineCrossOrigin, directionMap, displayMap, ease, easeIn, easeInOut, easeOut, edgeMap, flexDirectionMap, flexWrapMap, frag, getDefaultCssPropertyValue, gutterMap, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, justifyMap, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, overflowMap, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, positionTypeMap, render, timingFunctions, uid };
3314
3385
  export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, Camera2DEventMap, Camera2DProperties, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, CustomPropertyAccessor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DEventMap, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, TransformObject, TransformRect2DProperties, TransformableObject, TransitionProperties, UvTransform, Vector2Data, VectorLike, VectorOperateOutput, VertTransform, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };