modern-canvas 0.4.21 → 0.4.22
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.cjs +607 -519
- package/dist/index.d.cts +71 -48
- package/dist/index.d.mts +71 -48
- package/dist/index.d.ts +71 -48
- package/dist/index.js +127 -127
- package/dist/index.mjs +608 -520
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Font } from 'modern-font';
|
|
2
2
|
import { AnimationItem } from 'lottie-web';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
|
+
import { StyleDeclaration, ShadowDeclaration, OutlineDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
|
|
4
5
|
import { Path2D, LineCap, LineJoin, LineStyle } from 'modern-path2d';
|
|
5
|
-
import { StyleDeclaration, ImageSource, ImageSourceRect } from 'modern-idoc';
|
|
6
6
|
import { Node as Node$1, Direction } from 'yoga-layout/load';
|
|
7
7
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
8
8
|
|
|
@@ -1891,11 +1891,36 @@ declare class Node2D extends CanvasItem {
|
|
|
1891
1891
|
protected _process(delta: number): void;
|
|
1892
1892
|
}
|
|
1893
1893
|
|
|
1894
|
+
declare class BaseElement2DOutline extends CoreObject {
|
|
1895
|
+
parent: BaseElement2D;
|
|
1896
|
+
color: string;
|
|
1897
|
+
width: number;
|
|
1898
|
+
style: 'dashed' | 'solid' | string;
|
|
1899
|
+
image?: string;
|
|
1900
|
+
opacity: number;
|
|
1901
|
+
constructor(parent: BaseElement2D);
|
|
1902
|
+
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1903
|
+
updateEffect(): void;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
declare class BaseElement2DShadow extends CoreObject {
|
|
1907
|
+
parent: BaseElement2D;
|
|
1908
|
+
color: string;
|
|
1909
|
+
blur: number;
|
|
1910
|
+
offsetY: number;
|
|
1911
|
+
offsetX: number;
|
|
1912
|
+
constructor(parent: BaseElement2D);
|
|
1913
|
+
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1914
|
+
updateEffect(): void;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1894
1917
|
interface BaseElement2DEventMap extends CanvasItemEventMap {
|
|
1895
1918
|
updateStyleProperty: (key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration) => void;
|
|
1896
1919
|
}
|
|
1897
1920
|
interface BaseElement2DProperties extends Node2DProperties {
|
|
1898
1921
|
style: Partial<BaseElement2DStyleProperties>;
|
|
1922
|
+
shadow: Partial<ShadowDeclaration>;
|
|
1923
|
+
outline: Partial<OutlineDeclaration>;
|
|
1899
1924
|
modulate: ColorValue;
|
|
1900
1925
|
blendMode: WebGLBlendMode;
|
|
1901
1926
|
}
|
|
@@ -1910,10 +1935,11 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
1910
1935
|
protected _style: BaseElement2DStyle;
|
|
1911
1936
|
get style(): BaseElement2DStyle;
|
|
1912
1937
|
set style(style: BaseElement2DStyle);
|
|
1938
|
+
readonly shadow: BaseElement2DShadow;
|
|
1939
|
+
readonly outline: BaseElement2DOutline;
|
|
1913
1940
|
constructor(properties?: Partial<BaseElement2DProperties>, nodes?: Node[]);
|
|
1914
1941
|
setProperties(properties?: Record<PropertyKey, any>): this;
|
|
1915
1942
|
protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1916
|
-
protected _updateBoxShadow(): void;
|
|
1917
1943
|
protected _updateMaskImage(): void;
|
|
1918
1944
|
protected _updateBackgroundColor(): void;
|
|
1919
1945
|
protected _updateBackgroundImage(): Promise<void>;
|
|
@@ -2548,22 +2574,6 @@ declare class AudioWaveform extends Element2D {
|
|
|
2548
2574
|
protected _drawSrc(): void;
|
|
2549
2575
|
}
|
|
2550
2576
|
|
|
2551
|
-
interface BlurEffectProperties extends EffectProperties {
|
|
2552
|
-
strength: number;
|
|
2553
|
-
quality: number;
|
|
2554
|
-
}
|
|
2555
|
-
/**
|
|
2556
|
-
* Gaussian blur
|
|
2557
|
-
*/
|
|
2558
|
-
declare class BlurEffect extends Effect {
|
|
2559
|
-
static materialX: Material;
|
|
2560
|
-
static materialY: Material;
|
|
2561
|
-
strength: number;
|
|
2562
|
-
quality: number;
|
|
2563
|
-
constructor(properties?: Partial<BlurEffectProperties>, children?: Node[]);
|
|
2564
|
-
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
2577
|
interface ColorAdjustEffectProperties extends EffectProperties {
|
|
2568
2578
|
saturation: number;
|
|
2569
2579
|
contrast: number;
|
|
@@ -2638,46 +2648,34 @@ declare class ColorReplaceEffect extends Effect {
|
|
|
2638
2648
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2639
2649
|
}
|
|
2640
2650
|
|
|
2641
|
-
interface
|
|
2651
|
+
interface GaussianBlurEffectProperties extends EffectProperties {
|
|
2642
2652
|
strength: number;
|
|
2643
2653
|
quality: number;
|
|
2644
|
-
pixelSize: [number, number];
|
|
2645
|
-
clamp: boolean;
|
|
2646
2654
|
}
|
|
2647
|
-
declare
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
material: Material;
|
|
2655
|
+
declare class GaussianBlurEffect extends Effect {
|
|
2656
|
+
static materialX: Material;
|
|
2657
|
+
static materialY: Material;
|
|
2651
2658
|
strength: number;
|
|
2652
2659
|
quality: number;
|
|
2653
|
-
|
|
2654
|
-
protected _kernels: number[];
|
|
2655
|
-
constructor(properties?: Partial<KawaseBlurEffectProperties>, children?: Node[]);
|
|
2656
|
-
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
2657
|
-
/** Auto generate kernels by blur & quality */
|
|
2658
|
-
protected _generateKernels(): void;
|
|
2660
|
+
constructor(properties?: Partial<GaussianBlurEffectProperties>, children?: Node[]);
|
|
2659
2661
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2660
2662
|
}
|
|
2661
2663
|
|
|
2662
2664
|
interface DropShadowEffectProperties extends EffectProperties {
|
|
2663
|
-
offset: [number, number];
|
|
2664
2665
|
color: ColorValue;
|
|
2665
|
-
alpha: number;
|
|
2666
|
-
shadowOnly: boolean;
|
|
2667
2666
|
blur: number;
|
|
2668
|
-
|
|
2669
|
-
|
|
2667
|
+
offsetX: number;
|
|
2668
|
+
offsetY: number;
|
|
2669
|
+
shadowOnly: boolean;
|
|
2670
2670
|
}
|
|
2671
2671
|
declare class DropShadowEffect extends Effect {
|
|
2672
2672
|
static material: Material;
|
|
2673
|
-
offset: [number, number];
|
|
2674
2673
|
color: ColorValue;
|
|
2675
|
-
alpha: number;
|
|
2676
|
-
shadowOnly: boolean;
|
|
2677
2674
|
blur: number;
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2675
|
+
offsetX: number;
|
|
2676
|
+
offsetY: number;
|
|
2677
|
+
shadowOnly: boolean;
|
|
2678
|
+
blurEffect: GaussianBlurEffect;
|
|
2681
2679
|
viewport3: Viewport;
|
|
2682
2680
|
protected _color: Color;
|
|
2683
2681
|
constructor(properties?: Partial<DropShadowEffectProperties>, children?: Node[]);
|
|
@@ -2748,6 +2746,27 @@ declare class GodrayEffect extends Effect {
|
|
|
2748
2746
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2749
2747
|
}
|
|
2750
2748
|
|
|
2749
|
+
interface KawaseBlurEffectProperties extends EffectProperties {
|
|
2750
|
+
strength: number;
|
|
2751
|
+
quality: number;
|
|
2752
|
+
pixelSize: [number, number];
|
|
2753
|
+
clamp: boolean;
|
|
2754
|
+
}
|
|
2755
|
+
declare const frag = "varying vec2 vUv;\nuniform sampler2D sampler;\nuniform vec2 uOffset;\n\nvoid main(void) {\n vec4 color = vec4(0.0);\n color += texture2D(sampler, vec2(vUv.x - uOffset.x, vUv.y + uOffset.y));\n color += texture2D(sampler, vec2(vUv.x + uOffset.x, vUv.y + uOffset.y));\n color += texture2D(sampler, vec2(vUv.x + uOffset.x, vUv.y - uOffset.y));\n color += texture2D(sampler, vec2(vUv.x - uOffset.x, vUv.y - uOffset.y));\n color *= 0.25;\n gl_FragColor = color;\n}";
|
|
2756
|
+
declare const clampFrag = "precision highp float;\nvarying vec2 vUv;\nuniform sampler2D sampler;\nuniform vec2 uOffset;\nuniform vec4 uInputClamp;\nvoid main(void) {\n vec4 color = vec4(0.0);\n color += texture2D(sampler, clamp(vec2(vUv.x - uOffset.x, vUv.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));\n color += texture2D(sampler, clamp(vec2(vUv.x + uOffset.x, vUv.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));\n color += texture2D(sampler, clamp(vec2(vUv.x + uOffset.x, vUv.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));\n color += texture2D(sampler, clamp(vec2(vUv.x - uOffset.x, vUv.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));\n color *= 0.25;\n gl_FragColor = color;\n}";
|
|
2757
|
+
declare class KawaseBlurEffect extends Effect {
|
|
2758
|
+
material: Material;
|
|
2759
|
+
strength: number;
|
|
2760
|
+
quality: number;
|
|
2761
|
+
pixelSize: [number, number];
|
|
2762
|
+
protected _kernels: number[];
|
|
2763
|
+
constructor(properties?: Partial<KawaseBlurEffectProperties>, children?: Node[]);
|
|
2764
|
+
protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
2765
|
+
/** Auto generate kernels by blur & quality */
|
|
2766
|
+
protected _generateKernels(): void;
|
|
2767
|
+
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2751
2770
|
interface MaskEffectProperties extends EffectProperties {
|
|
2752
2771
|
src?: string;
|
|
2753
2772
|
}
|
|
@@ -2762,9 +2781,11 @@ declare class MaskEffect extends Effect {
|
|
|
2762
2781
|
}
|
|
2763
2782
|
|
|
2764
2783
|
interface OutlineEffectProperties extends EffectProperties {
|
|
2765
|
-
thickness: number;
|
|
2766
2784
|
color: ColorValue;
|
|
2767
|
-
|
|
2785
|
+
width: number;
|
|
2786
|
+
style: 'dashed' | 'solid' | string;
|
|
2787
|
+
image?: string;
|
|
2788
|
+
opacity: number;
|
|
2768
2789
|
quality: number;
|
|
2769
2790
|
knockout: boolean;
|
|
2770
2791
|
}
|
|
@@ -2773,9 +2794,11 @@ declare class OutlineEffect extends Effect {
|
|
|
2773
2794
|
static MIN_SAMPLES: number;
|
|
2774
2795
|
static MAX_SAMPLES: number;
|
|
2775
2796
|
static getAngleStep(quality: number): number;
|
|
2776
|
-
thickness: number;
|
|
2777
2797
|
color: ColorValue;
|
|
2778
|
-
|
|
2798
|
+
width: number;
|
|
2799
|
+
style: 'dashed' | 'solid' | string;
|
|
2800
|
+
image?: string;
|
|
2801
|
+
opacity: number;
|
|
2779
2802
|
quality: number;
|
|
2780
2803
|
knockout: boolean;
|
|
2781
2804
|
protected _color: Color;
|
|
@@ -2806,7 +2829,7 @@ declare class ZoomBlurEffect extends Effect {
|
|
|
2806
2829
|
radius: number;
|
|
2807
2830
|
strength: number;
|
|
2808
2831
|
constructor(properties?: Partial<ZoomBlurEffectProperties>, children?: Node[]);
|
|
2809
|
-
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2832
|
+
apply(renderer: WebGLRenderer, source: Viewport, context: EffectContext): void;
|
|
2810
2833
|
}
|
|
2811
2834
|
|
|
2812
2835
|
interface ControlEventMap extends CanvasItemEventMap, RectangulableEventMap {
|
|
@@ -3135,4 +3158,4 @@ interface RenderOptions {
|
|
|
3135
3158
|
}
|
|
3136
3159
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
3137
3160
|
|
|
3138
|
-
export { AnimatedTexture, Animation, type AnimationEffectMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, BaseElement2D, type BaseElement2DEventMap, type BaseElement2DProperties, BaseElement2DStyle, type BaseElement2DStyleProperties, type Batchable2D,
|
|
3161
|
+
export { AnimatedTexture, Animation, type AnimationEffectMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, BaseElement2D, type BaseElement2DEventMap, type BaseElement2DProperties, BaseElement2DStyle, type BaseElement2DStyleProperties, type Batchable2D, type CSSFilterKey, type CSSFilters, type CanvasBatchable, CanvasContext, CanvasItem, CanvasItemEditor, type CanvasItemEventMap, type CanvasItemProperties, CanvasTexture, Color, ColorAdjustEffect, type ColorAdjustEffectProperties, ColorFilterEffect, type ColorFilterEffectProperties, ColorMatrix, ColorOverlayEffect, type ColorOverlayEffectProperties, ColorRemoveEffect, type ColorRemoveEffectProperties, ColorReplaceEffect, type ColorReplaceEffectProperties, ColorTexture, type ColorValue, type ComputedLayout, Control, type ControlEventMap, type ControlProperties, CoreObject, type CoreObjectEventMap, type CssFunction, type CssFunctionArg, type Cursor, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, type DropShadowEffectProperties, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectProperties, Element2D, type Element2DEventMap, type Element2DProperties, Element2DStyle, type Element2DStyleProperties, EmbossEffect, type EmbossEffectProperties, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FillDraw, type FlexBaseElement2DEventMap, FlexElement2D, type FlexElement2DProperties, FlexElement2DStyle, type FlexElement2DStyleProperties, FlexLayout, FontLoader, GIFLoader, GaussianBlurEffect, type GaussianBlurEffectProperties, Geometry, type GeometryOptions, GlitchEffect, type GlitchEffectProperties, GodrayEffect, type GodrayEffectProperties, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DProperties, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InputEvent, type InputEventKey, type InputEventMap, type InternalMode, JSONLoader, KawaseBlurEffect, type KawaseBlurEffectProperties, KawaseTransition, type Keyframe, LeftEraseTransition, Loader, Lottie2D, type Lottie2DProperties, LottieLoader, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectProperties, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DProperties, type NodeEventMap, type NodeProperties, type NormalizedKeyframe, OutlineEffect, type OutlineEffectProperties, PI, PI_2, PixelateEffect, type PixelateEffectProperties, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, type ProcessMode, type ProcessSortMode, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, type RangeProperties, RawWeakMap, Rect2, type Rectangulable, type RectangulableEventMap, RefCounted, type RefCountedEventMap, type RenderMode, type RenderOptions, type Renderable, Renderer, Resource, type ResourceEventMap, Ruler, type RulerProperties, 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, type ScalerEventMap, type ScalerProperties, SceneTree, type SceneTreeEventMap, ScrollBar, type ScrollBarProperties, type StrokeDraw, Text2D, type Text2DProperties, TextLoader, Texture2D, type Texture2DFilterMode, type Texture2DPixelsSource, type Texture2DSource, type Texture2DWrapMode, TextureLoader, TextureRect2D, type TextureRect2DProperties, Ticker, TiltShiftTransition, Timeline, type TimelineEventMap, TimelineNode, type TimelineNodeEventMap, type TimelineNodeProperties, type TimelineProperties, type TimingFunctions, Transform2D, type Transform2DObject, TransformRect2D, type TransformRect2DProperties, Transition, type TransitionProperties, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DProperties, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportEventMap, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, XScrollBar, type XScrollBarProperties, YScrollBar, type YScrollBarProperties, ZoomBlurEffect, type ZoomBlurEffectProperties, assets, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|