38class PolystarGeometryAdapter final :
39 public DiscardableAdapterBase<PolystarGeometryAdapter, sksg::Path> {
46 const AnimationBuilder* abuilder,
Type t)
48 this->bind(*abuilder, jstar[
"pt"], fPointCount );
49 this->bind(*abuilder, jstar[
"p" ], fPosition );
50 this->bind(*abuilder, jstar[
"r" ], fRotation );
51 this->bind(*abuilder, jstar[
"ir"], fInnerRadius );
52 this->bind(*abuilder, jstar[
"or"], fOuterRadius );
53 this->bind(*abuilder, jstar[
"is"], fInnerRoundness);
54 this->bind(*abuilder, jstar[
"os"], fOuterRoundness);
58 void onSync()
override {
59 static constexpr int kMaxPointCount = 100000;
65 c.
y + r * std::sin(
a));
73 poly.
moveTo(pt_on_circle(fPosition, fOuterRadius, angle));
76 for (
unsigned i = 0; i <
count; ++i) {
77 if (fType == Type::kStar) {
78 poly.
lineTo(pt_on_circle(fPosition, fInnerRadius, angle + arc * 0.5f));
81 poly.
lineTo(pt_on_circle(fPosition, fOuterRadius, angle));
85 this->node()->setPath(poly.
detach());
103 static constexpr PolystarGeometryAdapter::Type gTypes[] = {
104 PolystarGeometryAdapter::Type::kStar,
105 PolystarGeometryAdapter::Type::kPoly,
108 const auto type = ParseDefault<size_t>(jstar[
"sy"], 0) - 1;
109 if (
type >= std::size(gTypes)) {
115 (jstar, abuilder, gTypes[
type]);
static constexpr float sk_ieee_float_divide(float numer, float denom)
#define SkDegreesToRadians(degrees)
#define SkScalarRoundToInt(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
constexpr unsigned SkToUInt(S x)
SkPathBuilder & lineTo(SkPoint pt)
void incReserve(int extraPtCount, int extraVerbCount)
SkPathBuilder & moveTo(SkPoint pt)
void attachDiscardableAdapter(sk_sp< T > adapter) const
void log(Logger::Level, const skjson::Value *, const char fmt[],...) const SK_PRINTF_LIKE(4
static sk_sp< sksg::GeometryNode > AttachPolystarGeometry(const skjson::ObjectValue &, const AnimationBuilder *)
static constexpr SkPoint Make(float x, float y)