Flutter Engine
The Flutter Engine
DegenerateTwoPtRadialsSlide.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
13#include "tools/viewer/Slide.h"
14
15static void draw_gradient2(SkCanvas* canvas, const SkRect& rect, SkScalar delta) {
17 SkScalar pos[] = { 0, 0.25f, 0.75f, SK_Scalar1 };
18
19 SkScalar l = rect.fLeft;
20 SkScalar t = rect.fTop;
21 SkScalar w = rect.width();
22 SkScalar h = rect.height();
23
24 SkASSERT(0 == SkScalarMod(w, SK_Scalar1 * 5));
25
26 SkPoint c0 = { l + 2 * w / 5 + delta, t + h / 2 };
27 SkPoint c1 = { l + 3 * w / 5, t + h / 2 };
28 SkScalar r0 = w / 5;
29 SkScalar r1 = 2 * w / 5;
31 paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
34 canvas->drawRect(rect, paint);
35}
36
37
39public:
40 DegenerateTwoPtRadialsSlide() { fName = "DegenerateTwoPtRadials"; }
41
42 void draw(SkCanvas* canvas) override {
43 canvas->clear(0xFFDDDDDD);
44 SkScalar delta = fTime / 15.f;
45 int intPart = SkScalarFloorToInt(delta);
46 delta = delta - SK_Scalar1 * intPart;
47 if (intPart % 2) {
49 }
51 static const int DELTA_SCALE = 500;
52 delta /= DELTA_SCALE;
53
54 SkScalar w = SK_Scalar1 * 500;
55 SkScalar h = SK_Scalar1 * 500;
56 SkScalar l = SK_Scalar1 * 100;
57 SkScalar t = SK_Scalar1 * 100;
58 draw_gradient2(canvas, SkRect::MakeXYWH(l, t, w, h), delta);
60 txt.appendf("gap at \"tangent\" pt = %f", delta);
61 canvas->drawString(txt,
62 l + w / 2 + w * DELTA_SCALE * delta,
63 t + h + SK_Scalar1 * 10,
65 SkPaint());
66 }
67
68 bool animate(double nanos) override {
69 fTime = SkDoubleToScalar(1e-9 * nanos / 15);
70 return true;
71 }
72
73private:
74 SkScalar fTime;
75};
76
77//////////////////////////////////////////////////////////////////////////////
78
static void draw_gradient2(SkCanvas *canvas, const SkRect &rect, SkScalar delta)
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define SkScalarMod(x, y)
Definition: SkScalar.h:41
#define SK_Scalar1
Definition: SkScalar.h:18
#define SK_ScalarHalf
Definition: SkScalar.h:19
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
#define DEF_SLIDE(code)
Definition: Slide.h:25
void draw(SkCanvas *canvas) override
bool animate(double nanos) override
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
Definition: Slide.h:29
SkString fName
Definition: Slide.h:54
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkFont DefaultFont()
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
Definition: switches.h:259
SkScalar w
SkScalar h
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659