Giter VIP home page Giter VIP logo

keyframes's Introduction

Keyframes

Version Version Carthage compatible License

Keyframes

Keyframes is a combination of (1) an ExtendScript script that extracts image animation data from an After Effects file and (2) a corresponding rendering library for Android and iOS. Keyframes can be used to export and render high quality, vector based animations with complex shape and path curves, all with minimal file footprint.

Usage

Developing Animations in After Effects

For a detailed list of constraints for developing animations to use with the Keyframes library, please refer to the Keyframes After Effects Guidelines.

Image Data Extraction

Use of the extraction script requires an installation of Adobe After Effects as well as Adobe ExtendScript Toolkit. If Keyframes JSON files are already available, only the corresponding iOS and Android libraries are needed.

For detailed steps on running the ExtendScript script on your AE comp, please refer to the instructions detailed here.

iOS Rendering

Installation

CocoaPods

Keyframes is available on CocoaPods. Add the following to your Podfile:

target 'MyApp' do
  pod "keyframes"
end

Quit Xcode completely before running

pod install

in the project directory in terminal.

Carthage

Keyframes is also available through Carthage.

Add the following to your Cartfile to get the latest release branch:

github "facebookincubator/Keyframes"

Or, to get the master branch:

github "facebookincubator/Keyframes" "master"

Run

> carthage update

In Xcode, on your application targets’ "General" settings tab, in the "Linked Frameworks and Libraries" section, drag and drop the framework from the Carthage/Build folder.

Rendering Setup

Use the provided deserializers on the generated JSON blob from the Image Data Extraction step to create a KFVector model object. If your JSON blob lives in the assets directory, this might look like:

NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"asset_name" ofType:@"json" inDirectory:nil];
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSDictionary *vectorDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
KFVector *vector = KFVectorFromDictionary(vectorDictionary);

Then a KFVectorLayer can be created using this KFVector, KFVectorLayer can be used as normal CALayer.

KFVectorLayer *layer = [KFVectorLayer layer];
// Set a non-zero layer frame before setting the KFVector is required.
layer.frame = $AnyNonZeroCGRect$;
layer.faceModel = vector;

If you don't want the control of animation and prefer a UIView, KFVectorView can also be created using KFVector.

KFVectorView *view = [[KFVectorView alloc] initWithFrame:$AnyNonZeroCGRect$ faceVector:vector];

Play!

Use startAnimation, pauseAnimation, resumeAnimation and seekToProgress on KFVectorLayer to control the animation.

// Animation will start from beginning.
[layer startAnimation];

// Pause the animation at current progress.
[layer pauseAnimation];

// Resume the animation from where we paused last time.
[layer resumeAnimation];

// Seek to a given progress in range [0, 1]
[layer seekToProgress:0.5]; // seek to the mid point of the animation

Android Rendering

Download

Download the latest JARs or grab via Gradle:

compile 'com.facebook.keyframes:keyframes:1.0'

or Maven:

<dependency>
  <groupId>com.facebook.keyframes</groupId>
  <artifactId>keyframes</artifactId>
  <version>1.0</version>
</dependency>

Rendering setup

Use the provided deserializers on the generated JSON blob from the Image Data Extraction step to create a KFImage model object. If your JSON blob lives in the assets directory, this might look like:

InputStream stream = getResources().getAssets().open("asset_name");
KFImage kfImage = KFImageDeserializer.deserialize(stream);

A KeyframesDrawable object can be created now using this KFImage, and this drawable can be used as a normal drawable. It is highly recommended to use the software layer on any views displaying Keyframes animations.

KeyframesDrawable kfDrawable = new KeyframesDrawableBuilder().withImage(kfImage).build();

ImageView imageView = (ImageView) findViewById(R.id.some_image_view);
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
imageView.setImageDrawable(kfDrawable);
imageView.setImageAlpha(0);

Play!

Use the start and stop animations on the drawable when appropriate to begin playback of the animation or end it after the end of the current loop.

// Starts a loop that progresses animation from the beginning and invalidates the drawable.
kfDrawable.startAnimation();

// Pause the animation at current progress.
kfDrawable.pauseAnimation();

// Resume the animation from where we paused last time.
kfDrawable.resumeAnimation();

// Stops the animation.
kfDrawable.stopAnimation();

// Stops the animation when the current animation ends.
kfDrawable.stopAnimationAtLoopEnd();

// Starts the animation and plays it once. Will stop at the end
kfDrawable.playOnce();

Mobile Frameworks

Existing implementations for mobile frameworks:

Framework Platform Author Link
React Native (imperative api) Android/IOS Tomas Roos https://github.com/ptomasroos/react-native-keyframes/
Appcelerator Titanium iOS Hans Knoechel https://github.com/hansemannn/ti.keyframes
Appcelerator Titanium Android Michael Gangolf https://github.com/m1ga/ti.keyframes
React Native Android/iOS Underscope https://github.com/underscopeio/react-native-facebook-keyframes
NativeScript Android/IOS Eddy Verbruggen https://github.com/EddyVerbruggen/nativescript-keyframes

Understanding Keyframes Model Objects

Image

An Image in Keyframes consists of a number of important fields, which together, describe an animated and scalable image. At the top level, an image contains information about how to scale (canvas_size) an image, as well as how to play back an animation at the correct speed (frame_rate, frame_count). The animation itself is not bound to the discrete frame_rate that the image was extracted at, as the Keyframes rendering library supports fractional frames. In addition to these global parameters of an Image, an Image also contains a number of Features, which describe different shapes to be drawn, as well as Animation Groups, which describe transforms that can be applied to multiple Features or even other Animation Groups at once.

Let's break down this simple image of a star against a circle scaling up and down. The animation was exported at 24FPS, and the frame number is shown in the top left corner as well as the scale of the star on the bottom.

Star, Real Time

Let's slow that down a bit, frame by frame.

Star, Slowwwww

Features

A Feature is any independent visual object of the image. Most important, it includes shape drawing commands, presented very similary to SVG type commands, which describe the Feature's shape at any given time. A Feature may belong to a larger Animation Group, as well as contain features specific animations of its own, including a specialized STROKE_WIDTH animation. The shape of a Feature can also change over time, using the same Keyframe and Interpolator pattern described below.

Shape

A shape is any list of line drawing commands, which strung together, describe a continuous line or closed shape that can be filled or stroked. The commands are given as a series of Move, Line, Quadratic, and Cubic commands, one after another.

Here are the important shapes for the above image, along with vertices (squares) and control points (circles), if relevant.

Circle Shape Star Shape

Animations

Transforms

The Keyframes rendering library includes support for the common matrix based transform operations, SCALE, ROTATE, and TRANSLATE. For Features specifically, an additional non-matrix STROKE_WIDTH is available. Animations may belong to specific Features, or as part of a larger Animation Group.

Animation Progression

The values of a transform of an animation and how they change during the playback of an animation are determined by two key fields, Keyframes and Timing Curves. Using the combination of the two fields, we can calculate back a value for a transform at any specified time in the animation.

Keyframes are specific frames in the animation that have specific target values. For example, in scaling a shape up and back down over 10 frames, we will want to start and end at 100% scale at the 0th and 10th frame, and hit our max scale of 150% on the 7th frame. In this example, our key frames for the SCALE transform for this shape would be [0, 7, 10] with the values [100%, 150%, 100% respectively.

Timing Curves describe the pace with which a transform changes between each keyframe. Each timing curve is modeled as a cubic bezier curve from point [0, 0] to [1, 1], where the X value is the progression in time from the origin keyframe to the destination keyframe, and the Y value describes the amount of change in the value at a given time: origValue + (destValue - origValue) * Y.

For our scaling star image, the graph of scale change over time looks like this, with vertices and timing curve in/out values shown.

Scale Animation Curve

Tying it all together

With these fields from an Image object, as well as a progress value, we can build back all of the shapes of the Image at a given time, as well as any transformations to apply to the shapes, and draw back the Image at that frame. Because the animations are driven by flexible timing_curves, a Keyframes Image is not limited to discrete integer frames for playback, but it is important to note that all progress values are given in relation to the frame count. This means a 10 frame animation accepts all values in the range [0..10].

Contributing

See CONTRIBUTING.md for how to help us by improving this library!

keyframes's People

Contributors

baires avatar catbus avatar dcaunt avatar eddyverbruggen avatar facebook-github-bot avatar hansemannn avatar insidegui avatar keizar901 avatar lozzle avatar m1ga avatar marmelroy avatar mauin avatar michaelobriena avatar ochanje210 avatar oueasley avatar ptomasroos avatar renyu-io avatar revolter avatar rohandhruva avatar subtlegradient avatar triniwiz avatar vcalvello avatar virenmohindra avatar zats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyframes's Issues

How to play the animation only once on iOS?

I'm sorry if this is obvious, but how can I get the animation to play only once on iOS? I saw the method for Android:

// Stops the animation when the current animation ends.
kfDrawable.stopAnimationAtLoopEnd();

Thanks in advance!

evalInAfterEffects.lock file not found on Windows

While running keyframes-cli on Windows I get the following error

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open 'C:\Program Files\Adobe\Adobe After Effects CC 2015\Support Files\Scripts\Keyframes\undefined\.evalInAfterEffects.lock'
    at Error (native)

It looks like the script attaches \undefined\.evalInAfterEffects.lock to the current directory. AF was open at the time.

After Effects exporter not working

The exporter in after effects isn't exporting a JSON file. The script panel says it's exporting but never finishes. No JSON file is exported, only a log file that's completely blank with no file size.

Can someone please help to confirm if there's an issue or if I've not set it up correctly.

Thanks

macOS support

I would love to see support for macOS. Would it be difficult to add?

Dynamic animations

It's possible to create animations and add them into diferente images? To make it more dynamic

How are these heart particles emitted?

Help Wanted:

If the team is willing to answer, are these heart particles in the animation example below, exported as a self-contained After Effects animation? Or, are the KFVectorLayers dynamically animated via something like SpriteKit or SceneKit particles?

Thanks in advance!

Take care,
Mark

Add swift demo

Hey guys,

anyone interested in a Swift 3 port? I'd port it, but not if someone already works on it. Thx!

P.S.: Great library! 🚀

Gradient Ramp not working

Hello.

used gradient ramp but json data not exist "effects", "gradient".
I looked up the source in github, Related code did not exist.

I want Gradient Ramp animation.

Thank you.

Script never ends

I have an After Effects project, when I'm going to execute the script, this never ends, only display 'exporting'.

Unable to execute script at line 87

can not execute script at AE cc 2015, 2017 , windows 10.

Error Message is
"Can not run script at 87 line. Uncaught JavaScipt exception:TypeError:
cannot convert to c:\Programs files\adobe~\Support File\script~~~\AECompToKeyFramesAnimation.js"

Masks?

Maybe Im not doing it correctly, but is there a specific way to set up masks for it to be read properly by Keyframes? I've tried the traditional pen/shape mask and also the track matte.
From looking at the Reactions animations it would seem like masks were used.. so was curious if there was support for this.

Does the AfterEffects script work with CS6?

I've been trying to run the script with CS6 with no luck, I wonder if it is not supported by CS6, otherwise if it does work if CS6 I'll continue searching for a solution.

new-android-features branch not support gradient animation

Hello.

I used gradient animation in master branch, but new-android-features don't support.
I compared two branch.

KeyFramedObject Class found problem.

master source has a variable "mInterpolators".

public KeyFramedObject(List objects, float[][][] timingCurves) {
.....
mInterpolators = KeyFrameAnimationHelper.buildInterpolatorList(timingCurves);
}

but other branch source move updateWithFrameRate method.

KeyFramedGradient not call updateWithFrameRate. So don't animation;

I modified my source.

KeyframesDrawable class - prepareShadersForFeature method.

for (int i = 0; i < precision; i++) {
        progress = i / (float) (precision) * numFrames;

       // --> insert code
        gradient.getStartGradient().updateWithFrameRate(frameRate);
        gradient.getEndGradient().updateWithFrameRate(frameRate);
     // <-- 

        gradient.getStartGradient().apply(progress, colorPair);
        gradient.getEndGradient().apply(progress, colorPair);
        mCachedShaders[i] = new LinearGradient(
                0,
                0,
                0,
                mKFImage.getCanvasSize()[1],
                colorPair.getStartColor(),
                colorPair.getEndColor(),
                Shader.TileMode.CLAMP);

Thank you.

keyframes-cli syntax error

I'm getting a syntax error when running $ keyframes-cli with a comp saved and open:

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/fang/.nvm/versions/node/v5.7.0/lib/node_modules/keyframes-cli/keyframes-cli.js:13:18)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

Using After Effects CC 2017 on Sierra and I have followed the README for installing keyframes-cli.

Support React Native

This is an awesome library, is there a current path to use it with React Native?

Thanks.

[Android] OPACITY is not a constant in com.facebook.keyframes.model.KFAnimation$PropertyType

One of the animations I'm trying to load has a feature with an OPACITY property.

{
          "property": "OPACITY",
          "key_values": [
            {
              "start_frame": 6,
              "data": [
                0
              ]
            },
            {
              "start_frame": 12,
              "data": [
                100
              ]
            }
          ],...
}

The Keyframes Android framework is not handling this properly.

FATAL EXCEPTION: main
Process: com.owletcare.owletfield, PID: 11924
java.lang.IllegalArgumentException: OPACITY is not a constant in com.facebook.keyframes.model.KFAnimation$PropertyType
at java.lang.Enum.valueOf(Enum.java:200)
at com.facebook.keyframes.model.KFAnimation$PropertyType.valueOf(KFAnimation.java:41)
at com.facebook.keyframes.deserializers.KFAnimationDeserializer.readObject(KFAnimationDeserializer.java:40)
at com.facebook.keyframes.deserializers.KFAnimationDeserializer$1.readObjectImpl(KFAnimationDeserializer.java:29)
at com.facebook.keyframes.deserializers.KFAnimationDeserializer$1.readObjectImpl(KFAnimationDeserializer.java:26)
at com.facebook.keyframes.deserializers.AbstractListDeserializer.readList(AbstractListDeserializer.java:35)
at com.facebook.keyframes.deserializers.KFFeatureDeserializer.readObject(KFFeatureDeserializer.java:71)
at com.facebook.keyframes.deserializers.KFFeatureDeserializer$1.readObjectImpl(KFFeatureDeserializer.java:32)
at com.facebook.keyframes.deserializers.KFFeatureDeserializer$1.readObjectImpl(KFFeatureDeserializer.java:29)
at com.facebook.keyframes.deserializers.AbstractListDeserializer.readList(AbstractListDeserializer.java:35)
at com.facebook.keyframes.deserializers.KFImageDeserializer.readObject(KFImageDeserializer.java:52)
at com.facebook.keyframes.deserializers.KFImageDeserializer.deserialize(KFImageDeserializer.java:35)
at com.owletcare.owlet.controls.KeyframesSequence.load(KeyframesSequence.java:78)
at com.owletcare.owlet.controls.KeyframesSequence.<init>(KeyframesSequence.java:68)
at com.owletcare.owlet.fragments.vitalsHelpPages.VHFeedingFragment.onViewCreated(VHFeedingFragment.java:37)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1132)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1682)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:541)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

This error is coming from the current build on Gradle. The animation runs fine when I run it on a clone of the current repository.

I suggest a new build be released to Gradle as soon as possible.

Buildtime Warnings in framework?

Are the following warnings anything to be concerned about?

  • Warning: no umbrella header found for target 'keyframes', module map will not be generated
  • Method override for the designated initializer of the superclass '-initWithFrame:' not found

keyframes-framework-warnings

Thanks,
Mark

Animating Opacity

Hello.

I was just wondering if animating opacity is supported or will be soon. I get this exception when I try to deserialize my json on android.

 Caused by: java.lang.IllegalArgumentException: No enum constant com.facebook.keyframes.model.KFAnimation.PropertyType.OPACITY
    at java.lang.Enum.valueOf(Enum.java:254)
    at com.facebook.keyframes.model.KFAnimation$PropertyType.valueOf(KFAnimation.java:41)
    at com.facebook.keyframes.deserializers.KFAnimationDeserializer.readObject(KFAnimationDeserializer.java:40)

...

Animation not showing on iOS & Android

I installed and ran the AE script as instructed but when I try and my exported JSON file in the Xcode example project or Android Studio nothing shows up. It's a very simple rotation example.
Am I missing something here?

using AE version 14.0.1.5

{
"formatVersion": "1.0",
"name": "COMP",
"key": 1,
"frame_rate": 24,
"animation_frame_count": 24,
"canvas_size": [
600,
600
],
"features": [
{
"name": "Shape Layer 1",
"feature_animations": [
{
"property": "ANCHOR_POINT",
"key_values": [
{
"start_frame": 0,
"data": [
13.3359375,
33.3359375
]
}
],
"timing_curves": [

      ]
    },
    {
      "property": "X_POSITION",
      "key_values": [
        {
          "start_frame": 0,
          "data": [
            300
          ]
        }
      ],
      "timing_curves": [
        
      ]
    },
    {
      "property": "Y_POSITION",
      "key_values": [
        {
          "start_frame": 0,
          "data": [
            300
          ]
        }
      ],
      "timing_curves": [
        
      ]
    },
    {
      "property": "ROTATION",
      "key_values": [
        {
          "start_frame": 0,
          "data": [
            0
          ]
        },
        {
          "start_frame": 24,
          "data": [
            180
          ]
        }
      ],
      "timing_curves": [
        [
          [
            0.33333333,
            0
          ],
          [
            0.66666667,
            1
          ]
        ]
      ]
    }
  ],
  "stroke_line_cap": "butt",
  "fill_color": "#ff5f90df",
  "stroke_color": "#ffffffff",
  "stroke_width": 0
}

],
"animation_groups": [

]
}

Doesn't work on AE CC 2015(Windows)?

After importing the Scripts to AE, an alert poped up when pressed the "Export" button,showing as below

1167aa40e7ef1aa468ef4c3708c656f1

some of my configuration:

1167aa40e7ef1aa468ef4c3708c656f11

0187f9b5738f5cfd22ceb4e1a8bf642d1

Any ideas?

Provide sample JSON files

I wasn't able to find them (correct me if I'm wrong) but it would be nice to have a couple of sample JSON files to be able to write up a quick test and check things out without needing to install After Effects and whatnot, bandwidth doesn't help me. Thanks

Inconsistent terminology: "Image" vs. "Vector"

README.md talks about Image as the primary model object in Keyframes, however in the iOS code it is instead called Vector. It would be nice if there was correspondence (I personally kind of prefer the term "Image" here).

Implement delegates / listener to track playback

Not 100 % sure if that's available already, but we should create a delegate (iOS) / listener (Android) to notify the developer who implements the delegate / listener about the current progress. Is there an interest on this functionality? Then I'd implement it. 🚀

support react native

Seems like all the pieces for using react native is already there. just need to put together as a module.

Shape exceeding comp bounds on iOs & Android

I have a comp which includes a circular shape layer that expands to a size that exceeds the bounds of the comp. It looks fine in AE but on device it doesnt seem to clip to the comp size.

In Android 6.0 KeyframesDrawable background transparent is lose

device-2016-12-09-144241
device-2016-12-09-144411

first screen shot is in nexus 6p running with android 7.0. I try to run in nexus 5x with android 6.0, background is also black.

2nd screen shot is running with android 4.4. I just use sample_file.json which in keyframes sample. and the keyframes sample is same result.

Implement stroke trim & thickness & stuff

Hi Guys,

I'm using After effects 2017 on macOS Sierra.
Every time i export i get a different result. As you can see from the gif below the export doesn't work. It hasn't copied over the colour, stroke thickness or the shape rotation only the shape path.

Image of issue

Here is the log from the export

2017-01-04T18:32:53.560Z	Exporting "animation" from "/Users/user/Desktop/loader.aep"
2017-01-04T18:32:53.560Z	Encoding...
2017-01-04T18:32:53.566Z	tuna
2017-01-04T18:32:53.588Z	tuna/Contents
2017-01-04T18:32:53.593Z	tuna/Contents/Shape 1
2017-01-04T18:32:53.607Z	tuna/Contents/Shape 1/Contents
2017-01-04T18:32:53.612Z	tuna/Contents/Shape 1/Contents/Path 1
2017-01-04T18:32:53.762Z	tuna/Contents/Shape 1/Contents/Stroke 1
2017-01-04T18:32:53.957Z	tuna/Contents/Shape 1/Contents/Stroke 1/Dashes
2017-01-04T18:32:53.964Z	tuna/Contents/Shape 1/Contents/Fill 1
2017-01-04T18:32:54.018Z	tuna/Contents/Shape 1/Transform
2017-01-04T18:32:54.194Z	tuna/Contents/Shape 1/Material Options
2017-01-04T18:32:54.204Z	tuna/Masks
2017-01-04T18:32:54.210Z	tuna/Effects
2017-01-04T18:32:54.215Z	tuna/Transform
2017-01-04T18:32:54.492Z	tuna/Layer Styles
2017-01-04T18:32:54.497Z	tuna/Geometry Options
2017-01-04T18:32:54.503Z	tuna/Material Options
2017-01-04T18:32:54.509Z	tuna/Audio
2017-01-04T18:32:54.515Z	Cloning...
2017-01-04T18:32:54.526Z	Exporting...
2017-01-04T18:32:54.532Z	UNSUPPORTED: %s Root → animation → tuna → Contents → Rotation → Rotation on vector
2017-01-04T18:32:54.545Z	Saving...
2017-01-04T18:32:54.553Z	FB Keyframes JSON Exported:
2017-01-04T18:32:54.554Z	/Users/loader.aep.comp-1-animation.kf.json
2017-01-04T18:32:54.555Z	Calling After Creation Hook command: `"/Users/(lib)/hooks-macos/after-creation.sh" "/Users/loader.aep.comp-1-animation.kf.json"`
2017-01-04T18:32:54.618Z	+ LocalFile='/Users/loader.aep.comp-1-animation.kf.json'
++ /sbin/md5 -q '/Users/loader.aep.comp-1-animation.kf.json'
+ RemoteFile=/sdcard/PreviewKeyframesAnimation-4217af87847c8b50f41f2653b40e7fe5.json
+ main
+ read serial
++ adb devices
++ awk 'NR>1 {print $1}'
+ [[ emulator-5554 == '' ]]
+ echo 'serial='\''emulator-5554'\'''
+ read serial
+ [[ '' == '' ]]
+ break
+ push-the-animation emulator-5554
+ local serial=emulator-5554
+ /platform-tools/adb -s emulator-5554 push '/Users/loader.aep.comp-1-animation.kf.json' /sdcard/PreviewKeyframesAnimation-4217af87847c8b50f41f2653b40e7fe5.json
/Users/Desktop/Keyframes-master/Keyframes After Effects Scripts/(lib)/hooks-macos/after-creation.sh: line 9: /platform-tools/adb: No such file or directory
serial='emulator-5554'

2017-01-04T18:32:54.620Z	Raw JSON Exported:
2017-01-04T18:32:54.623Z	/Users/loader.aep.comp-1-animation.json

Here is the JSON File

{
  "formatVersion": "1.0",
  "name": "ANIMATION",
  "key": 0,
  "frame_rate": 30,
  "animation_frame_count": 50,
  "canvas_size": [
    200,
    200
  ],
  "features": [
    {
      "name": "tuna",
      "feature_animations": [
        {
          "property": "ANCHOR_POINT",
          "key_values": [
            {
              "start_frame": 0,
              "data": [
                0,
                0
              ]
            }
          ],
          "timing_curves": []
        },
        {
          "property": "X_POSITION",
          "key_values": [
            {
              "start_frame": 0,
              "data": [
                100
              ]
            }
          ],
          "timing_curves": []
        },
        {
          "property": "Y_POSITION",
          "key_values": [
            {
              "start_frame": 0,
              "data": [
                100
              ]
            }
          ],
          "timing_curves": []
        }
      ],
      "stroke_line_cap": "butt",
      "key_frames": [
        {
          "start_frame": 0,
          "data": [
            "M0.33,0.33",
            "L0.33,0.33",
            "L0.33,0.33",
            "L0.33,0.33",
            "L0.33,0.33"
          ]
        },
        {
          "start_frame": 24,
          "data": [
            "M30.69,-30.12",
            "L-30.02,-30.12",
            "L-30.02,30.79",
            "L30.69,30.79",
            "L30.69,-30.12"
          ]
        },
        {
          "start_frame": 28,
          "data": [
            "M30.69,-30.12",
            "L-30.02,-30.12",
            "L-30.02,30.79",
            "L30.69,30.79",
            "L30.69,-30.12"
          ]
        },
        {
          "start_frame": 49,
          "data": [
            "M60.34,-59.87",
            "L-59.67,-59.87",
            "L-59.67,60.54",
            "L60.34,60.54",
            "L60.34,-59.87"
          ]
        }
      ],
      "timing_curves": [
        [
          [
            0.166666665,
            0
          ],
          [
            0.833333335,
            1
          ]
        ],
        [
          [
            0.166666665,
            0
          ],
          [
            0.833333335,
            1
          ]
        ],
        [
          [
            0.166666665,
            0
          ],
          [
            0.833333335,
            1
          ]
        ]
      ],
      "fill_color": "#ff000000",
      "stroke_color": "#ffff0000",
      "stroke_width": 0
    }
  ],
  "animation_groups": []
}

Also please see the Layer keyframes. I've used shape path instead of scale as it didn't export the scale properties.
Image of keyframes

No Way to Tint KeyframesDrawable

I've tried using ImageViews tinting functions, and even Drawables tinting functions but the animation stayed the same color. I would appreciate it if tinting functionality would be added.

Documentation: Explain about decoding JSON in the background

Hey guys,

Using the Android library here. When loading large json files, I'm getting around a 2-3 second UI hang. This was obviously undesired and I narrowed down the issue to being in the deserialization of the asset from the InputStream. The way I got around the issue was by using an Rx chain and pushing the deserialization off of the UI thread while providing a Looper from a HandlerThread to the Scheduler. I'm sure this can be achieved in a similar fashion with AsyncTask if needed.

In general, the file still takes around 2 seconds to load while on a background thread.
Our animation files are around 30k - 50k lines long.

[iOS] Animate a Window of the timeline

Suppose, my vector file contains 3 seconds of animation. How can I animate only part of it, like from second 2 to second 3? In other words, from progress 0.3333 to progress 0.6666. I think right now this is not supported by the framework, but I'd like to know some ideas so I can implement it myself.

After Effects Not Exporting

Adobe After Effects CC 2017 (UpToDate)

Installed Scripts
Turned on "Allow Scripts to write files"
Open File
Open Comp that I want to export only.
Run Script
See Export Dialog
Click Export
See "Exporting..."
Writes Blank Log File
Activity Manager - AE CPU usage is at 1.6%

Nothing else happens even leaving AE open overnight.

How can I get the script to work? I am a iOS dev and would love to use this in our pipeline.

black background in Lollipop devices

Hello,
I clone the repo and play it on Android devices. I got a ImageView with black background like:

( Nexus 5X, Android 7.1.1, LAYER_TYPE_SOFTWARE )

nexus_5x_soft_1_3rd

If I remove imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);, the background of ImageView becom transparent as excepted.

( Nexus 5X, Android 7.1.1, LAYER_TYPE_NONE )

nexus_5x_none_1_3rd

Same situation happens in other devices

( Galaxy S4, Android 5.0.1, LAYER_TYPE_SOFTWARE )

samsung_soft_1_3rd

( Galaxy S4, Android 5.0.1, LAYER_TYPE_NONE )

samsung_none_1_3rd

But in 4.4, LAYER_TYPE_SOFTWARE works.

( Android Emulator, Android 4.4
emu_api_19_soft_half

Should I close LAYER_TYPE_SOFTWARE in post-Lollipop devices?

Help with an optimal method for instantiating multiple KFVectorLayer animations?

Below is my code for instantiating three KFVectorLayer animations, which you can check out in my Keyframes-Test repo. There must be a more efficient way to do this dynamically, and with fewer lines of code, right?

override func viewDidLoad() {
        super.viewDidLoad()
        
        // Create JSON data extractor object for reuse
        let jsonDataExtractor = JsonDataExtractor()
        
        // Calculated dimensions, relating to the screen's dimensions
        let shortSide = min(self.view.bounds.width, self.view.bounds.height)
        let longSide = max(self.view.bounds.width, self.view.bounds.height)
        
        ///=============== Animate Keyframe logo on the top to be played twice
        
        // Top Keyframe animated logo
        let keyframeLogoVector : KFVector!
        
        // Create animation from JSON vector file.
        do {
            keyframeLogoVector = try jsonDataExtractor.loadVectorFromDisk(assetName: "sample_logo")
        } catch {
            print("Vector file could not be loaded, aborting")
            return
        }
        
        // Create vector layer
        let keyframeLogoVectorLayer = KFVectorLayer()
        
        keyframeLogoVectorLayer.frame = CGRect(x: shortSide / 4, y: 20, width: shortSide / 2, height: shortSide / 2)
        
        // The repeatCount parameter *MUST* be declared prior to the faceModel, and not after. Otherwise, the animation will not stop. If you want the animation to repeat indefinitely, just comment the following line out.
        keyframeLogoVectorLayer.repeatCount = 2
        
        // Attach the animation to the faceModel.
        keyframeLogoVectorLayer.faceModel = keyframeLogoVector!
        
        // Add the VectorLayer as a sublayer for the main view.
        self.view.layer.addSublayer(keyframeLogoVectorLayer)
        
        // Start animation halfway through.
        //keyframeLogoVectorLayer.seek(toProgress: 0.5) //<== Seek to Progress doesn't seem to work
        
        // Start the animation, which will loop by default.
        keyframeLogoVectorLayer.startAnimation()
        
        ///=============== Animate "S" Letter to be played once
        
        let sLetterVector : KFVector!
        do {
            sLetterVector = try jsonDataExtractor.loadVectorFromDisk(assetName: "keyframes")
        } catch {
            print("Vector file could not be loaded, aborting")
            return
        }

        let sLetterVectorLayer = KFVectorLayer()
        sLetterVectorLayer.frame = CGRect(x: shortSide / 4, y: longSide / 2 - shortSide / 4, width: shortSide / 2, height: shortSide / 2)
        sLetterVectorLayer.repeatCount = 1
        sLetterVectorLayer.faceModel = sLetterVector!
        self.view.layer.addSublayer(sLetterVectorLayer)
        sLetterVectorLayer.startAnimation()
        
        ///=============== Animate Keyframe logo on the bottom to be played infinitely
        
        // Bottom Keyframe animated logo
        let sampleLogoVector : KFVector!
        do {
            sampleLogoVector = try jsonDataExtractor.loadVectorFromDisk(assetName: "sample_logo")
        } catch {
            print("Vector file could not be loaded, aborting")
            return
        }
        let sampleLogoVectorLayer = KFVectorLayer()
        sampleLogoVectorLayer.frame = CGRect(x: shortSide / 4, y: longSide - 180, width: shortSide / 2, height: shortSide / 2)
        sLetterVectorLayer.repeatCount = 0
        sampleLogoVectorLayer.faceModel = sampleLogoVector!
        self.view.layer.addSublayer(sampleLogoVectorLayer)
        sampleLogoVectorLayer.startAnimation()
        
    }

Play Animation without repeating in iOS

Thank you for this wonderful library. It's exactly what I need for an upcoming project. Great job! This definitely something I'd like to contribute to.

I'm just digging into the code right now, but I noticed in iOS, there is no equivalent to Android's stopAnimationAtLoopEnd so that the animation could only be played once. I've tried setRepeatCount (setting it both before and after starting the animation), and it still repeats.

Is there a simple way to play an animation just one iteration in iOS? Thanks!

Runtime error on iOS

When trying to run the sample app on an iOS device, I get this error message:

dyld: Library not loaded: @rpath/keyframes.framework/keyframes
Referenced from: /var/containers/Bundle/Application/53D31992-2E40-4E7A-82DB-B0AB58B46AFE/keyframes-sample-ios.app/keyframes-sample-ios
Reason: image not found

Colour blending modes like 'Multiply'

Is there currently a way to use colour blending modes like multiply, overlay, etc? It doesn't seem to work when testing on iOS.

This would be a great addition. Cheers!

screen-shot-2016-12-30-at-17 58 13

More (advanced) JSON example files

Are there any examples beside the keyframes logo JSON to try out? E.g. the emoticons?

I don't have access to AFX to create files but I would like to test more files on Android (I'm creating an Android module for Appcelerator Titanium: https://github.com/m1ga/ti.keyframes to support Keyframes) to see if everything is running fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.