Hal Canary | 8800042 | 2020-01-15 11:51:12 -0500 | [diff] [blame] | 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. |
| 3 | #include "tools/fiddle/examples.h" |
| 4 | REG_FIDDLE_ANIMATED(shapes_with_motion, 256, 256, false, 5, 4) { |
| 5 | void draw(SkCanvas* canvas) { |
| 6 | //float p = 1 - fabs(2 * frame - 1); |
| 7 | float p = 0.5 * (1 - cos(6.28318548f * frame)); |
| 8 | canvas->drawColor(SK_ColorWHITE); |
| 9 | |
| 10 | SkPaint paint; |
| 11 | paint.setStyle(SkPaint::kFill_Style); |
| 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 | |
| 19 | SkRRect oval; |
| 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); |
| 30 | paint.setStyle(SkPaint::kStroke_Style); |
| 31 | canvas->drawRoundRect(rect, 10, 10, paint); |
| 32 | } |
| 33 | } // END FIDDLE |