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

Side by Side Diff: sky/sdk/example/raw/spinning_image.dart

Issue 1233673003: Fix bugs found by Dart analyzer (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: typo Created 5 years, 5 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky'; 6 import 'dart:sky';
7 7
8 import 'package:sky/mojo/net/image_cache.dart' as image_cache; 8 import 'package:sky/mojo/net/image_cache.dart' as image_cache;
9 9
10 double timeBase = null; 10 double timeBase = null;
11 11
12 Image image = null; 12 Image image = null;
13 String url1 = "https://www.dartlang.org/logos/dart-logo.png"; 13 String url1 = "https://www.dartlang.org/logos/dart-logo.png";
14 String url2 = "http://i2.kym-cdn.com/photos/images/facebook/000/581/296/c09.jpg" ; 14 String url2 = "http://i2.kym-cdn.com/photos/images/facebook/000/581/296/c09.jpg" ;
15 15
16 void beginFrame(double timeStamp) { 16 void beginFrame(double timeStamp) {
17 if (timeBase == null) 17 if (timeBase == null)
18 timeBase = timeStamp; 18 timeBase = timeStamp;
19 double delta = timeStamp - timeBase; 19 double delta = timeStamp - timeBase;
20 PictureRecorder recorder = new PictureRecorder(); 20 PictureRecorder recorder = new PictureRecorder();
21 Canvas canvas = new Canvas(recorder, new Size(view.width, view.height)); 21 Canvas canvas = new Canvas(recorder, Point.origin & new Size(view.width, view. height));
22 canvas.translate(view.width / 2.0, view.height / 2.0); 22 canvas.translate(view.width / 2.0, view.height / 2.0);
23 canvas.rotate(math.PI * delta / 1800); 23 canvas.rotate(math.PI * delta / 1800);
24 canvas.scale(0.2, 0.2); 24 canvas.scale(0.2, 0.2);
25 Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0); 25 Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0);
26 26
27 // Draw image 27 // Draw image
28 if (image != null) 28 if (image != null)
29 canvas.drawImage(image, new Point(-image.width / 2.0, -image.height / 2.0), paint); 29 canvas.drawImage(image, new Point(-image.width / 2.0, -image.height / 2.0), paint);
30 30
31 // Draw cut out of image 31 // Draw cut out of image
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 return false; 66 return false;
67 } 67 }
68 68
69 void main() { 69 void main() {
70 image_cache.load(url1).then(handleImageLoad); 70 image_cache.load(url1).then(handleImageLoad);
71 view.setEventCallback(handleEvent); 71 view.setEventCallback(handleEvent);
72 view.setFrameCallback(beginFrame); 72 view.setFrameCallback(beginFrame);
73 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698