Flutter Engine
The Flutter Engine
shapes_with_motion.cpp
Go to the documentation of this file.
1// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE_ANIMATED(shapes_with_motion, 256, 256, false, 5, 4) {
5void draw(SkCanvas* canvas) {
6 //float p = 1 - fabs(2 * frame - 1);
7 float p = 0.5 * (1 - cos(6.28318548f * frame));
9
12 paint.setAntiAlias(true);
13 paint.setStrokeWidth(4);
14 paint.setColor(0xffFE938C);
15
16 SkRect rect = SkRect::MakeXYWH(10, 10, 100, 160);
17 canvas->drawRect(rect, paint);
18
20 oval.setOval(rect);
21 oval.offset(40, p * 80);
22 paint.setColor(0xffE6B89C);
23 canvas->drawRRect(oval, paint);
24
25 paint.setColor(0xff9CAFB7);
26 canvas->drawCircle(180 * p, 50, 25, paint);
27
28 rect.offset(80, 50);
29 paint.setColor(0xff4281A4);
31 canvas->drawRoundRect(rect, 10, 10, paint);
32}
33} // END FIDDLE
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
void drawRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint)
Definition: SkCanvas.cpp:2717
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
const Paint & paint
Definition: color_source.cc:38
double frame
Definition: examples.cpp:31
SkRect oval
Definition: SkRecords.h:249
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
REG_FIDDLE_ANIMATED(shapes_with_motion, 256, 256, false, 5, 4)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
void offset(float dx, float dy)
Definition: SkRect.h:1016