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 OpenHarmony.
Keyframes can be used to export and render high quality, vector based animations with complex shape and path curves, all with minimal file footprint.
For a detailed list of constraints for developing animations to use with the Keyframes library, please refer to the Keyframes After Effects Guidelines.
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.
compile 'io.openharmony.tpc.thirdlib:Keyframes:1.0.0'
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);
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();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型