OLD | NEW |
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; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 else { | 46 else { |
47 canvas.translate((size.width - scaleY * _image.width)/2.0, 0.0); | 47 canvas.translate((size.width - scaleY * _image.width)/2.0, 0.0); |
48 scaleX = scaleY; | 48 scaleX = scaleY; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 canvas.scale(scaleX, scaleY); | 52 canvas.scale(scaleX, scaleY); |
53 | 53 |
54 // Setup paint object for opacity and transfer mode | 54 // Setup paint object for opacity and transfer mode |
55 Paint paint = new Paint(); | 55 Paint paint = new Paint(); |
56 paint.color = Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255); | 56 paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255); |
57 if (colorOverlay != null) { | 57 if (colorOverlay != null) { |
58 paint.setColorFilter(new ColorFilter.mode(colorOverlay, TransferMode.src
ATopMode)); | 58 paint.setColorFilter(new ColorFilter.mode(colorOverlay, TransferMode.src
ATopMode)); |
59 } | 59 } |
60 if (transferMode != null) { | 60 if (transferMode != null) { |
61 paint.setTransferMode(transferMode); | 61 paint.setTransferMode(transferMode); |
62 } | 62 } |
63 | 63 |
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 = 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 } |
OLD | NEW |