etro 0.7.0 → 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/.github/workflows/nodejs.yml +1 -1
- package/CHANGELOG.md +45 -1
- package/CONTRIBUTING.md +23 -19
- package/README.md +81 -26
- package/dist/effect/base.d.ts +38 -0
- package/dist/effect/brightness.d.ts +16 -0
- package/dist/effect/channels.d.ts +23 -0
- package/dist/effect/chroma-key.d.ts +23 -0
- package/dist/effect/contrast.d.ts +15 -0
- package/dist/effect/elliptical-mask.d.ts +31 -0
- package/dist/effect/gaussian-blur.d.ts +60 -0
- package/dist/effect/grayscale.d.ts +7 -0
- package/dist/effect/index.d.ts +15 -0
- package/dist/effect/pixelate.d.ts +18 -0
- package/dist/effect/shader.d.ts +99 -0
- package/dist/effect/stack.d.ts +23 -0
- package/dist/effect/transform.d.ts +73 -0
- package/dist/etro-cjs.js +9337 -3331
- package/dist/etro-iife.js +9279 -3273
- package/dist/etro.d.ts +7 -0
- package/dist/event.d.ts +35 -0
- package/dist/index.d.ts +6 -0
- package/dist/layer/audio-source.d.ts +24 -0
- package/dist/layer/audio.d.ts +14 -0
- package/dist/layer/base.d.ts +69 -0
- package/dist/layer/image.d.ts +6 -0
- package/dist/layer/index.d.ts +11 -0
- package/dist/layer/text.d.ts +60 -0
- package/dist/layer/video.d.ts +11 -0
- package/dist/layer/visual-source.d.ts +32 -0
- package/dist/layer/visual.d.ts +58 -0
- package/dist/movie.d.ts +192 -0
- package/dist/object.d.ts +12 -0
- package/dist/util.d.ts +125 -0
- package/eslint.conf.js +0 -8
- package/eslint.example-conf.js +9 -0
- package/eslint.typescript-conf.js +5 -0
- package/examples/application/readme-screenshot.html +12 -9
- package/examples/application/video-player.html +7 -7
- package/examples/application/webcam.html +6 -6
- package/examples/introduction/audio.html +30 -18
- package/examples/introduction/effects.html +14 -10
- package/examples/introduction/export.html +32 -25
- package/examples/introduction/functions.html +6 -4
- package/examples/introduction/hello-world1.html +9 -5
- package/examples/introduction/hello-world2.html +5 -5
- package/examples/introduction/keyframes.html +35 -23
- package/examples/introduction/media.html +26 -18
- package/examples/introduction/text.html +9 -5
- package/karma.conf.js +1 -1
- package/package.json +29 -13
- package/rollup.config.js +15 -4
- package/scripts/gen-effect-samples.html +29 -25
- package/scripts/save-effect-samples.js +14 -15
- package/spec/assets/effect/gaussian-blur-horizontal.png +0 -0
- package/spec/assets/effect/gaussian-blur-vertical.png +0 -0
- package/spec/assets/effect/grayscale.png +0 -0
- package/spec/assets/effect/original.png +0 -0
- package/spec/assets/effect/pixelate.png +0 -0
- package/spec/assets/effect/transform/multiply.png +0 -0
- package/spec/assets/effect/transform/rotate.png +0 -0
- package/spec/assets/effect/transform/scale-fraction.png +0 -0
- package/spec/assets/effect/transform/scale.png +0 -0
- package/spec/assets/effect/transform/translate-fraction.png +0 -0
- package/spec/assets/effect/transform/translate.png +0 -0
- package/spec/effect.spec.js +126 -57
- package/spec/event.spec.js +14 -0
- package/spec/layer.spec.js +175 -18
- package/spec/movie.spec.js +191 -7
- package/spec/util.spec.js +14 -5
- package/src/effect/base.ts +96 -0
- package/src/effect/brightness.ts +43 -0
- package/src/effect/channels.ts +50 -0
- package/src/effect/chroma-key.ts +82 -0
- package/src/effect/contrast.ts +42 -0
- package/src/effect/elliptical-mask.ts +75 -0
- package/src/effect/gaussian-blur.ts +232 -0
- package/src/effect/grayscale.ts +34 -0
- package/src/effect/index.ts +22 -0
- package/src/effect/pixelate.ts +59 -0
- package/src/effect/shader.ts +561 -0
- package/src/effect/stack.ts +74 -0
- package/src/effect/transform.ts +194 -0
- package/src/etro.ts +26 -0
- package/src/event.ts +118 -0
- package/src/index.ts +8 -0
- package/src/layer/audio-source.ts +217 -0
- package/src/layer/audio.ts +35 -0
- package/src/layer/base.ts +156 -0
- package/src/layer/image.ts +8 -0
- package/src/layer/index.ts +13 -0
- package/src/layer/text.ts +138 -0
- package/src/layer/video.ts +15 -0
- package/src/layer/visual-source.ts +150 -0
- package/src/layer/visual.ts +198 -0
- package/src/movie.ts +709 -0
- package/src/object.ts +14 -0
- package/src/util.ts +473 -0
- package/tsconfig.json +8 -0
- package/screenshots/2019-08-17_0.png +0 -0
- package/src/effect.js +0 -1268
- package/src/event.js +0 -78
- package/src/index.js +0 -23
- package/src/layer.js +0 -897
- package/src/movie.js +0 -637
- package/src/util.js +0 -505
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.0] - 2021-04-11
|
|
4
|
+
### Added
|
|
5
|
+
- Type declarations.
|
|
6
|
+
- `duration` option for `Movie#record`, to only record a subsection of the movie.
|
|
7
|
+
- `'movie.recordended'` event. This does not affect the behavior of `'movie.ended'`.
|
|
8
|
+
- Grayscale effect.
|
|
9
|
+
- `etro.event.unsubscribe` to remove event listeners.
|
|
10
|
+
- Image and video layers' `destX`, `destY`, `destWidth` and `destHeight`.
|
|
11
|
+
- Previously `imageX`, `imageY`, `imageWidth`, `imageHeight`, ...
|
|
12
|
+
- Allows for rotating these layers without cropping out parts.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- All constructor arguments are now supplied through an `options` object.
|
|
16
|
+
- Now `Movie#record` also accepts its arguments through an `options` object.
|
|
17
|
+
- Keyframes are now entered as `new etro.KeyFrame([time1, val1, interp],
|
|
18
|
+
[time2, val2])`
|
|
19
|
+
- Rename `clip*` to `source*` for image layers.
|
|
20
|
+
- `clipX` is now `sourceX`, etc.
|
|
21
|
+
- Rename `image` to `source` for image layers.
|
|
22
|
+
- Rename `source` to `audioNode` and `media` to `source` for audio and video layers.
|
|
23
|
+
- And `mediaStartTime` to `sourceStartTime`
|
|
24
|
+
- For image and video layers, `width` now defaults to `destWidth`, which defaults to `sourceWidth`, which defaults to the width of the image or video.
|
|
25
|
+
- The `movie.audiodestinationupdate` event is now published on the movie instead of each layer.
|
|
26
|
+
- The movie's `audioContext` option is now `actx` (to match the property).
|
|
27
|
+
|
|
28
|
+
### Deprecated
|
|
29
|
+
- `etro.mapPixels` - use `etro.effect.Shader` instead, because it supports
|
|
30
|
+
hardware-acceleration
|
|
31
|
+
- `audioContext` option for `Movie` - use `actx` instead.
|
|
32
|
+
|
|
33
|
+
### Removed
|
|
34
|
+
- Video files for examples (can now be downloaded with `npm run assets`).
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- Browsers that do not implement `AudioContext` are now supported.
|
|
38
|
+
- Movie not rendering with no layers.
|
|
39
|
+
- Issues with modifying `Movie#layers` and `Movie#effects`.
|
|
40
|
+
- Layers no longer error on 'movie.seek' event.
|
|
41
|
+
- Property filters' `this` is now set to the owner of the property.
|
|
42
|
+
- Visual layers' `width` and `height` property filters now default to the movie's width and height.
|
|
43
|
+
- Visual layers' `border` property not being processed correctly.
|
|
44
|
+
- Effects' and layers' `attach()` and `detach()` methods not being called when replaced by another effect or layer.
|
|
45
|
+
|
|
3
46
|
## [0.7.0] - 2020-12-17
|
|
4
47
|
### Added
|
|
5
48
|
- Importing with CommonJS syntax.
|
|
@@ -128,7 +171,8 @@
|
|
|
128
171
|
- Gaussian blur
|
|
129
172
|
- Transform
|
|
130
173
|
|
|
131
|
-
[Unreleased]: https://github.com/etro-js/etro/compare/v0.
|
|
174
|
+
[Unreleased]: https://github.com/etro-js/etro/compare/v0.8...HEAD
|
|
175
|
+
[0.8.0]: https://github.com/etro-js/etro/compare/v0.7...v0.8
|
|
132
176
|
[0.7.0]: https://github.com/etro-js/etro/compare/v0.6...v0.7
|
|
133
177
|
[0.6.0]: https://github.com/etro-js/etro/compare/v0.5...v0.6
|
|
134
178
|
[0.5.0]: https://github.com/etro-js/etro/compare/v0.4...v0.5
|
package/CONTRIBUTING.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Thank you for considering contributing to Etro! There are many ways you can contribute to Etro, like creating issues for features or bugs, improving the docs or wiki, or writing the actual code for the library. This page covers how to make changes to the repository files (either code or docs).
|
|
6
6
|
|
|
7
|
-
> Etro has a [Taiga Project](https://tree.taiga.io/project/etro-js-etro/epics) for managing issues and a [
|
|
7
|
+
> Etro has a [Taiga Project](https://tree.taiga.io/project/etro-js-etro/epics) for managing issues and a [GitHub Discussion page](https://github.com/etro-js/etro/discussions) for questions, ideas and casual discussion
|
|
8
8
|
|
|
9
9
|
## Setting up your local environment
|
|
10
10
|
|
|
@@ -17,11 +17,9 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
17
17
|
- Create your own fork of Etro. Then run
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
$ git fetch upstream
|
|
24
|
-
$ npm install
|
|
20
|
+
git clone -b master --single-branch https://github.com/username/etro.git
|
|
21
|
+
cd etro
|
|
22
|
+
npm install
|
|
25
23
|
```
|
|
26
24
|
|
|
27
25
|
#### Step 2: Branch
|
|
@@ -29,7 +27,7 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
29
27
|
- To help organize your work, create a branch for your topic. Avoid working directly off the `master` branch
|
|
30
28
|
|
|
31
29
|
```
|
|
32
|
-
|
|
30
|
+
git checkout -b topic-branch
|
|
33
31
|
```
|
|
34
32
|
|
|
35
33
|
## Making your changes
|
|
@@ -38,20 +36,26 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
38
36
|
|
|
39
37
|
- If you are writing code, please follow the style guide [StandardJS](https://standardjs.com/rules.html)
|
|
40
38
|
|
|
41
|
-
- To
|
|
39
|
+
- To download the example assets run
|
|
42
40
|
|
|
43
41
|
```
|
|
44
|
-
|
|
42
|
+
npm run assets
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
- Then, start the development server with
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
npm start
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Now you can see your changes by running some [examples](examples).
|
|
48
52
|
|
|
49
53
|
- When you're ready to submit a piece of work, first run
|
|
50
54
|
|
|
51
55
|
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
npm run lint
|
|
57
|
+
npm run build
|
|
58
|
+
npm test
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
to lint the code, generate the [dist](dist) files and run unit tests on them. It may be helpful to put these commands in a pre-commit hook.
|
|
@@ -78,14 +82,14 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
78
82
|
- First, rebase (don't merge) to integrate your work with the main repository
|
|
79
83
|
|
|
80
84
|
```
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
git fetch upstream
|
|
86
|
+
git rebase upstream/master
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
- Push your changes to the topic branch in your fork of the repository
|
|
86
90
|
|
|
87
91
|
```
|
|
88
|
-
|
|
92
|
+
git push origin topic-branch
|
|
89
93
|
```
|
|
90
94
|
|
|
91
95
|
#### Step 4: Pull request
|
|
@@ -99,9 +103,9 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
99
103
|
- A large part of the submission process is receiving feedback on how you can improve you pull request. If you need change your pull request,
|
|
100
104
|
|
|
101
105
|
```
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
git add path/to/changes
|
|
107
|
+
git commit
|
|
108
|
+
git push origin topic-branch
|
|
105
109
|
```
|
|
106
110
|
|
|
107
111
|
## Code overview
|
package/README.md
CHANGED
|
@@ -3,25 +3,30 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/etro)
|
|
4
4
|
[](https://actions-badge.atrox.dev/etro-js/etro/goto)
|
|
5
5
|
|
|
6
|
-
>
|
|
6
|
+
> [Version 0.8 is out](https://etrojs.dev/blog/introducing-v0-8-0)!
|
|
7
|
+
> Check out [this guide](https://etrojs.dev/docs/migrating-v0-8-0)
|
|
8
|
+
> for migrating.
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
Etro is a JavaScript framework for programmatically editing videos. Similar
|
|
11
|
+
to GUI-based video-editing software, it lets you layer media and other
|
|
12
|
+
content on a timeline. Audio, image, video and other tracks are supported,
|
|
13
|
+
along with powerful video effectts for existing tracks. Being very flexible
|
|
14
|
+
and extendable, you can choose to only use the core components or define your
|
|
15
|
+
own.
|
|
11
16
|
|
|
12
17
|
## Features
|
|
13
18
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- Write
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
19
|
+
- Composite video and audio layers
|
|
20
|
+
- Use built-in hardware accelerated effects
|
|
21
|
+
- Write your own effects in JavaScript and GLSL
|
|
22
|
+
- Manipulate audio with the web audio API
|
|
23
|
+
- Define layer and effect properties as keyframes and functions
|
|
24
|
+
- Export to a blob or file
|
|
20
25
|
|
|
21
26
|
## Installation
|
|
22
27
|
|
|
23
28
|
```
|
|
24
|
-
npm
|
|
29
|
+
npm i etro
|
|
25
30
|
```
|
|
26
31
|
|
|
27
32
|
## Usage
|
|
@@ -31,34 +36,83 @@ You can use CommonJS syntax:
|
|
|
31
36
|
import etro from 'etro'
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
Or include it as a global
|
|
35
|
-
```
|
|
39
|
+
Or include it as a global etro:
|
|
40
|
+
```js
|
|
36
41
|
<script src="node_modules/etro/dist/etro-iife.js"></script>
|
|
37
42
|
```
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
Let's look at an example:
|
|
40
45
|
```js
|
|
41
|
-
var movie = new etro.Movie(canvas)
|
|
46
|
+
var movie = new etro.Movie({ canvas: outputCanvas })
|
|
47
|
+
var layer = new etro.layer.Video({ startTime: 0, source: videoElement }) // the layer starts at 0s
|
|
48
|
+
movie.addLayer(layer)
|
|
49
|
+
movie.record({ frameRate: 24 }) // or just `play` if you don't need to save it
|
|
50
|
+
.then(blob => ...)
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
This renders `videoElement` to a blob at 24 fps. This blob can then be
|
|
54
|
+
downloaded as a video file.
|
|
55
|
+
|
|
56
|
+
Effects can transform the output of a layer or movie:
|
|
45
57
|
```js
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
var layer = new etro.layer.Video({ startTime: 0, source: videoElement })
|
|
59
|
+
.addEffect(new etro.effect.Brightness({ brightness: +100) }))
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Using in Node
|
|
63
|
+
|
|
64
|
+
To use Etro in Node, use the [wrapper](https://github.com/etro-js/etro-node):
|
|
65
|
+
```
|
|
66
|
+
npm i etro-node
|
|
51
67
|
```
|
|
52
68
|
|
|
53
|
-
Finally, start the movie
|
|
54
69
|
```js
|
|
55
|
-
|
|
70
|
+
var etroNode = require('etro-node')
|
|
71
|
+
|
|
72
|
+
etroNode(() => {
|
|
73
|
+
// You can access inputs as html elements and pass them to Etro as usual.
|
|
74
|
+
var image = document.getElementById('input1') // <img> element
|
|
75
|
+
|
|
76
|
+
// Use etro normally ...
|
|
77
|
+
|
|
78
|
+
movie
|
|
79
|
+
.exportRaw()
|
|
80
|
+
.then(window.done)
|
|
81
|
+
// Tell Etro Node what inputs to load with { id: path }
|
|
82
|
+
}, { input1: 'image.png' }, 'output.mp4')
|
|
56
83
|
```
|
|
57
84
|
|
|
85
|
+
`etroNode()` takes an optional Puppeteer page argument, so you can run
|
|
86
|
+
multiple Etro scripts on the same movie (useful for servers). See [the
|
|
87
|
+
docs](https://github.com/etro-js/etro-node#documentation).
|
|
88
|
+
|
|
89
|
+
## Running the Examples
|
|
90
|
+
|
|
91
|
+
First, download the assets for the examples:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
npm run assets
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Then, start the development server (only used for convience while developing;
|
|
98
|
+
you don't need a server to use Etro):
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
npm start
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Now you can open any example (such as
|
|
105
|
+
http://127.0.0.1:8080/examples/introduction/hello-world1.html).
|
|
106
|
+
|
|
107
|
+
## TypeScript
|
|
108
|
+
|
|
109
|
+
Etro is written in TypeScript, so it should work out of the box with TypeScript
|
|
110
|
+
projects. However, it is also compatible with projects that do not use
|
|
111
|
+
TypeScript.
|
|
112
|
+
|
|
58
113
|
## Further Reading
|
|
59
114
|
|
|
60
|
-
- [Documentation](https://etrojs.dev)
|
|
61
|
-
- [Wiki (WIP)](https://github.com/etro-js/etro/wiki)
|
|
115
|
+
- [Documentation](https://etrojs.dev/docs)
|
|
62
116
|
|
|
63
117
|
## Contributing
|
|
64
118
|
|
|
@@ -66,4 +120,5 @@ See the [contributing guide](CONTRIBUTING.md)
|
|
|
66
120
|
|
|
67
121
|
## License
|
|
68
122
|
|
|
69
|
-
Distributed under GNU General Public License v3. See `LICENSE` for more
|
|
123
|
+
Distributed under GNU General Public License v3. See `LICENSE` for more
|
|
124
|
+
information.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Movie } from '../movie';
|
|
2
|
+
import { Visual } from '../layer/index';
|
|
3
|
+
import BaseObject from '../object';
|
|
4
|
+
/**
|
|
5
|
+
* Modifies the visual contents of a layer.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Base implements BaseObject {
|
|
8
|
+
type: string;
|
|
9
|
+
publicExcludes: string[];
|
|
10
|
+
propertyFilters: Record<string, <T>(value: T) => T>;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
private _target;
|
|
13
|
+
/**
|
|
14
|
+
* The number of times this effect has been attached to a target minus the
|
|
15
|
+
* number of times it's been detached. (Used for the target's array proxy with
|
|
16
|
+
* `unshift`)
|
|
17
|
+
*/
|
|
18
|
+
private _occurrenceCount;
|
|
19
|
+
constructor();
|
|
20
|
+
attach(target: Movie | Visual): void;
|
|
21
|
+
detach(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Apply this effect to a target at the given time
|
|
24
|
+
*
|
|
25
|
+
* @param target
|
|
26
|
+
* @param reltime - the movie's current time relative to the layer
|
|
27
|
+
* (will soon be replaced with an instance getter)
|
|
28
|
+
* @abstract
|
|
29
|
+
*/
|
|
30
|
+
apply(target: Movie | Visual, reltime: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* The current time of the target
|
|
33
|
+
*/
|
|
34
|
+
get currentTime(): number;
|
|
35
|
+
get parent(): Movie | Visual;
|
|
36
|
+
get movie(): Movie;
|
|
37
|
+
getDefaultOptions(): Record<string, unknown>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Dynamic } from '../util';
|
|
2
|
+
import { Shader } from './shader';
|
|
3
|
+
export interface BrightnessOptions {
|
|
4
|
+
brightness?: Dynamic<number>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Changes the brightness
|
|
8
|
+
*/
|
|
9
|
+
export declare class Brightness extends Shader {
|
|
10
|
+
brightness: Dynamic<number>;
|
|
11
|
+
/**
|
|
12
|
+
* @param [brightness=0] - the value to add to each pixel's color
|
|
13
|
+
* channels (between -255 and 255)
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: BrightnessOptions);
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Dynamic } from '../util';
|
|
2
|
+
import { Shader } from './shader';
|
|
3
|
+
export interface ChannelsOptions {
|
|
4
|
+
factors?: Dynamic<{
|
|
5
|
+
r?: number;
|
|
6
|
+
g?: number;
|
|
7
|
+
b?: number;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Multiplies each channel by a different factor
|
|
12
|
+
*/
|
|
13
|
+
export declare class Channels extends Shader {
|
|
14
|
+
factors: Dynamic<{
|
|
15
|
+
r?: number;
|
|
16
|
+
b?: number;
|
|
17
|
+
g?: number;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* @param factors - channel factors, each defaulting to 1
|
|
21
|
+
*/
|
|
22
|
+
constructor(options?: ChannelsOptions);
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Dynamic, Color } from '../util';
|
|
2
|
+
import { Shader } from './shader';
|
|
3
|
+
export interface ChromaKeyOptions {
|
|
4
|
+
target?: Dynamic<Color>;
|
|
5
|
+
threshold?: Dynamic<number>;
|
|
6
|
+
interpolate?: Dynamic<boolean>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reduces alpha for pixels which are close to a specified target color
|
|
10
|
+
*/
|
|
11
|
+
export declare class ChromaKey extends Shader {
|
|
12
|
+
target: Dynamic<Color>;
|
|
13
|
+
threshold: Dynamic<number>;
|
|
14
|
+
interpolate: Dynamic<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* @param [target={r: 0, g: 0, b: 0, a: 1}] - the color to remove
|
|
17
|
+
* @param [threshold=0] - how much error to allow
|
|
18
|
+
* @param [interpolate=false] - <code>true</code> to interpolate
|
|
19
|
+
* the alpha channel, or <code>false</code> value for no smoothing (i.e. an
|
|
20
|
+
* alpha of either 0 or 255)
|
|
21
|
+
*/
|
|
22
|
+
constructor(options?: ChromaKeyOptions);
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dynamic } from '../util';
|
|
2
|
+
import { Shader } from './shader';
|
|
3
|
+
export interface ContrastOptions {
|
|
4
|
+
contrast?: Dynamic<number>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Changes the contrast by multiplying the RGB channels by a constant
|
|
8
|
+
*/
|
|
9
|
+
export declare class Contrast extends Shader {
|
|
10
|
+
contrast: Dynamic<number>;
|
|
11
|
+
/**
|
|
12
|
+
* @param [contrast=1] - the contrast multiplier
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: ContrastOptions);
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Movie } from '../movie';
|
|
2
|
+
import { Dynamic } from '../util';
|
|
3
|
+
import { Base } from './base';
|
|
4
|
+
import { Visual } from '../layer/index';
|
|
5
|
+
export declare class EllipticalMaskOptions {
|
|
6
|
+
x: Dynamic<number>;
|
|
7
|
+
y: Dynamic<number>;
|
|
8
|
+
radiusX: Dynamic<number>;
|
|
9
|
+
radiusY: Dynamic<number>;
|
|
10
|
+
rotation?: Dynamic<number>;
|
|
11
|
+
startAngle?: Dynamic<number>;
|
|
12
|
+
endAngle?: Dynamic<number>;
|
|
13
|
+
anticlockwise?: Dynamic<boolean>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Preserves an ellipse of the layer and clears the rest
|
|
17
|
+
*/
|
|
18
|
+
export declare class EllipticalMask extends Base {
|
|
19
|
+
x: Dynamic<number>;
|
|
20
|
+
y: Dynamic<number>;
|
|
21
|
+
radiusX: Dynamic<number>;
|
|
22
|
+
radiusY: Dynamic<number>;
|
|
23
|
+
rotation: Dynamic<number>;
|
|
24
|
+
startAngle: Dynamic<number>;
|
|
25
|
+
endAngle: Dynamic<number>;
|
|
26
|
+
anticlockwise: Dynamic<boolean>;
|
|
27
|
+
private _tmpCanvas;
|
|
28
|
+
private _tmpCtx;
|
|
29
|
+
constructor(options: EllipticalMaskOptions);
|
|
30
|
+
apply(target: Movie | Visual, reltime: number): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Stack } from './stack';
|
|
2
|
+
import { Shader } from './shader';
|
|
3
|
+
import { Movie } from '../movie';
|
|
4
|
+
import { Visual } from '../layer';
|
|
5
|
+
export interface GaussianBlurOptions {
|
|
6
|
+
radius: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Applies a Gaussian blur
|
|
10
|
+
*/
|
|
11
|
+
export declare class GaussianBlur extends Stack {
|
|
12
|
+
constructor(options: GaussianBlurOptions);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Shared class for both horizontal and vertical gaussian blur classes.
|
|
16
|
+
*/
|
|
17
|
+
declare class GaussianBlurComponent extends Shader {
|
|
18
|
+
radius: number;
|
|
19
|
+
shape: HTMLCanvasElement;
|
|
20
|
+
private _radiusCache;
|
|
21
|
+
/**
|
|
22
|
+
* @param src - fragment source code (specific to which component -
|
|
23
|
+
* horizontal or vertical)
|
|
24
|
+
* @param radius - only integers are currently supported
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: {
|
|
27
|
+
fragmentSource: string;
|
|
28
|
+
radius: number;
|
|
29
|
+
});
|
|
30
|
+
apply(target: Movie | Visual, reltime: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Render Gaussian kernel to a canvas for use in shader.
|
|
33
|
+
* @param kernel
|
|
34
|
+
* @private
|
|
35
|
+
*
|
|
36
|
+
* @return
|
|
37
|
+
*/
|
|
38
|
+
private static _render1DKernel;
|
|
39
|
+
private static _gen1DKernel;
|
|
40
|
+
private static _genPascalRow;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Horizontal component of gaussian blur
|
|
44
|
+
*/
|
|
45
|
+
export declare class GaussianBlurHorizontal extends GaussianBlurComponent {
|
|
46
|
+
/**
|
|
47
|
+
* @param radius
|
|
48
|
+
*/
|
|
49
|
+
constructor(options: GaussianBlurOptions);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Vertical component of gaussian blur
|
|
53
|
+
*/
|
|
54
|
+
export declare class GaussianBlurVertical extends GaussianBlurComponent {
|
|
55
|
+
/**
|
|
56
|
+
* @param radius
|
|
57
|
+
*/
|
|
58
|
+
constructor(options: GaussianBlurOptions);
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module effect
|
|
3
|
+
*/
|
|
4
|
+
export * from './base';
|
|
5
|
+
export * from './brightness';
|
|
6
|
+
export * from './channels';
|
|
7
|
+
export * from './chroma-key';
|
|
8
|
+
export * from './contrast';
|
|
9
|
+
export * from './elliptical-mask';
|
|
10
|
+
export * from './gaussian-blur';
|
|
11
|
+
export * from './grayscale';
|
|
12
|
+
export * from './pixelate';
|
|
13
|
+
export * from './shader';
|
|
14
|
+
export * from './stack';
|
|
15
|
+
export * from './transform';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Visual } from '../layer';
|
|
2
|
+
import { Movie } from '../movie';
|
|
3
|
+
import { Dynamic } from '../util';
|
|
4
|
+
import { Shader } from './shader';
|
|
5
|
+
export interface PixelateOptions {
|
|
6
|
+
pixelSize?: Dynamic<number>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Breaks the target up into squares of `pixelSize` by `pixelSize`
|
|
10
|
+
*/
|
|
11
|
+
export declare class Pixelate extends Shader {
|
|
12
|
+
pixelSize: Dynamic<number>;
|
|
13
|
+
/**
|
|
14
|
+
* @param pixelSize
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: PixelateOptions);
|
|
17
|
+
apply(target: Movie | Visual, reltime: number): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Visual } from '../layer/index';
|
|
2
|
+
import { Movie } from '../movie';
|
|
3
|
+
import { Base } from './base';
|
|
4
|
+
export interface UniformOptions {
|
|
5
|
+
type?: string;
|
|
6
|
+
defaultFloatComponent?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TextureOptions {
|
|
9
|
+
createUniform?: boolean;
|
|
10
|
+
target?: any;
|
|
11
|
+
level?: number;
|
|
12
|
+
internalFormat?: any;
|
|
13
|
+
srcFormat?: any;
|
|
14
|
+
srcType?: any;
|
|
15
|
+
wrapS?: any;
|
|
16
|
+
wrapT?: any;
|
|
17
|
+
minFilter?: any;
|
|
18
|
+
magFilter?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface ShaderOptions {
|
|
21
|
+
fragmentSource?: string;
|
|
22
|
+
uniforms?: Record<string, (UniformOptions | string)>;
|
|
23
|
+
textures?: Record<string, TextureOptions>;
|
|
24
|
+
sourceTextureOptions?: TextureOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A hardware-accelerated pixel mapping using WebGL
|
|
28
|
+
*/
|
|
29
|
+
export declare class Shader extends Base {
|
|
30
|
+
/**
|
|
31
|
+
* WebGL texture units consumed by {@link Shader}
|
|
32
|
+
*/
|
|
33
|
+
static INTERNAL_TEXTURE_UNITS: number;
|
|
34
|
+
private static _DEFAULT_TEXTURE_OPTIONS;
|
|
35
|
+
private static _VERTEX_SOURCE;
|
|
36
|
+
private static _IDENTITY_FRAGMENT_SOURCE;
|
|
37
|
+
private _program;
|
|
38
|
+
private _buffers;
|
|
39
|
+
private _canvas;
|
|
40
|
+
private _gl;
|
|
41
|
+
private _uniformLocations;
|
|
42
|
+
private _attribLocations;
|
|
43
|
+
private _userUniforms;
|
|
44
|
+
private _userTextures;
|
|
45
|
+
private _sourceTextureOptions;
|
|
46
|
+
private _inputTexture;
|
|
47
|
+
/**
|
|
48
|
+
* @param fragmentSrc
|
|
49
|
+
* @param [userUniforms={}] - object mapping uniform id to an
|
|
50
|
+
* options object or a string (if you only need to provide the uniforms'
|
|
51
|
+
* type)
|
|
52
|
+
* @param [userTextures=[]]
|
|
53
|
+
* @param [sourceTextureOptions={}]
|
|
54
|
+
*/
|
|
55
|
+
constructor(options?: ShaderOptions);
|
|
56
|
+
private _initGl;
|
|
57
|
+
private _initTextures;
|
|
58
|
+
private _initAttribs;
|
|
59
|
+
private _initUniforms;
|
|
60
|
+
apply(target: Movie | Visual, reltime: number): void;
|
|
61
|
+
private _checkDimensions;
|
|
62
|
+
private _refreshGl;
|
|
63
|
+
private _enablePositionAttrib;
|
|
64
|
+
private _enableTexCoordAttrib;
|
|
65
|
+
private _prepareTextures;
|
|
66
|
+
private _prepareUniforms;
|
|
67
|
+
private _draw;
|
|
68
|
+
/**
|
|
69
|
+
* Converts a value of a standard type for javascript to a standard type for
|
|
70
|
+
* GLSL
|
|
71
|
+
* @param value - the raw value to prepare
|
|
72
|
+
* @param outputType - the WebGL type of |value|; example:
|
|
73
|
+
* <code>1f</code> for a float
|
|
74
|
+
* @param reltime - current time, relative to the target
|
|
75
|
+
* @param [options] - Optional config
|
|
76
|
+
*/
|
|
77
|
+
private _prepareValue;
|
|
78
|
+
private static _initRectBuffers;
|
|
79
|
+
/**
|
|
80
|
+
* Creates the quad covering the screen
|
|
81
|
+
*/
|
|
82
|
+
private static _initBuffer;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a webgl texture from the source.
|
|
85
|
+
* @param [options] - optional WebGL config for texture
|
|
86
|
+
* @param [options.target=gl.TEXTURE_2D]
|
|
87
|
+
* @param [options.level=0]
|
|
88
|
+
* @param [options.internalFormat=gl.RGBA]
|
|
89
|
+
* @param [options.srcFormat=gl.RGBA]
|
|
90
|
+
* @param [options.srcType=gl.UNSIGNED_BYTE]
|
|
91
|
+
* @param [options.wrapS=gl.CLAMP_TO_EDGE]
|
|
92
|
+
* @param [options.wrapT=gl.CLAMP_TO_EDGE]
|
|
93
|
+
* @param [options.minFilter=gl.LINEAR]
|
|
94
|
+
* @param [options.magFilter=gl.LINEAR]
|
|
95
|
+
*/
|
|
96
|
+
private static _loadTexture;
|
|
97
|
+
private static _initShaderProgram;
|
|
98
|
+
private static _loadShader;
|
|
99
|
+
}
|