Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
CanvasLineSegmentStage Class Reference
Inheritance diagram for CanvasLineSegmentStage:
Stage

Public Member Functions

 CanvasLineSegmentStage (SkSize size)
 
 ~CanvasLineSegmentStage () override=default
 
void draw (SkCanvas *canvas) override
 
bool animate (double nanos) override
 
std::unique_ptr< MMObjectcreateObject () override
 
- Public Member Functions inherited from Stage
 Stage (SkSize size, int startingObjectCount, int objectIncrement)
 
virtual ~Stage ()=default
 
virtual void draw (SkCanvas *canvas)
 
virtual bool animate (double nanos)
 
virtual bool onChar (SkUnichar uni)
 

Additional Inherited Members

- Protected Member Functions inherited from Stage
virtual std::unique_ptr< MMObjectcreateObject ()=0
 
void initializeObjects ()
 
- Protected Attributes inherited from Stage
SkSize fSize
 
int fStartingObjectCount
 
int fObjectIncrement
 
std::vector< std::unique_ptr< MMObject > > fObjects
 
SkRandom fRandom
 

Detailed Description

Definition at line 222 of file MotionMarkSlide.cpp.

Constructor & Destructor Documentation

◆ CanvasLineSegmentStage()

CanvasLineSegmentStage::CanvasLineSegmentStage ( SkSize  size)
inline

Definition at line 224 of file MotionMarkSlide.cpp.

225 : Stage(size, /*startingObjectCount=*/5000, /*objectIncrement*/1000) {
226 fParams.fLineMinimum = 20;
227 fParams.fLineLengthMaximum = 40;
228 fParams.fCircleRadius = fSize.fWidth/8 - .4 * (fParams.fLineMinimum +
229 fParams.fLineLengthMaximum);
230 fParams.fCircleCenters[0] = SkPoint::Make(5.5 / 32 * fSize.fWidth, 2.1 / 3*fSize.fHeight);
231 fParams.fCircleCenters[1] = SkPoint::Make(12.5 / 32 * fSize.fWidth, .9 / 3*fSize.fHeight);
232 fParams.fCircleCenters[2] = SkPoint::Make(19.5 / 32 * fSize.fWidth, 2.1 / 3*fSize.fHeight);
233 fParams.fCircleCenters[3] = SkPoint::Make(26.5 / 32 * fSize.fWidth, .9 / 3*fSize.fHeight);
234 fHalfSize = SkSize::Make(fSize.fWidth * 0.5f, fSize.fHeight * 0.5f);
235 fTwoFifthsSizeX = fSize.fWidth * .4;
236
237 this->initializeObjects();
238 }
SkSize fSize
void initializeObjects()
Stage(SkSize size, int startingObjectCount, int objectIncrement)
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
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
static constexpr SkSize Make(SkScalar w, SkScalar h)
Definition: SkSize.h:56
SkScalar fHeight
Definition: SkSize.h:54
SkScalar fWidth
Definition: SkSize.h:53

◆ ~CanvasLineSegmentStage()

CanvasLineSegmentStage::~CanvasLineSegmentStage ( )
overridedefault

Member Function Documentation

◆ animate()

bool CanvasLineSegmentStage::animate ( double  nanos)
inlineoverridevirtual

Reimplemented from Stage.

Definition at line 306 of file MotionMarkSlide.cpp.

306 {
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);
310
311 this->Stage::animate(nanos);
312 return true;
313 }
#define SK_ScalarPI
Definition: SkScalar.h:21
virtual bool animate(double nanos)

◆ createObject()

std::unique_ptr< MMObject > CanvasLineSegmentStage::createObject ( )
inlineoverridevirtual

Implements Stage.

Definition at line 315 of file MotionMarkSlide.cpp.

315 {
316 return std::make_unique<CanvasLineSegment>(&fRandom,fParams);
317 }
SkRandom fRandom

◆ draw()

void CanvasLineSegmentStage::draw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from Stage.

Definition at line 242 of file MotionMarkSlide.cpp.

242 {
243 canvas->clear(SK_ColorWHITE);
244
245 float dx = fTwoFifthsSizeX * std::cos(fCurrentAngle);
246 float dy = fTwoFifthsSizeX * std::sin(fCurrentAngle);
247
248 float colorStopStep = SkScalarInterp(-.1f, .1f, fCurrentGradientStep);
249 int brightnessStep = SkScalarRoundToInt(SkScalarInterp(32, 64, fCurrentGradientStep));
250
251 SkColor color1Step = SkColorSetARGB(brightnessStep,
252 brightnessStep,
253 (brightnessStep << 1),
254 102);
255 SkColor color2Step = SkColorSetARGB((brightnessStep << 1),
256 (brightnessStep << 1),
257 brightnessStep,
258 102);
259 SkPoint pts[2] = {
260 {fHalfSize.fWidth + dx, fHalfSize.fHeight + dy},
261 {fHalfSize.fWidth - dx, fHalfSize.fHeight - dy}
262 };
263 SkColor colors[] = {
264 color1Step,
265 color1Step,
266 color2Step,
267 color2Step
268 };
269 float pos[] = {
270 0,
271 0.2f + colorStopStep,
272 0.8f - colorStopStep,
273 1
274 };
275 sk_sp<SkShader> gradientShader = SkGradientShader::MakeLinear(pts, colors, pos, 4,
277
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
284 };
285 const SkColor fillColors[] = {
286 0xff70051d, 0xff016112, 0xff2F0C6E, 0xff702701
287 };
288 paint.setColor(strokeColors[i]);
290 SkRect arcRect = SkRect::MakeXYWH(fParams.fCircleCenters[i].fX - fParams.fCircleRadius,
291 fParams.fCircleCenters[i].fY- fParams.fCircleRadius,
292 2*fParams.fCircleRadius,
293 2*fParams.fCircleRadius);
294 canvas->drawArc(arcRect, 0, 360, false, paint);
295 paint.setColor(fillColors[i]);
296 paint.setStyle(SkPaint::kFill_Style);
297 canvas->drawArc(arcRect, 0, 360, false, paint);
298 paint.setShader(gradientShader);
299 canvas->drawArc(arcRect, 0, 360, false, paint);
300 paint.setShader(nullptr);
301 }
302
303 this->Stage::draw(canvas);
304 }
SkPoint pos
uint32_t SkColor
Definition: SkColor.h:37
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
Definition: SkScalar.h:131
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition: SkCanvas.cpp:2728
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)
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
virtual void draw(SkCanvas *canvas)
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

The documentation for this class was generated from the following file: