Chromium Code Reviews| OLD | NEW |
|---|---|
| 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"; | 5 import "dart:math"; |
| 6 import 'dart:sky'; | 6 import 'dart:sky'; |
| 7 | 7 |
| 8 import 'package:sky/framework/shell.dart' as shell; | 8 import 'package:sky/framework/shell.dart' as shell; |
| 9 import 'package:sky/rendering/object.dart'; | |
| 9 import 'package:mojom/intents/intents.mojom.dart'; | 10 import 'package:mojom/intents/intents.mojom.dart'; |
| 10 | 11 |
| 11 Picture draw(int a, int r, int g, int b) { | 12 Picture draw(int a, int r, int g, int b) { |
| 12 double width = view.width; | 13 double width = view.width; |
| 13 double height = view.height; | 14 double height = view.height; |
| 14 | 15 |
| 15 PictureRecorder recorder = new PictureRecorder(width, height); | 16 PictureRecorder recorder = new PictureRecorder(); |
| 17 RenderCanvas canvas = new RenderCanvas(recorder, width, height); | |
|
abarth-chromium
2015/06/23 02:28:45
Again, regular Canvas is fine here. There's no ne
iansf
2015/06/23 22:46:09
Done.
| |
| 16 double radius = min(width, height) * 0.45; | 18 double radius = min(width, height) * 0.45; |
| 17 | 19 |
| 18 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b); | 20 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b); |
| 19 recorder.drawRect(new Rect.fromSize(new Size(width, height)), paint); | 21 canvas.drawRect(new Rect.fromSize(new Size(width, height)), paint); |
| 20 return recorder.endRecording(); | 22 return recorder.endRecording(); |
| 21 } | 23 } |
| 22 | 24 |
| 23 bool handleEvent(Event event) { | 25 bool handleEvent(Event event) { |
| 24 if (event.type == "pointerdown") { | 26 if (event.type == "pointerdown") { |
| 25 view.picture = draw(255, 0, 0, 255); | 27 view.picture = draw(255, 0, 0, 255); |
| 26 view.scheduleFrame(); | 28 view.scheduleFrame(); |
| 27 return true; | 29 return true; |
| 28 } | 30 } |
| 29 | 31 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 48 return false; | 50 return false; |
| 49 } | 51 } |
| 50 | 52 |
| 51 void main() { | 53 void main() { |
| 52 print("Hello, world"); | 54 print("Hello, world"); |
| 53 view.picture = draw(255, 255, 255, 0); | 55 view.picture = draw(255, 255, 255, 0); |
| 54 view.scheduleFrame(); | 56 view.scheduleFrame(); |
| 55 | 57 |
| 56 view.setEventCallback(handleEvent); | 58 view.setEventCallback(handleEvent); |
| 57 } | 59 } |
| OLD | NEW |