halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
| 8 | // This is an example of the translation unit that needs to be |
| 9 | // assembled by the fiddler program to compile into a fiddle: an |
| 10 | // implementation of the GetDrawOptions() and draw() functions. |
| 11 | |
| 12 | #include "fiddle_main.h" |
| 13 | DrawOptions GetDrawOptions() { |
| 14 | // path *should* be absolute. |
mtklein | 5dbd274 | 2016-08-02 11:13:48 -0700 | [diff] [blame] | 15 | static const char path[] = "resources/color_wheel.png"; |
Joe Gregorio | 1fd1823 | 2017-02-13 11:39:43 -0500 | [diff] [blame] | 16 | return DrawOptions(256, 256, true, true, true, true, true, false, false, path); |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 17 | } |
| 18 | void draw(SkCanvas* canvas) { |
| 19 | canvas->clear(SK_ColorWHITE); |
| 20 | SkMatrix matrix; |
| 21 | matrix.setScale(0.75f, 0.75f); |
Joe Gregorio | 1e735c0 | 2017-04-19 14:05:14 -0400 | [diff] [blame] | 22 | matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s. |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 23 | SkPaint paint; |
halcanary | d096459 | 2016-03-25 11:29:34 -0700 | [diff] [blame] | 24 | paint.setShader(image->makeShader(SkShader::kRepeat_TileMode, |
| 25 | SkShader::kRepeat_TileMode, |
| 26 | &matrix)); |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 27 | canvas->drawPaint(paint); |
Joe Gregorio | 1fd1823 | 2017-02-13 11:39:43 -0500 | [diff] [blame] | 28 | SkDebugf("This is text output: %d", 2); |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 29 | } |