Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: gm/addarc.cpp

Issue 912203002: add gm for stroked circles that are zoomed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (meas.getPosTan(arcLen, &pos, NULL)) { 104 if (meas.getPosTan(arcLen, &pos, NULL)) {
105 canvas->drawLine(0, 0, pos.x(), pos.y(), measPaint); 105 canvas->drawLine(0, 0, pos.x(), pos.y(), measPaint);
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 private: 110 private:
111 typedef skiagm::GM INHERITED; 111 typedef skiagm::GM INHERITED;
112 }; 112 };
113 DEF_GM( return new AddArcMeasGM; ) 113 DEF_GM( return new AddArcMeasGM; )
114
115 ///////////////////////////////////////////////////
116
117 // Emphasize drawing a stroked oval (containing conics) and then scaling the res ults up,
118 // to ensure that we compute the stroke taking the CTM into account
119 //
120 class StrokeCircleGM : public skiagm::GM {
121 public:
122 StrokeCircleGM() : fRotate(0) {}
123
124 protected:
125 SkString onShortName() SK_OVERRIDE { return SkString("strokecircle"); }
126
127 SkISize onISize() SK_OVERRIDE { return SkISize::Make(520, 520); }
128
129 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
130 canvas->scale(20, 20);
131 canvas->translate(13, 13);
132
133 SkPaint paint;
134 paint.setAntiAlias(true);
135 paint.setStyle(SkPaint::kStroke_Style);
136 paint.setStrokeWidth(SK_Scalar1 / 2);
137
138 const SkScalar delta = paint.getStrokeWidth() * 3 / 2;
139 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
140 SkRandom rand;
141
142 SkScalar sign = 1;
143 while (r.width() > paint.getStrokeWidth() * 2) {
144 SkAutoCanvasRestore acr(canvas, true);
145 canvas->rotate(fRotate * sign);
146
147 paint.setColor(rand.nextU() | (0xFF << 24));
148 canvas->drawOval(r, paint);
149 r.inset(delta, delta);
150 sign = -sign;
151 }
152 }
153
154 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
155 fRotate = timer.scaled(60, 360);
156 return true;
157 }
158
159 private:
160 SkScalar fRotate;
161
162 typedef skiagm::GM INHERITED;
163 };
164 DEF_GM( return new StrokeCircleGM; )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698