| 1 |
// Copyright 2019 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(Canvas_translate, 256, 128, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkPaint filledPaint; |
| 7 |
SkPaint outlinePaint; |
| 8 |
outlinePaint.setStyle(SkPaint::kStroke_Style); |
| 9 |
outlinePaint.setColor(SK_ColorBLUE); |
| 10 |
canvas->save(); |
| 11 |
canvas->translate(50, 50); |
| 12 |
canvas->drawCircle(28, 28, 15, outlinePaint); // blue center: (50+28, 50+28) |
| 13 |
canvas->scale(2, 1/2.f); |
| 14 |
canvas->drawCircle(28, 28, 15, filledPaint); // black center: (50+(28*2), 50+(28/2)) |
| 15 |
canvas->restore(); |
| 16 |
filledPaint.setColor(SK_ColorGRAY); |
| 17 |
outlinePaint.setColor(SK_ColorRED); |
| 18 |
canvas->scale(2, 1/2.f); |
| 19 |
canvas->drawCircle(28, 28, 15, outlinePaint); // red center: (28*2, 28/2) |
| 20 |
canvas->translate(50, 50); |
| 21 |
canvas->drawCircle(28, 28, 15, filledPaint); // gray center: ((50+28)*2, (50+28)/2) |
| 22 |
} |
| 23 |
} // END FIDDLE |