Flutter Engine
The Flutter Engine
Canvas_translate.cpp
Go to the documentation of this file.
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.
4REG_FIDDLE(Canvas_translate, 256, 128, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint filledPaint;
7 SkPaint outlinePaint;
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
REG_FIDDLE(Canvas_translate, 256, 128, false, 0)
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194