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

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

Issue 1214833004: Split Size into Size and Offset. (Closed) Base URL: https://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 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) timeBase = timeStamp;
18 double delta = timeStamp - timeBase; 18 double delta = timeStamp - timeBase;
19 PictureRecorder recorder = new PictureRecorder(); 19 PictureRecorder recorder = new PictureRecorder();
20 Canvas canvas = new Canvas(recorder, view.width, view.height); 20 Canvas canvas = new Canvas(recorder, new Size(view.width, view.height));
21 canvas.translate(view.width / 2.0, view.height / 2.0); 21 canvas.translate(view.width / 2.0, view.height / 2.0);
22 canvas.rotate(math.PI * delta / 1800); 22 canvas.rotate(math.PI * delta / 1800);
23 canvas.scale(0.2, 0.2); 23 canvas.scale(0.2, 0.2);
24 Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0); 24 Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0);
25 25
26 // Draw image 26 // Draw image
27 if (image != null) 27 if (image != null)
28 canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint); 28 canvas.drawImage(image, new Point(-image.width / 2.0, -image.height / 2.0), paint);
29 29
30 // Draw cut out of image 30 // Draw cut out of image
31 canvas.rotate(math.PI * delta / 1800); 31 canvas.rotate(math.PI * delta / 1800);
32 if (image != null) { 32 if (image != null) {
33 var w = image.width.toDouble(); 33 var w = image.width.toDouble();
34 var h = image.width.toDouble(); 34 var h = image.width.toDouble();
35 canvas.drawImageRect(image, 35 canvas.drawImageRect(image,
36 new Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75), 36 new Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
37 new Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0), 37 new Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
38 paint); 38 paint);
(...skipping 25 matching lines...) Expand all
64 64
65 return false; 65 return false;
66 } 66 }
67 67
68 void main() { 68 void main() {
69 image_cache.load(url1, handleImageLoad); 69 image_cache.load(url1, handleImageLoad);
70 image_cache.load(url1, handleImageLoad); 70 image_cache.load(url1, handleImageLoad);
71 view.setEventCallback(handleEvent); 71 view.setEventCallback(handleEvent);
72 view.setBeginFrameCallback(beginFrame); 72 view.setBeginFrameCallback(beginFrame);
73 } 73 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/example/raw/spinning_arabic.dart ('k') | sky/sdk/lib/example/raw/spinning_square.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698