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

Unified Diff: sky/examples/raw/spinning_image.dart

Issue 1204783003: Adds basic sprite sheet support to sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Adds basic sprite sheet support to sprites (fixed issues) 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 side-by-side diff with in-line comments
Download patch
Index: sky/examples/raw/spinning_image.dart
diff --git a/sky/examples/raw/spinning_image.dart b/sky/examples/raw/spinning_image.dart
index a50f4c36f8c34e2801ed5530bf0cfa180733df2d..0b8ad29c689e2a73bf1d1bd260790ef0bd8fa9ac 100644
--- a/sky/examples/raw/spinning_image.dart
+++ b/sky/examples/raw/spinning_image.dart
@@ -20,8 +20,22 @@ void beginFrame(double timeStamp) {
canvas.rotate(math.PI * delta / 1800);
canvas.scale(0.2, 0.2);
Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0);
+
+ // Draw image
if (image != null)
canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint);
+
+ // Draw cut out of image
+ canvas.rotate(math.PI * delta / 1800);
+ if (image != null) {
+ var w = image.width.toDouble();
+ var h = image.width.toDouble();
+ canvas.drawImageRect(image,
+ new Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
+ new Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
+ paint);
+ }
+
view.picture = canvas.endRecording();
view.scheduleFrame();
}

Powered by Google App Engine
This is Rietveld 408576698