| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
| 8 #include "SkView.h" | 8 #include "SkView.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 p.setStyle(SkPaint::kStroke_Style); | 30 p.setStyle(SkPaint::kStroke_Style); |
| 31 | 31 |
| 32 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); | 32 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); |
| 33 | 33 |
| 34 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; | 34 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; |
| 35 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; | 35 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; |
| 36 p.setShader(SkGradientShader::MakeSweep(r.centerX(), r.centerY(), | 36 p.setShader(SkGradientShader::MakeSweep(r.centerX(), r.centerY(), |
| 37 colors, nullptr, SK_ARRAY_COUNT(colo
rs))); | 37 colors, nullptr, SK_ARRAY_COUNT(colo
rs))); |
| 38 | 38 |
| 39 SkAutoCanvasRestore acr(c, true); | 39 SkAutoCanvasRestore acr(c, true); |
| 40 | 40 c->rotate(angle, r.centerX(), r.centerY()); |
| 41 c->translate(r.centerX(), r.centerY()); | |
| 42 c->rotate(angle); | |
| 43 c->translate(-r.centerX(), -r.centerY()); | |
| 44 | 41 |
| 45 SkRect bounds = r; | 42 SkRect bounds = r; |
| 46 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); | 43 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); |
| 47 SkRect innerBounds = r; | 44 SkRect innerBounds = r; |
| 48 | 45 |
| 49 if (true) { | 46 if (true) { |
| 50 c->drawOval(r, p); | 47 c->drawOval(r, p); |
| 51 } else { | 48 } else { |
| 52 SkScalar x = r.centerX(); | 49 SkScalar x = r.centerX(); |
| 53 SkScalar y = r.centerY(); | 50 SkScalar y = r.centerY(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 164 } |
| 168 | 165 |
| 169 private: | 166 private: |
| 170 typedef SampleView INHERITED; | 167 typedef SampleView INHERITED; |
| 171 }; | 168 }; |
| 172 | 169 |
| 173 ////////////////////////////////////////////////////////////////////////////// | 170 ////////////////////////////////////////////////////////////////////////////// |
| 174 | 171 |
| 175 static SkView* MyFactory() { return new DitherView; } | 172 static SkView* MyFactory() { return new DitherView; } |
| 176 static SkViewRegister reg(MyFactory); | 173 static SkViewRegister reg(MyFactory); |
| OLD | NEW |