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

Side by Side Diff: gm/addarc.cpp

Issue 2409983004: Correct a small mistake in SkPath::build_arc_conics (Closed)
Patch Set: undo changes to canvas->translate Created 4 years, 2 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 | src/core/SkPath.cpp » ('j') | 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 SkISize onISize() override { return SkISize::Make(620, 330); } 298 SkISize onISize() override { return SkISize::Make(620, 330); }
299 299
300 void onDraw(SkCanvas* canvas) override { 300 void onDraw(SkCanvas* canvas) override {
301 SkPaint paint; 301 SkPaint paint;
302 paint.setAntiAlias(true); 302 paint.setAntiAlias(true);
303 paint.setStyle(SkPaint::kStroke_Style); 303 paint.setStyle(SkPaint::kStroke_Style);
304 304
305 canvas->translate(50, 50); 305 canvas->translate(50, 50);
306 306
307 SkPath path; 307 SkScalar outerRadius = 100000.0f;
308 path.moveTo(50, 20); 308 SkScalar innerRadius = outerRadius - 20.0f;
309 path.lineTo(50, 0); 309 SkScalar centerX = 50;
310 // A combination of tiny sweepAngle + large radius, we should draw a lin e. 310 SkScalar centerY = outerRadius;
311 html_canvas_arc(&path, 50, 100000, 100000, 270, 270.0f - 0.00572957795f, 311 SkScalar startAngles[] = { 1.5f * SK_ScalarPI , 1.501f * SK_ScalarPI };
312 false, true); 312 SkScalar sweepAngle = 10.0f / outerRadius;
313 path.lineTo(60, 20); 313
314 html_canvas_arc(&path, 50, 100000, 99980, 270.0f - 0.00572957795f, 270, 314 for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles); ++i) {
315 false, false); 315 SkPath path;
316 canvas->drawPath(path, paint); 316 SkScalar endAngle = startAngles[i] + sweepAngle;
317 path.moveTo(centerX + innerRadius * sk_float_cos(startAngles[i]),
318 centerY + innerRadius * sk_float_sin(startAngles[i]));
319 path.lineTo(centerX + outerRadius * sk_float_cos(startAngles[i]),
320 centerY + outerRadius * sk_float_sin(startAngles[i]));
321 // A combination of tiny sweepAngle + large radius, we should draw a line.
322 html_canvas_arc(&path, centerX, outerRadius, outerRadius,
323 startAngles[i] * 180 / SK_ScalarPI, endAngle * 180 / SK_ScalarPI,
324 true, true);
325 path.lineTo(centerX + innerRadius * sk_float_cos(endAngle),
326 centerY + innerRadius * sk_float_sin(endAngle));
327 html_canvas_arc(&path, centerX, outerRadius, innerRadius,
328 endAngle * 180 / SK_ScalarPI, startAngles[i] * 180 / SK_ScalarPI,
329 true, false);
330 canvas->drawPath(path, paint);
331 canvas->translate(20, 0);
332 }
317 } 333 }
318 334
319 private: 335 private:
320 typedef skiagm::GM INHERITED; 336 typedef skiagm::GM INHERITED;
321 }; 337 };
322 DEF_GM( return new TinyAngleBigRadiusArcsGM; ) 338 DEF_GM( return new TinyAngleBigRadiusArcsGM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698