Last active
November 6, 2019 20:39
-
-
Save jacobsologub/23853fd06c53c3a506c3bbe76c77dabd to your computer and use it in GitHub Desktop.
hypno instant platform code example - Hold Still Inc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // crossfade-images.js | |
| // libhypno | |
| // | |
| // Created by Jacob Sologub on 29 Oct 2019 9:22:41pm | |
| // Copyright © 2019 Jacob Sologub. All rights reserved. | |
| import { Asset, Time, TimeRange, Clip, Vector, coreimage } from 'hypno'; | |
| import { Image, Filter } from 'hypno/coreimage'; | |
| Time.timescale = 30; | |
| let emptyClip = new Clip (new Time (30 * 3)); | |
| const TrackIDs = { | |
| Image: "image" | |
| }; | |
| const track = composition.track (TrackIDs.Image); | |
| track.add (emptyClip); | |
| const image1 = new Image ("./T0YRgsZ11jr6.jpg"); | |
| const image2 = new Image ("./T0YRgsZ11jr6-swapped.png"); | |
| composition.renderSize = image1.size; | |
| composition.render = function (context) { | |
| const instruction = context.instruction; | |
| const instructionProgress = (instruction.time.value / instruction.timeRange.duration.value); | |
| const colorMatrixFilter = new Filter (coreimage.CIColorMatrix, { | |
| inputAVector: new Vector (0.0, 0.0, 0.0, instructionProgress), | |
| inputImage: image2 | |
| }); | |
| const sourceOverFilter = new Filter (coreimage.CISourceOverCompositing); | |
| sourceOverFilter.set ({ inputBackgroundImage: image1, inputImage: colorMatrixFilter.apply() }); | |
| context.setFrame (TrackIDs.Image, sourceOverFilter.apply()); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment