modern-canvas 0.14.2 → 0.14.4

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 CHANGED
@@ -39,7 +39,7 @@ npm i modern-canvas
39
39
  ## 🦄 Usage
40
40
 
41
41
  ```javascript
42
- import { Animation, Element2D, Engine, Image2D, Video2D } from 'modern-canvas'
42
+ import { Animation, Element2D, Engine } from 'modern-canvas'
43
43
  import { fonts } from 'modern-font'
44
44
 
45
45
  async function loadFallbackFont() {
@@ -50,7 +50,7 @@ loadFallbackFont().then(() => {
50
50
  const engine = new Engine({ width: 500, height: 500 }).start()
51
51
 
52
52
  engine.root.appendChild(
53
- new Image2D({
53
+ new Element2D({
54
54
  style: {
55
55
  left: 100,
56
56
  top: 100,
@@ -61,7 +61,7 @@ loadFallbackFont().then(() => {
61
61
  backgroundColor: '#00FF00',
62
62
  filter: 'brightness(102%) contrast(90%) saturate(128%) sepia(18%)',
63
63
  },
64
- src: '/example.png',
64
+ foreground: { image: '/example.png' },
65
65
  }, [
66
66
  new Animation({
67
67
  duration: 3000,
@@ -79,16 +79,6 @@ loadFallbackFont().then(() => {
79
79
  content: '/example.png',
80
80
  },
81
81
  }),
82
- new Video2D({
83
- style: {
84
- left: 200,
85
- top: 200,
86
- width: 100,
87
- height: 100,
88
- maskImage: '/example.png',
89
- },
90
- src: '/example.mp4',
91
- }),
92
82
  ])
93
83
  )
94
84
 
@@ -103,11 +93,11 @@ loadFallbackFont().then(() => {
103
93
  See all [preset special effects](./src/scene/effects)
104
94
 
105
95
  ```typescript
106
- import { EmbossEffect, Image2D } from 'modern-canvas'
96
+ import { EmbossEffect, Element2D } from 'modern-canvas'
107
97
 
108
98
  engine.root.appendChild(
109
- new Image2D({
110
- src: '/example.png',
99
+ new Element2D({
100
+ foreground: { image: '/example.png' },
111
101
  }, [
112
102
  new EmbossEffect(),
113
103
  ])
@@ -119,15 +109,15 @@ engine.root.appendChild(
119
109
  See all [preset transitions](./src/scene/transitions)
120
110
 
121
111
  ```typescript
122
- import { Image2D, TiltShiftTransition } from 'modern-canvas'
112
+ import { Element2D, TiltShiftTransition } from 'modern-canvas'
123
113
 
124
114
  engine.root.appendChild(
125
- new Image2D({
126
- src: '/example.png',
115
+ new Element2D({
116
+ foreground: { image: '/example.png' },
127
117
  }),
128
118
  new TiltShiftTransition(),
129
- new Image2D({
130
- src: '/example.gif',
119
+ new Element2D({
120
+ foreground: { image: '/example.gif' },
131
121
  }),
132
122
  )
133
123
  ```
@@ -136,15 +126,15 @@ Use https://github.com/gl-transitions/gl-transitions with `vite`
136
126
 
137
127
  ```ts
138
128
  import bounceGLSL from 'gl-transitions/transitions/Bounce.glsl?raw'
139
- import { Image2D, Transition } from 'modern-canvas'
129
+ import { Element2D, Transition } from 'modern-canvas'
140
130
 
141
131
  engine.root.appendChild(
142
- new Image2D({
143
- src: '/example.png',
132
+ new Element2D({
133
+ foreground: { image: '/example.png' },
144
134
  }),
145
135
  new Transition({ glsl: bounceGLSL }),
146
- new Image2D({
147
- src: '/example.gif',
136
+ new Element2D({
137
+ foreground: { image: '/example.gif' },
148
138
  }),
149
139
  )
150
140
  ```
@@ -1,7 +1,8 @@
1
+ import type { RectangleLike } from '../../math';
1
2
  import type { GlRenderer } from './GlRenderer';
2
3
  import type { GlRenderable } from './types';
3
4
  import { GlSystem } from './system';
4
- export type MaskLike = GlRenderable;
5
+ export type MaskLike = GlRenderable | RectangleLike;
5
6
  export interface MaskStackItem {
6
7
  source: GlRenderable;
7
8
  mask: MaskLike;
@@ -6,6 +6,7 @@ import { GlGeometrySystem } from './geometry';
6
6
  import { GlBatch2DSystem } from './GlBatch2DSystem';
7
7
  import { GlColorMaskSystem } from './GlColorMaskSystem';
8
8
  import { GlMaskSystem } from './GlMaskSystem';
9
+ import { GlScissorSystem } from './GlScissorSystem';
9
10
  import { GlStencilSystem } from './GlStencilSystem';
10
11
  import { GlViewportSystem } from './GlViewportSystem';
11
12
  import { GlRenderTargetSystem } from './renderTarget';
@@ -22,6 +23,7 @@ export interface GlRenderer {
22
23
  mask: GlMaskSystem;
23
24
  colorMask: GlColorMaskSystem;
24
25
  stencil: GlStencilSystem;
26
+ scissor: GlScissorSystem;
25
27
  batch2D: GlBatch2DSystem;
26
28
  viewport: GlViewportSystem;
27
29
  }
@@ -30,7 +32,7 @@ export declare class GlRenderer extends Renderer {
30
32
  gl: GlRenderingContext;
31
33
  version: 1 | 2;
32
34
  extensions: GlExtensions;
33
- protected _systems: (GlShaderSystem | GlTextureSystem | GlGeometrySystem | GlBufferSystem | GlStateSystem | GlBatch2DSystem | GlColorMaskSystem | GlMaskSystem | GlRenderTargetSystem | GlStencilSystem | GlViewportSystem)[];
35
+ protected _systems: (GlShaderSystem | GlTextureSystem | GlGeometrySystem | GlBufferSystem | GlStateSystem | GlBatch2DSystem | GlColorMaskSystem | GlMaskSystem | GlRenderTargetSystem | GlScissorSystem | GlStencilSystem | GlViewportSystem)[];
34
36
  readonly bindPoints: Map<number, GlTarget>;
35
37
  readonly supports: {
36
38
  uint32Indices: boolean;
@@ -0,0 +1,15 @@
1
+ import type { RectangleLike } from '../../math';
2
+ import type { RenderTargetLike } from '../shared';
3
+ import type { GlRenderer } from './GlRenderer';
4
+ import { GlSystem } from './system';
5
+ export declare class GlScissorSystem extends GlSystem {
6
+ install(renderer: GlRenderer): void;
7
+ current: Record<number, {
8
+ refCount: number;
9
+ rect?: RectangleLike;
10
+ }>;
11
+ onRenderTargetChange(renderTarget: RenderTargetLike | null): void;
12
+ push(rect: RectangleLike): void;
13
+ pop(): void;
14
+ bind(rect?: RectangleLike | null): void;
15
+ }
@@ -50,7 +50,6 @@ export declare class GlStencilSystem extends GlSystem {
50
50
  };
51
51
  onUpdateContext(gl: GlRenderingContext): void;
52
52
  reset(): void;
53
- protected _activeRenderTarget: RenderTargetLike | null;
54
53
  onRenderTargetChange(renderTarget: RenderTargetLike | null): void;
55
54
  bind(stencilMode: StencilMode, refCount: number): void;
56
55
  }