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

Side by Side Diff: sky/examples/game/lib/sprite.dart

Issue 1179333002: Playable demo game and bug fixes in sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 part of sprites; 1 part of sprites;
2 2
3 // TODO: Actually draw images 3 // TODO: Actually draw images
4 4
5 class Sprite extends NodeWithSize { 5 class Sprite extends NodeWithSize {
6 6
7 Image _image; 7 Image _image;
8 bool constrainProportions = false; 8 bool constrainProportions = false;
9 double _opacity = 1.0; 9 double _opacity = 1.0;
10 Color colorOverlay; 10 Color colorOverlay;
11 TransferMode transferMode; 11 TransferMode transferMode;
12 12
13 Sprite() { 13 Sprite() {
14 } 14 }
15 15
16 Sprite.withImage(Image image) { 16 Sprite.withImage(Image image) {
17 this.pivot = new Point(0.5, 0.5); 17 pivot = new Point(0.5, 0.5);
18 this.size = new Size(image.width.toDouble(), image.height.toDouble()); 18 size = new Size(image.width.toDouble(), image.height.toDouble());
19 _image = image; 19 _image = image;
20 } 20 }
21 21
22 double get opacity => _opacity; 22 double get opacity => _opacity;
23 23
24 void set opacity(double opacity) { 24 void set opacity(double opacity) {
25 assert(opacity >= 0.0 && opacity <= 1.0); 25 assert(opacity >= 0.0 && opacity <= 1.0);
26 _opacity = opacity; 26 _opacity = opacity;
27 } 27 }
28 28
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 canvas.drawImage(_image, 0.0, 0.0, paint); 64 canvas.drawImage(_image, 0.0, 0.0, paint);
65 } 65 }
66 else { 66 else {
67 // Paint a red square for missing texture 67 // Paint a red square for missing texture
68 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height), 68 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height),
69 new Paint()..color = const Color.fromARGB(255, 255, 0, 0)); 69 new Paint()..color = const Color.fromARGB(255, 255, 0, 0));
70 } 70 }
71 canvas.restore(); 71 canvas.restore();
72 } 72 }
73 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698