Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
platform_tools
android
apps
jetski
src
main
java
org
skia
jetski
SkottieAnimation.java
Go to the documentation of this file.
1
/*
2
* Copyright 2021 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
package
org.skia.jetski;
9
10
public
class
SkottieAnimation
{
11
private
long
mNativeInstance;
12
13
/**
14
* Create an animation from the provided JSON string.
15
*/
16
public
SkottieAnimation
(String animation_json) {
17
mNativeInstance = nCreate(animation_json);
18
}
19
20
/**
21
* Returns the animation duration in seconds.
22
*/
23
public
double
getDuration
() {
24
return
nGetDuration(mNativeInstance);
25
}
26
27
/**
28
* Returns the animation frame count. This is normally an integral value,
29
* but both the JSON encoding and Skottie's frame-based APIs support fractional frames.
30
*/
31
public
double
getFrameCount
() {
32
return
nGetFrameCount(mNativeInstance);
33
}
34
35
/**
36
* Returns the intrinsic animation width.
37
*/
38
public
float
getWidth
() {
39
return
nGetWidth(mNativeInstance);
40
}
41
42
/**
43
* Returns the intrinsic animation height.
44
*/
45
public
float
getHeight
() {
46
return
nGetHeight(mNativeInstance);
47
}
48
49
/**
50
* Update the animation state to match |t|, specifed in seconds.
51
* The input is clamped to [0..duration).
52
*/
53
public
void
seekTime
(
double
t) {
54
nSeekTime(mNativeInstance, t);
55
}
56
57
/**
58
* Update the animation state to match |f|, specified as a frame index
59
* in the [0..frameCount) domain.
60
*
61
* Fractional values are allowed and meaningful - e.g.
62
*
63
* 0.0 -> first frame
64
* 1.0 -> second frame
65
* 0.5 -> halfway between first and second frame
66
*/
67
public
void
seekFrame
(
double
f) {
68
nSeekFrame(mNativeInstance, f);
69
}
70
71
/**
72
* Draw the current frame to the Canvas.
73
*/
74
public
void
render
(
Canvas
canvas) {
75
nRender(mNativeInstance, canvas.
getNativeInstance
());
76
}
77
78
/**
79
* Releases any resources associated with this Animation.
80
*/
81
public
void
release
() {
82
nRelease(mNativeInstance);
83
mNativeInstance = 0;
84
}
85
86
@Override
87
protected
void
finalize
() throws Throwable {
88
release
();
89
}
90
91
private
static
native
long
nCreate(String json);
92
private
static
native
void
nRelease(
long
nativeInstance);
93
94
private
static
native
double
nGetDuration(
long
nativeInstance);
95
private
static
native
double
nGetFrameCount(
long
nativeInstance);
96
private
static
native
float
nGetWidth(
long
nativeInstance);
97
private
static
native
float
nGetHeight(
long
nativeInstance);
98
99
private
static
native
void
nSeekTime(
long
nativeInstance,
double
t);
100
private
static
native
void
nSeekFrame(
long
nativeInstance,
double
frame
);
101
private
static
native
void
nRender(
long
nativeInstance,
long
nativeCanvas);
102
}
org.skia.jetski.Canvas
Definition
Canvas.java:12
org.skia.jetski.Canvas.getNativeInstance
long getNativeInstance()
Definition
Canvas.java:136
org.skia.jetski.SkottieAnimation
Definition
SkottieAnimation.java:10
org.skia.jetski.SkottieAnimation.seekFrame
void seekFrame(double f)
Definition
SkottieAnimation.java:67
org.skia.jetski.SkottieAnimation.getDuration
double getDuration()
Definition
SkottieAnimation.java:23
org.skia.jetski.SkottieAnimation.SkottieAnimation
SkottieAnimation(String animation_json)
Definition
SkottieAnimation.java:16
org.skia.jetski.SkottieAnimation.render
void render(Canvas canvas)
Definition
SkottieAnimation.java:74
org.skia.jetski.SkottieAnimation.finalize
void finalize()
Definition
SkottieAnimation.java:87
org.skia.jetski.SkottieAnimation.getWidth
float getWidth()
Definition
SkottieAnimation.java:38
org.skia.jetski.SkottieAnimation.getHeight
float getHeight()
Definition
SkottieAnimation.java:45
org.skia.jetski.SkottieAnimation.seekTime
void seekTime(double t)
Definition
SkottieAnimation.java:53
org.skia.jetski.SkottieAnimation.getFrameCount
double getFrameCount()
Definition
SkottieAnimation.java:31
org.skia.jetski.SkottieAnimation.release
void release()
Definition
SkottieAnimation.java:81
frame
double frame
Definition
examples.cpp:31
Generated on Fri Apr 26 2024 06:16:31 for Flutter Engine by
1.9.8