59 int wedges[] = { 6, 12, 36 };
61 for (
int wedge : wedges) {
67 for (
int index = 0; index < dashExample.length; ++index) {
68 dashUnits += dashExample.pattern[index];
70 SkScalar unitLength = arcLength / dashUnits;
72 for (
int index = 0; index < wedge; ++index) {
73 for (
int i2 = 0; i2 < dashExample.length; i2 += 2) {
74 SkScalar span = dashExample.pattern[i2] * unitLength;
78 angle += span + (dashExample.pattern[i2 + 1]) * unitLength;
90 int intervalCount = dashExample.length;
91 SkScalar dashLength = circumference / wedge / dashUnits;
92 for (
int index = 0; index < dashExample.length; ++index) {
93 intervals[index] = dashExample.pattern[index] * dashLength;
108 constexpr SkScalar kDesiredDurationSecs = 100.0f;
117 using INHERITED =
GM;
133 static constexpr SkScalar kIntervals[][2]{
146 static constexpr int kN =
std::size(kIntervals);
153 static constexpr SkRect kThinCircle = {-kThinRadius, -kThinRadius,
154 kThinRadius, kThinRadius};
155 static constexpr SkScalar kThinStrokeWidth = 0.4f;
159 for (
int i = 0;
i < kN; ++
i) {
162 SkScalar scaledIntervals[2] = {kCircumference * kIntervals[
i][0],
163 kCircumference * kIntervals[
i][1]};
165 scaledIntervals, 2, kCircumference * fPhaseDegrees * kTau / 360.f);
166 static constexpr SkScalar kThinCircumference = kThinRadius * kTau;
167 scaledIntervals[0] = kThinCircumference * kIntervals[
i][0];
168 scaledIntervals[1] = kThinCircumference * kIntervals[
i][1];
170 scaledIntervals, 2, kThinCircumference * fPhaseDegrees * kTau / 360.f);
183 SkMatrix::Concat(
SkMatrix::MakeAll(-1, 0, 0, 0, 1, 0, 0, 0, 1),
rotate),
188 paint.setAntiAlias(
true);
190 paint.setStroke(
true);
195 kThinStrokeWidth / 2.f);
196 for (
const auto&
m : kMatrices) {
198 m.mapRect(&devBounds, kBounds);
206 for (
const auto&
m : kMatrices) {
210 paint.setPathEffect(deffects[
i]);
214 paint.setPathEffect(thinDEffects[
i]);
215 paint.setStrokeWidth(kThinStrokeWidth);
229 fPhaseDegrees = 1
e-9 * nanos;
240 canvas->drawRect({0, 0, 1600, 1600},
SkPaint());
243 p.setAntiAlias(
true);
245 p.setStrokeWidth(380);
250 canvas->drawCircle(400, 400, 200,
p);
253 path.moveTo(800, 400);
254 path.quadTo(1000, 400, 1000, 600);
255 path.quadTo(1000, 800, 800, 800);
256 path.quadTo(600, 800, 600, 600);
257 path.quadTo(600, 400, 800, 400);
259 canvas->translate(350, 150);
260 p.setStrokeWidth(320);
261 canvas->drawPath(
path.detach(),
p);
263 path.moveTo(800, 400);
264 path.cubicTo(900, 400, 1000, 500, 1000, 600);
265 path.cubicTo(1000, 700, 900, 800, 800, 800);
266 path.cubicTo(700, 800, 600, 700, 600, 600);
267 path.cubicTo(600, 500, 700, 400, 800, 400);
269 canvas->translate(-550, 500);
270 p.setStrokeWidth(300);
271 canvas->drawPath(
path.detach(),
p);
constexpr SkColor SK_ColorRED
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
SkString getName() const override
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
bool onAnimate(double nanos) override
void onDraw(SkCanvas *canvas) override
bool onAnimate(double nanos) override
SkString getName() const override
SkISize getISize() override
void drawOval(const SkRect &oval, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void rotate(SkScalar degrees)
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
static const SkMatrix & I()
void setColor(SkColor color)
void setAntiAlias(bool aa)
void setStrokeWidth(SkScalar width)
SkPathBuilder & arcTo(const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
SkPathBuilder & moveTo(SkPoint pt)
static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
GM(SkColor backgroundColor=SK_ColorWHITE)
DEF_SIMPLE_GM(maddash, canvas, 1600, 1600)
struct DashExample dashExamples[]
Optional< SkRect > bounds
static float Scaled(float time, float speed, float period=0)
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
constexpr SkScalar kStrokeWidth
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeEmpty()
SkRect makeOutset(float dx, float dy) const
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)