From 055b0f5cb0b1eba1cfa7736642dd5b08e97e2045 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 22 Jan 2018 23:13:10 -0500 Subject: [skottie] Improved trim path support |offset| is an angular value in [0..360]. TBR= Change-Id: I10a91bec7e8f43db1f54c8b5358dd0604c974998 Reviewed-on: https://skia-review.googlesource.com/98560 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- experimental/skottie/Skottie.cpp | 3 +-- experimental/sksg/geometry/SkSGTrimEffect.cpp | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'experimental') diff --git a/experimental/skottie/Skottie.cpp b/experimental/skottie/Skottie.cpp index becf3bf470..da3023d2e4 100644 --- a/experimental/skottie/Skottie.cpp +++ b/experimental/skottie/Skottie.cpp @@ -471,10 +471,9 @@ std::vector> AttachTrimGeometryEffect( [](sksg::TrimEffect* node, const ScalarValue& e) { node->setEnd(e * 0.01f); }); - // TODO: "offset" doesn't currently work the same as BM - figure out what's going on. BindProperty(jtrim["o"], ctx, trim, [](sksg::TrimEffect* node, const ScalarValue& o) { - node->setOffset(o * 0.01f); + node->setOffset(o / 360); }); } diff --git a/experimental/sksg/geometry/SkSGTrimEffect.cpp b/experimental/sksg/geometry/SkSGTrimEffect.cpp index f3118221d5..afcc7e46b6 100644 --- a/experimental/sksg/geometry/SkSGTrimEffect.cpp +++ b/experimental/sksg/geometry/SkSGTrimEffect.cpp @@ -35,9 +35,9 @@ void TrimEffect::onDraw(SkCanvas* canvas, const SkPaint& paint) const { pathLen += measure.getLength(); } while (measure.nextContour()); - const auto start = SkScalarPin(fStart , 0, 1) * pathLen, - end = SkScalarPin(fEnd , 0, 1) * pathLen, - offset = SkScalarPin(fOffset, 0, 1) * pathLen, + const auto start = pathLen * fStart, + end = pathLen * fEnd, + offset = pathLen * fOffset, len = end - start; if (len <= 0) { -- cgit v1.2.3