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

Side by Side Diff: sky/sdk/example/game/lib/sprite.dart

Issue 1217933002: Rename RenderCanvas to PaintingCanvas to avoid confusion with other classes that inherit from Rende… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « sky/sdk/example/game/lib/node_with_size.dart ('k') | sky/sdk/example/game/lib/sprite_box.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of sprites; 1 part of sprites;
2 2
3 /// A Sprite is a [Node] that renders a bitmap image to the screen. 3 /// A Sprite is a [Node] that renders a bitmap image to the screen.
4 class Sprite extends NodeWithSize { 4 class Sprite extends NodeWithSize {
5 5
6 /// The texture that the sprite will render to screen. 6 /// The texture that the sprite will render to screen.
7 /// 7 ///
8 /// If the texture is null, the sprite will be rendered as a red square 8 /// If the texture is null, the sprite will be rendered as a red square
9 /// marking the bounds of the sprite. 9 /// marking the bounds of the sprite.
10 /// 10 ///
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 /// 57 ///
58 /// mySprite.opacity = 0.5; 58 /// mySprite.opacity = 0.5;
59 double get opacity => _opacity; 59 double get opacity => _opacity;
60 60
61 void set opacity(double opacity) { 61 void set opacity(double opacity) {
62 assert(opacity != null); 62 assert(opacity != null);
63 assert(opacity >= 0.0 && opacity <= 1.0); 63 assert(opacity >= 0.0 && opacity <= 1.0);
64 _opacity = opacity; 64 _opacity = opacity;
65 } 65 }
66 66
67 void paint(RenderCanvas canvas) { 67 void paint(PaintingCanvas canvas) {
68 canvas.save(); 68 canvas.save();
69 69
70 // Account for pivot point 70 // Account for pivot point
71 applyTransformForPivot(canvas); 71 applyTransformForPivot(canvas);
72 72
73 if (texture != null) { 73 if (texture != null) {
74 double w = texture.size.width; 74 double w = texture.size.width;
75 double h = texture.size.height; 75 double h = texture.size.height;
76 76
77 if (w <= 0 || h <= 0) return; 77 if (w <= 0 || h <= 0) return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 canvas.drawImageRect(texture.image, texture.frame, texture.spriteSourceS ize, paint); 120 canvas.drawImageRect(texture.image, texture.frame, texture.spriteSourceS ize, paint);
121 } 121 }
122 } else { 122 } else {
123 // Paint a red square for missing texture 123 // Paint a red square for missing texture
124 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height), 124 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height),
125 new Paint()..color = const Color.fromARGB(255, 255, 0, 0)); 125 new Paint()..color = const Color.fromARGB(255, 255, 0, 0));
126 } 126 }
127 canvas.restore(); 127 canvas.restore();
128 } 128 }
129 } 129 }
OLDNEW
« no previous file with comments | « sky/sdk/example/game/lib/node_with_size.dart ('k') | sky/sdk/example/game/lib/sprite_box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698