32 return p0 + (p1 - p0) * t;
55 const auto input = geo->asPath();
60 const auto input_bounds = input.computeTightBounds();
61 const SkPoint center{input_bounds.centerX(), input_bounds.centerY()};
66 std::vector<CubicInfo> cubics;
68 auto commit_contour = [&]() {
69 path.moveTo(
lerp(contour_start, center, fAmount));
70 for (
const auto& c : cubics) {
71 path.cubicTo(
lerp(c.ctrl0, center, -fAmount),
72 lerp(c.ctrl1, center, -fAmount),
73 lerp(c.pt , center, fAmount));
88 contour_start = pts[0];
93 static constexpr float kCtrlPosFraction = 1.f / 100;
94 const auto line_start = pts[0],
97 lerp(line_start, line_end, kCtrlPosFraction),
98 lerp(line_start, line_end, 1 - kCtrlPosFraction),
104 cubics.push_back({pts[1], pts[2], pts[3]});
111 static constexpr float kCubicCircleCoeff = 1 - 0.551915024494f;
113 const auto conic_start = cubics.empty() ? contour_start
118 lerp(pts[1], conic_start, kCubicCircleCoeff),
119 lerp(pts[1], conic_end , kCubicCircleCoeff),
124 cubics.push_back({pts[1], pts[2], pts[3]});
142class PuckerBloatAdapter final :
public DiscardableAdapterBase<PuckerBloatAdapter,
146 const AnimationBuilder& abuilder,
149 this->bind(abuilder, joffset[
"a" ], fAmount);
153 void onSync()
override {
155 this->node()->setAmount(fAmount / 100);
160 using INHERITED = DiscardableAdapterBase<PuckerBloatAdapter, PuckerBloatEffect>;
168 std::vector<sk_sp<sksg::GeometryNode>> bloated;
169 bloated.reserve(geos.size());
171 for (
auto& g : geos) {
173 (jround, *abuilder, std::move(g)));
SkPoint lerp(const SkPoint &a, const SkPoint &b, float t)
void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4])
#define INHERITED(method,...)
sk_sp< T > sk_make_sp(Args &&... args)
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define SK_ScalarRoot2Over2
void attachDiscardableAdapter(sk_sp< T > adapter) const
static std::vector< sk_sp< sksg::GeometryNode > > AttachPuckerBloatGeometryEffect(const skjson::ObjectValue &, const AnimationBuilder *, std::vector< sk_sp< sksg::GeometryNode > > &&)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path