95 std::vector<std::unique_ptr<MMObject>>
fObjects;
104 return fStage->onChar(uni);
112 return fStage->animate(nanos);
122float time_counter_value(
double nanos,
float factor) {
123 constexpr double kMillisPerNano = 0.0000001;
124 return static_cast<float>(nanos*kMillisPerNano)/factor;
127float time_fractional_value(
double nanos,
float cycleLengthMs) {
135void canonicalize_angle(
float*
startAngle,
float* endAngle) {
139 *endAngle = *endAngle +
delta;
143float adjust_end_angle(
float startAngle,
float endAngle,
bool ccw) {
144 float newEndAngle = endAngle;
147 }
else if (ccw &&
startAngle - endAngle >= 360.f) {
176 0xffe01040, 0xff10c030, 0xff744cba, 0xffe05010
179 fLineWidth = std::pow(random->
nextF(), 12) * 20 + 3;
180 fOmega = random->
nextF() * 3 + 0.2f;
182 fCosTheta = std::cos(theta);
183 fSinTheta = std::sin(theta);
185 params.fCircleRadius * fSinTheta);
186 fLength =
params.fLineMinimum;
187 fLength += std::pow(random->
nextF(), 8) *
params.fLineLengthMaximum;
188 fSegmentDirection = random->
nextF() > 0.5 ? -1 : 1;
195 paint.setAntiAlias(
true);
196 paint.setColor(fColor);
197 paint.setStrokeWidth(fLineWidth);
201 fStart.
fX + fSegmentDirection * fLength * fCosTheta,
202 fStart.
fY + fSegmentDirection * fLength * fSinTheta
208 fLength += std::sin(time_counter_value(nanos, 100) * fOmega);
219 float fSegmentDirection;
245 float dx = fTwoFifthsSizeX * std::cos(fCurrentAngle);
246 float dy = fTwoFifthsSizeX * std::sin(fCurrentAngle);
248 float colorStopStep =
SkScalarInterp(-.1f, .1f, fCurrentGradientStep);
253 (brightnessStep << 1),
256 (brightnessStep << 1),
271 0.2f + colorStopStep,
272 0.8f - colorStopStep,
279 paint.setAntiAlias(
true);
280 paint.setStrokeWidth(15);
281 for (
int i = 0;
i < 4;
i++) {
282 const SkColor strokeColors[] = {
283 0xffe01040, 0xff10c030, 0xff744cba, 0xffe05010
286 0xff70051d, 0xff016112, 0xff2F0C6E, 0xff702701
288 paint.setColor(strokeColors[
i]);
295 paint.setColor(fillColors[
i]);
298 paint.setShader(gradientShader);
300 paint.setShader(
nullptr);
307 fCurrentAngle = time_fractional_value(nanos, 3000) *
SK_ScalarPI * 2;
308 fCurrentGradientStep = 0.5f + 0.5f * std::sin(
309 time_fractional_value(nanos, 5000) *
SK_ScalarPI * 2);
316 return std::make_unique<CanvasLineSegment>(&
fRandom,fParams);
321 float fTwoFifthsSizeX;
322 float fCurrentAngle = 0;
323 float fCurrentGradientStep = 0.5f;
333 constexpr float kMaxX = 6;
334 constexpr float kMaxY = 3;
336 const SkColor baseColors[3] = {
337 0xff101010, 0xff808080, 0xffc0c0c0
339 const SkColor bonusColors[3] = {
340 0xffe01040, 0xff10c030, 0xffe05010
343 float distanceY =
size.fHeight / (
kMaxY + 1);
347 fPoint =
SkPoint::Make(distanceX * (randX + (randY % 2) / 2), distanceY * (randY + 0.5f));
349 fRadius = 20 + std::pow(random->
nextF(), 5) * (
std::min(distanceX, distanceY) / 1.8f);
352 fOmega = (random->
nextF() - 0.5f) * 0.3f;
353 fCounterclockwise = random->
nextBool();
359 fColor = colorIndex == 3 ? bonusColor : baseColors[colorIndex];
360 fLineWidth = 1 + std::pow(random->
nextF(), 5) * 30;
368 paint.setAntiAlias(
true);
369 paint.setColor(fColor);
371 2*fRadius, 2*fRadius);
373 float startAngleDeg = fStartAngle * 180.f /
SK_ScalarPI;
374 float endAngleDeg = fEndAngle * 180.f /
SK_ScalarPI;
375 canonicalize_angle(&startAngleDeg, &endAngleDeg);
376 endAngleDeg = adjust_end_angle(startAngleDeg, endAngleDeg, fCounterclockwise);
378 float sweepAngle = startAngleDeg - endAngleDeg;
381 paint.setStrokeWidth(fLineWidth);
393 fStartAngle += fOmega;
394 fEndAngle += fOmega / 2;
405 bool fCounterclockwise;
435 const SkSize kGridSize = { 80, 40 };
436 const SkPoint kGridCenter = { 40, 20 };
444 SkPoint coordinate = prevCoord ? *prevCoord : kGridCenter;
448 if (coordinate.
fX < 0 || coordinate.
fX > kGridSize.
width())
450 if (coordinate.
fY < 0 || coordinate.
fY > kGridSize.
height())
455 (coordinate.
fY + 0.5f) *
size.height() / (kGridSize.
height() + 1));
456 fCoordinate = coordinate;
462 0xff101010, 0xff808080, 0xffc0c0c0, 0xff101010, 0xff808080, 0xffc0c0c0, 0xffe01040
466 fWidth = std::pow(random->
nextF(), 5) * 20 + 1;
475 path->lineTo(fPoint);
549 return std::make_unique<CanvasQuadraticSegment>(random,
size,
prev);
552 return std::make_unique<CanvasBezierSegment>(random,
size,
prev);
557 return std::make_unique<CanvasLinePoint>(random,
size,
prev);
576 paint.setAntiAlias(
true);
585 object->append(¤tPath);
597 object->toggleIsSplit();
634 return random->
nextRangeF(maxVelocity/8, maxVelocity);
641 , fRotateInterval(rotateInterval) {}
644 fTimeDelta =
SkScalarMod(fTimeDelta + timeDelta, fRotateInterval);
648 return (360 * fTimeDelta) / fRotateInterval;
653 float fRotateInterval;
668 ,
fSize(particleSize)
679 constexpr double kMillisPerNano = 0.0000001;
805 const char* kImageSrcs[kImageCount] = {
808 "images/color_wheel.jpg",
809 "images/mandrill_512_q075.jpg",
810 "images/gainmap_iso21496_1.jpg",
814#if defined(SK_GRAPHITE)
818 for (
int i = 0;
i < kImageCount; ++
i) {
822#if defined(SK_GRAPHITE)
824 fImages[
i] = lazyYUV->refImage(recorder,
829 fImages[
i] = lazyYUV->refImage(rContext,
836 if (fNeedToInitImages) {
838 fNeedToInitImages =
false;
862 fNeedToInitImages =
true;
866 static constexpr int kImageCount = 5;
868 bool fNeedToInitImages =
true;
SkPoint point_on_circle(float angle, float radius)
SkPoint random_position(SkRandom *random, SkSize maxPosition)
Rotater random_rotater(SkRandom *random)
std::unique_ptr< CanvasLinePoint > make_line_path(SkRandom *random, SkSize size, SkPoint *prev)
float random_angle(SkRandom *random)
float random_velocity(SkRandom *random, float maxVelocity)
static float prev(float f)
sk_sp< SkData > GetResourceAsData(const char *resource)
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorWHITE
#define sk_float_ceil2int(x)
constexpr float SK_FloatPI
#define SkScalarMod(x, y)
#define SkScalarSin(radians)
#define SkScalarRoundToInt(x)
#define SkScalarCos(radians)
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
static SkScalar SkScalarFraction(SkScalar x)
BouncingParticle(SkRandom *random, SkSize stageSize, SkSize particleSize, float maxVelocity)
void animate(double deltaNanos) override
bool animate(double nanos) override
BouncingParticlesStage(SkSize size)
void draw(SkCanvas *canvas) override
const SkMatrix & transform()
BouncingTaggedImage(SkRandom *random, SkSize stageSize, SkSize particleSize, float maxVelocity)
void animate(double deltaNanos) override
void load(SkScalar w, SkScalar h) override
BouncingTaggedImagesSlide()
void gpuTeardown() override
void initImages(SkCanvas *canvas)
~BouncingTaggedImagesStage() override=default
std::unique_ptr< MMObject > createObject() override
void draw(SkCanvas *canvas) override
BouncingTaggedImagesStage(SkSize size)
std::unique_ptr< MMObject > createObject() override
CanvasArcStage(SkSize size)
~CanvasArcStage() override=default
void draw(SkCanvas *canvas) override
void animate(double) override
CanvasArc(SkRandom *random, SkSize size)
void draw(SkCanvas *canvas) override
~CanvasArc() override=default
void load(SkScalar w, SkScalar h) override
CanvasBezierSegment(SkRandom *random, SkSize size, SkPoint *prev)
void append(SkPath *path) override
bool animate(double) override
std::unique_ptr< MMObject > createObject() override
CanvasLinePathStage(SkSize size)
~CanvasLinePathStage() override=default
void draw(SkCanvas *canvas) override
virtual void append(SkPath *path)
CanvasLinePoint(SkRandom *random, SkSize size, SkPoint *prev)
~CanvasLinePoint() override=default
void animate(double) override
void draw(SkCanvas *) override
void setEndPoint(SkRandom *random, SkSize size, SkPoint *prevCoord)
bool animate(double nanos) override
void draw(SkCanvas *canvas) override
CanvasLineSegmentStage(SkSize size)
std::unique_ptr< MMObject > createObject() override
~CanvasLineSegmentStage() override=default
~CanvasLineSegment() override=default
void draw(SkCanvas *canvas) override
void animate(double nanos) override
CanvasLineSegment(SkRandom *random, const LineSegmentParams ¶ms)
void load(SkScalar w, SkScalar h) override
void append(SkPath *path) override
CanvasQuadraticSegment(SkRandom *random, SkSize size, SkPoint *prev)
virtual void animate(double)=0
virtual void draw(SkCanvas *canvas)=0
virtual ~MMObject()=default
std::unique_ptr< Stage > fStage
bool onChar(SkUnichar uni) override
MotionMarkSlide()=default
void draw(SkCanvas *canvas) override
bool animate(double nanos) override
void load(SkScalar w, SkScalar h) override
Rotater(float rotateInterval)
void next(float timeDelta)
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void clear(SkColor color)
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & setTranslateY(SkScalar v)
static SkMatrix RotateDeg(SkScalar deg)
SkMatrix & setTranslateX(SkScalar v)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
SkPath & moveTo(SkScalar x, SkScalar y)
float nextRangeF(float min, float max)
uint32_t nextRangeU(uint32_t min, uint32_t max)
virtual void draw(SkCanvas *canvas)
virtual bool animate(double nanos)
std::vector< std::unique_ptr< MMObject > > fObjects
virtual bool onChar(SkUnichar uni)
virtual std::unique_ptr< MMObject > createObject()=0
Stage(SkSize size, int startingObjectCount, int objectIncrement)
static std::unique_ptr< LazyYUVImage > Make(sk_sp< SkData > data, skgpu::Mipmapped=skgpu::Mipmapped::kNo, sk_sp< SkColorSpace >=nullptr)
const EmbeddedViewParams * params
static float min(float r, float g, float b)
PODArray< SkColor > colors
SkSamplingOptions sampling
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
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
SIN Vec< N, float > floor(const Vec< N, float > &x)
SkPoint fCircleCenters[4]
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
void offset(float dx, float dy)
static constexpr SkRect MakeSize(const SkSize &size)
static constexpr SkSize Make(SkScalar w, SkScalar h)