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(example3ps, 320, 256, false, 0) {
5 static SkMatrix setpsmatrix(float sx, float kx, float ky, float sy, float tx, float ty, int h) {
8 m.setAll(sx, -kx, -tx * sx - (ty - h) * kx, -ky, sy, (ty - h) * sy + tx * ky, 0, 0, 1);
12 void draw(SkCanvas* canvas) {
14 canvas->scale(15, -15);
15 canvas->translate(0, -28);
25 p.setStrokeWidth(0.1f);
28 canvas->translate(0, 18);
29 p.setColor(SK_ColorGRAY);
30 canvas->drawPath(path, p);
33 p.setStyle(SkPaint::kStroke_Style);
35 canvas->translate(8, 19);
37 p.setColor(SK_ColorRED);
38 canvas->drawPath(path, p);
42 canvas->translate(5, 23);
44 p.setColor(SK_ColorBLUE);
45 canvas->drawPath(path, p);
49 canvas->translate(14, 18);
51 p.setColor(0xFF007F00);
52 canvas->drawPath(path, p);
56 canvas->scale(15, 15);
57 canvas->translate(0, 24);
60 unsigned char d[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff};
61 sk_sp<SkData> data = SkData::MakeWithoutCopy((unsigned char*)d, sizeof(d));
63 SkImageInfo::Make(3, 2, SkColorType::kGray_8_SkColorType, kOpaque_SkAlphaType);
64 sk_sp<SkImage> image = SkImage::MakeRasterData(info, data, 3);
67 m = setpsmatrix(1, 0, 0, 1, -1, -24, 2);
68 // m.setAll(1, 0, -1, 0, 1, -24, 0, 0, 1);
70 canvas->drawImage(image, 0, 0);
74 m = setpsmatrix(0, 1, 1, 0, -24, -5, 2);
75 // m.setAll(0, -1, 5, -1, 0, -22, 0, 0, 1);
77 canvas->drawImage(image, 0, 0);
81 m = setpsmatrix(0, 1, -1, 0, 27, -8, 2);
82 // m.setAll(0, -1, 8, 1, 0, -25, 0, 0, 1);
84 canvas->drawImage(image, 0, 0);
88 m = setpsmatrix(0, -1, -1, 0, -24, 13, 2);
89 // m.setAll(0, 1, 9, -1, 0, -22, 0, 0, 1);
91 canvas->drawImage(image, 0, 0);
95 m = setpsmatrix(-1, 0, 0, -1, 17, 26, 2);
96 // m.setAll(-1, 0, 15, 0, -1, -22, 0, 0, 1);
98 canvas->drawImage(image, 0, 0);
102 m = setpsmatrix(-1, 0, 0, 1, 21, -24, 2);
103 // m.setAll(-1, 0, 19, 0, 1, -24, 0, 0, 1);
105 canvas->drawImage(image, 0, 0);