Browse Source

Make it easier to disable zoom direciton #31

pull/44/head
Mikael Finstad 6 years ago
parent
commit
cc099766a9
  1. 2
      README.md
  2. 1
      examples/kenBurns.json5
  3. 5
      sources/fabricFrameSource.js

2
README.md

@ -181,7 +181,7 @@ For video layers, if parent `clip.duration` is specified, the video will be slow
| Parameter | Description | Default | | | Parameter | Description | Default | |
|-|-|-|-| |-|-|-|-|
| `path` | Path to image file | | | | `path` | Path to image file | | |
| `zoomDirection` | Zoom direction for Ken Burns effect: `in` or `out` | `in` | |
| `zoomDirection` | Zoom direction for Ken Burns effect: `in`, `out` or `null` to disable | `in` | |
| `zoomAmount` | Zoom amount for Ken Burns effect | `0.1` | | | `zoomAmount` | Zoom amount for Ken Burns effect | `0.1` | |
#### Layer type 'title' #### Layer type 'title'

1
examples/kenBurns.json5

@ -6,5 +6,6 @@
clips: [ clips: [
{ duration: 3, layers: [{ type: 'image', path: './assets/img2.jpg', zoomDirection: 'out' }] }, { duration: 3, layers: [{ type: 'image', path: './assets/img2.jpg', zoomDirection: 'out' }] },
{ duration: 3, layers: [{ type: 'image', path: './assets/img3.jpg', zoomDirection: 'in' }] }, { duration: 3, layers: [{ type: 'image', path: './assets/img3.jpg', zoomDirection: 'in' }] },
{ duration: 3, layers: [{ type: 'image', path: './assets/img1.jpg', zoomDirection: null }] },
], ],
} }

5
sources/fabricFrameSource.js

@ -100,7 +100,10 @@ async function imageFrameSource({ verbose, params, width, height, canvas }) {
const img = getImg(); const img = getImg();
const scaleFactor = zoomDirection === 'in' ? (1 + progress * zoomAmount) : (1 + zoomAmount * (1 - progress));
let scaleFactor = 1;
if (zoomDirection === 'in') scaleFactor = (1 + progress * zoomAmount);
else if (zoomDirection === 'out') scaleFactor = (1 + zoomAmount * (1 - progress));
if (img.height > img.width) img.scaleToHeight(height * scaleFactor); if (img.height > img.width) img.scaleToHeight(height * scaleFactor);
else img.scaleToWidth(width * scaleFactor); else img.scaleToWidth(width * scaleFactor);

Loading…
Cancel
Save