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

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

Issue 1209413004: Instead of applying a transform for every RenderObject, pass down an Offset for where to paint. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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) timeBase = timeStamp; 17 if (timeBase == null)
18 timeBase = timeStamp;
18 double delta = timeStamp - timeBase; 19 double delta = timeStamp - timeBase;
19 PictureRecorder recorder = new PictureRecorder(); 20 PictureRecorder recorder = new PictureRecorder();
20 Canvas canvas = new Canvas(recorder, new Size(view.width, view.height)); 21 Canvas canvas = new Canvas(recorder, new Size(view.width, view.height));
21 canvas.translate(view.width / 2.0, view.height / 2.0); 22 canvas.translate(view.width / 2.0, view.height / 2.0);
22 canvas.rotate(math.PI * delta / 1800); 23 canvas.rotate(math.PI * delta / 1800);
23 canvas.scale(0.2, 0.2); 24 canvas.scale(0.2, 0.2);
24 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);
25 26
26 // Draw image 27 // Draw image
27 if (image != null) 28 if (image != null)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 65
65 return false; 66 return false;
66 } 67 }
67 68
68 void main() { 69 void main() {
69 image_cache.load(url1, handleImageLoad); 70 image_cache.load(url1, handleImageLoad);
70 image_cache.load(url1, handleImageLoad); 71 image_cache.load(url1, handleImageLoad);
71 view.setEventCallback(handleEvent); 72 view.setEventCallback(handleEvent);
72 view.setBeginFrameCallback(beginFrame); 73 view.setBeginFrameCallback(beginFrame);
73 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698