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

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

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (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 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
deleted file mode 100644
index 0b304784eff4e1934382562829505a69fb79d61e..0000000000000000000000000000000000000000
--- a/sky/examples/raw/spinning_image.dart
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:math' as math;
-import 'dart:sky';
-
-import 'package:sky/mojo/net/image_cache.dart' as image_cache;
-
-double timeBase = null;
-
-Image image = null;
-String url1 = "https://www.dartlang.org/logos/dart-logo.png";
-String url2 = "http://i2.kym-cdn.com/photos/images/facebook/000/581/296/c09.jpg";
-
-void beginFrame(double timeStamp) {
- if (timeBase == null) timeBase = timeStamp;
- double delta = timeStamp - timeBase;
- PictureRecorder recorder = new PictureRecorder();
- Canvas canvas = new Canvas(recorder, view.width, view.height);
- canvas.translate(view.width / 2.0, view.height / 2.0);
- 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 = recorder.endRecording();
- view.scheduleFrame();
-}
-
-void handleImageLoad(result) {
- if (result != image) {
- print("${result.width}x${result.width} image loaded!");
- image = result;
- view.scheduleFrame();
- } else {
- print("Existing image was loaded again");
- }
-}
-
-bool handleEvent(Event event) {
- if (event.type == "pointerdown") {
- return true;
- }
-
- if (event.type == "pointerup") {
- image_cache.load(url2, handleImageLoad);
- return true;
- }
-
- return false;
-}
-
-void main() {
- image_cache.load(url1, handleImageLoad);
- image_cache.load(url1, handleImageLoad);
- view.setEventCallback(handleEvent);
- view.setBeginFrameCallback(beginFrame);
-}

Powered by Google App Engine
This is Rietveld 408576698