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

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

Issue 1151753009: Add Sky framework support for drawing images (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Run git cl format once more Created 5 years, 7 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
« no previous file with comments | « sky/engine/core/painting/Image.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/raw/spinning_image.dart
diff --git a/sky/examples/raw/spinning_square.dart b/sky/examples/raw/spinning_image.dart
similarity index 66%
copy from sky/examples/raw/spinning_square.dart
copy to sky/examples/raw/spinning_image.dart
index 17072330d56a229ea035b708aba5d86df568c8ef..53fe140460f3b4dbc19e556d937e50c582b77596 100644
--- a/sky/examples/raw/spinning_square.dart
+++ b/sky/examples/raw/spinning_image.dart
@@ -6,20 +6,24 @@ import 'dart:sky';
double timeBase = null;
+Image image;
+
void beginFrame(double timeStamp) {
- if (timeBase == null)
- timeBase = timeStamp;
+ if (timeBase == null) timeBase = timeStamp;
double delta = timeStamp - timeBase;
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
canvas.translate(view.width / 2.0, view.height / 2.0);
canvas.rotateDegrees(delta / 10);
- canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
- new Paint()..setARGB(255, 0, 255, 0));
+ canvas.scale(0.2, 0.2);
+ Paint paint = new Paint()..setARGB(255, 0, 255, 0);
+ canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint);
view.picture = canvas.endRecording();
view.scheduleFrame();
}
void main() {
+ image = new Image();
+ image.src = "https://www.dartlang.org/logos/dart-logo.png";
view.setBeginFrameCallback(beginFrame);
view.scheduleFrame();
}
« no previous file with comments | « sky/engine/core/painting/Image.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698