Skottie - stretching on a single axis

39 views
Skip to first unread message

שחר לנגבהיים

unread,
Apr 2, 2020, 8:27:42 AM4/2/20
to skia-discuss
Hi, I tried to find any example that demonstrates how to stretch a Skottie animation on a single axis, preferably in CanvasKit - that is, scale an animation on one axis more than I scale it on the other.
Just passing a non-square rectangle to render() doesn't do it.
The only lead I found is TransformPropertyValue in SkottieProperty.h, but without documentation it isn't clear how the stretching should happen - I assume that fScale needs to be adjusted, but what about fAnchorPoint and fPosition? And what happens if there is any rotation or skew?
Is this possible to do in a simple manner using the Skottie API?

Mike Reed

unread,
Apr 2, 2020, 9:18:50 AM4/2/20
to skia-d...@googlegroups.com
Do you want to do this at runtime (i.e. in the player code, so it applies to any json file), or to modify a specific JSON so it will always play scaled?

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/5264b6ed-444d-4017-95a7-1cfe0d069ae1%40googlegroups.com.

Shachar Langbeheim

unread,
Apr 2, 2020, 10:12:58 AM4/2/20
to skia-discuss

Brian Osman

unread,
Apr 2, 2020, 10:16:13 AM4/2/20
to skia-d...@googlegroups.com
I think you'd do this by just applying the transform to the SkCanvas before playing the animation:

canvas->save();
canvas->scale(2, 1);
anim->render(canvas);
canvas->restore();


Shachar Langbeheim

unread,
Apr 5, 2020, 4:45:16 AM4/5/20
to skia-discuss
Thanks, that worked exactly as I needed :)

Reply all
Reply to author
Forward
0 new messages