Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
org.skia.jetskidemo.samples.SkottieSample Class Reference
Inheritance diagram for org.skia.jetskidemo.samples.SkottieSample:
org.skia.jetskidemo.samples.Sample

Public Member Functions

 SkottieSample (Resources res, int resId)
 
void render (Canvas canvas, long ms, float left, float top, float right, float bottom)
 
void render (Canvas canvas, long t, float left, float top, float right, float bottom)
 

Detailed Description

Definition at line 19 of file SkottieSample.java.

Constructor & Destructor Documentation

◆ SkottieSample()

org.skia.jetskidemo.samples.SkottieSample.SkottieSample ( Resources  res,
int  resId 
)
inline

Definition at line 23 of file SkottieSample.java.

23 {
24 String json = "";
25
26 try {
27 InputStream is = res.openRawResource(resId);
28 byte[] data = new byte[is.available()];
29 is.read(data);
30 json = new String(data);
31 } catch (Exception e) {}
32
33 mAnimation = new SkottieAnimation(json);
34 }
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

Member Function Documentation

◆ render()

void org.skia.jetskidemo.samples.SkottieSample.render ( Canvas  canvas,
long  t,
float  left,
float  top,
float  right,
float  bottom 
)
inline

Renders a Sample frame t (ms) into the destination rect [L T R B].

Implements org.skia.jetskidemo.samples.Sample.

Definition at line 36 of file SkottieSample.java.

36 {
37 canvas.drawRect(left, top, right, bottom, mClearPaint);
38
39 double t = (double)ms / 1000 % mAnimation.getDuration();
40 mAnimation.seekTime(t);
41
42 float w = right - left,
43 h = bottom - top,
44 s = Math.min(w / mAnimation.getWidth(),
45 h / mAnimation.getHeight());
46
47 canvas.save();
48 canvas.concat(new Matrix().translate(left + (w - s*mAnimation.getWidth() )/2,
49 top + (h - s*mAnimation.getHeight())/2)
50 .scale(s, s));
51
52 mAnimation.render(canvas);
53 canvas.restore();
54 }
struct MyStruct s
SK_API sk_sp< PrecompileColorFilter > Matrix()
SkScalar w
SkScalar h

The documentation for this class was generated from the following file: