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

Side by Side Diff: site/user/api/skcanvas.md

Issue 1228063002: doc: more changes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-07-09 (Thursday) 09:56:30 EDT Created 5 years, 5 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 | site/user/tips.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 SkCanvas 1 SkCanvas
2 ======== 2 ========
3 3
4 *The drawing context* 4 *The drawing context*
5 5
6 <!-- Updated Mar 4, 2011 --> 6 <!-- Updated Mar 4, 2011 -->
7 7
8 Preview 8 Preview
9 ------- 9 -------
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 a stack of matrices and clips. Note however, that unlike similar 43 a stack of matrices and clips. Note however, that unlike similar
44 contexts in other APIs like postscript, cairo, or awt, Skia does not 44 contexts in other APIs like postscript, cairo, or awt, Skia does not
45 store any other drawing attributes in the context (e.g. color, pen 45 store any other drawing attributes in the context (e.g. color, pen
46 size). Rather, these are specified explicitly in each draw call, via a 46 size). Rather, these are specified explicitly in each draw call, via a
47 SkPaint. 47 SkPaint.
48 48
49 <!--?prettify lang=cc?--> 49 <!--?prettify lang=cc?-->
50 50
51 void draw(SkCanvas* canvas) { 51 void draw(SkCanvas* canvas) {
52 canvas->save(); 52 canvas->save();
53 canvas->translate(SkIntToScalar(128), SkIntToScalar(128));
53 canvas->rotate(SkIntToScalar(45)); 54 canvas->rotate(SkIntToScalar(45));
54 SkRect rect = SkRect::MakeXYWH(150, -50, 100, 100); 55 SkRect rect = SkRect::MakeXYWH(-90.5f, -90.5f, 181.0f, 181.0f);
55 SkPaint paint; 56 SkPaint paint;
57 paint.setColor(SK_ColorBLUE);
56 canvas->drawRect(rect, paint); 58 canvas->drawRect(rect, paint);
57 canvas->restore(); 59 canvas->restore();
58 } 60 }
59 61
60 <a href="https://fiddle.skia.org/c/71f2e87df2be1cdbc44139ee3e2790eb"> 62 <a href="https://fiddle.skia.org/c/6af99894b40ea1331f6a79d55a4cbfd7">
61 <img src="https://fiddle.skia.org/i/71f2e87df2be1cdbc44139ee3e2790eb_raster.png" ></a> 63 <img src="https://fiddle.skia.org/i/6af99894b40ea1331f6a79d55a4cbfd7_raster.png" ></a>
62 64
63 The code above will draw a rectangle rotated by 45 degrees. Exactly 65 The code above will draw a rectangle rotated by 45 degrees. Exactly
64 what color and style the rect will be drawn in is described by the 66 what color and style the rect will be drawn in is described by the
65 paint, not the canvas. 67 paint, not the canvas.
66 68
67 Check out more detailed info on [creating a SkCanvas object](canvas). 69 Check out more detailed info on [creating a SkCanvas object](canvas).
68 70
69 To begin with, we might want to erase the entire canvas. We can do 71 To begin with, we might want to erase the entire canvas. We can do
70 this by drawing an enormous rectangle, but there are easier ways to do 72 this by drawing an enormous rectangle, but there are easier ways to do
71 it. 73 it.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 140 }
139 141
140 <a href="https://fiddle.skia.org/c/35b614d41e60289461d658a9d509e28d"> 142 <a href="https://fiddle.skia.org/c/35b614d41e60289461d658a9d509e28d">
141 <img src="https://fiddle.skia.org/i/35b614d41e60289461d658a9d509e28d_raster.png" ></a> 143 <img src="https://fiddle.skia.org/i/35b614d41e60289461d658a9d509e28d_raster.png" ></a>
142 144
143 In some of the calls, we pass a pointer, rather than a reference, to 145 In some of the calls, we pass a pointer, rather than a reference, to
144 the paint. In those instances, the paint parameter may be null. In all 146 the paint. In those instances, the paint parameter may be null. In all
145 other cases the paint parameter is required. 147 other cases the paint parameter is required.
146 148
147 Next: [SkPaint](/user/api/skpaint) 149 Next: [SkPaint](/user/api/skpaint)
OLDNEW
« no previous file with comments | « no previous file | site/user/tips.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698