[skottie] Plumb square selector "smoothness" prop
Requires https://github.com/bodymovin/bodymovin-extension/pull/22
Change-Id: I2614aeefce18f4b3e6c6373cd5503a7696253a76
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238436
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/skottie/src/text/RangeSelector.cpp b/modules/skottie/src/text/RangeSelector.cpp
index 6f00099..aed6f1e 100644
--- a/modules/skottie/src/text/RangeSelector.cpp
+++ b/modules/skottie/src/text/RangeSelector.cpp
@@ -306,6 +306,14 @@
selector->fEaseHi = xe;
});
+ // Optional square "smoothness" prop.
+ if (selector->fShape == Shape::kSquare) {
+ abuilder->bindProperty<ScalarValue>((*jrange)["sm"],
+ [selector](const ScalarValue& sm) {
+ selector->fSmoothness = sm;
+ });
+ }
+
return selector;
}
@@ -382,13 +390,13 @@
// We achieve this by moving the range edges outward by |smoothness|/2, and adjusting
// the generator cubic ramp size.
- // TODO: support actual smoothness prop.
- static constexpr float kSmoothness = 1.0f;
+ // smoothness is percentage-based [0..100]
+ const auto smoothness = SkTPin<float>(fSmoothness / 100, 0, 1);
- r0 -= kSmoothness / 2;
- len += kSmoothness;
+ r0 -= smoothness / 2;
+ len += smoothness;
- gen.crs += kSmoothness / len;
+ gen.crs += smoothness / len;
}
SkASSERT(len > 0);
diff --git a/modules/skottie/src/text/RangeSelector.h b/modules/skottie/src/text/RangeSelector.h
index 6e3501c..e2df000 100644
--- a/modules/skottie/src/text/RangeSelector.h
+++ b/modules/skottie/src/text/RangeSelector.h
@@ -69,9 +69,10 @@
float fStart,
fEnd,
fOffset,
- fAmount = 100,
- fEaseLo = 0,
- fEaseHi = 0;
+ fAmount = 100,
+ fEaseLo = 0,
+ fEaseHi = 0,
+ fSmoothness = 100;
};
} // namespace internal