| Index: sky/sdk/example/raw/painting_node.dart
|
| diff --git a/sky/sdk/example/raw/hello_world.dart b/sky/sdk/example/raw/painting_node.dart
|
| similarity index 59%
|
| copy from sky/sdk/example/raw/hello_world.dart
|
| copy to sky/sdk/example/raw/painting_node.dart
|
| index e667391734b3dcfd9f595a90d706ab33c6d84b98..7297540ee4df303e208aed57ef4c1ee652027343 100644
|
| --- a/sky/sdk/example/raw/hello_world.dart
|
| +++ b/sky/sdk/example/raw/painting_node.dart
|
| @@ -2,17 +2,32 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +import "dart:math";
|
| import 'dart:sky';
|
|
|
| +PaintingNode paintingNode = null;
|
| Picture draw(int a, int r, int g, int b) {
|
| + Rect bounds = new Rect.fromLTRB(0.0, 0.0, view.width, view.height);
|
| Size size = new Size(view.width, view.height);
|
|
|
| PictureRecorder recorder = new PictureRecorder();
|
| - Canvas canvas = new Canvas(recorder, size);
|
| + Canvas canvas = new Canvas(recorder, bounds);
|
| double radius = size.shortestSide * 0.45;
|
|
|
| Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
|
| canvas.drawCircle(size.center(Point.origin), radius, paint);
|
| +
|
| + if (paintingNode == null) {
|
| + paintingNode = new PaintingNode();
|
| + Paint innerPaint = new Paint()..color = new Color.fromARGB(a, 255 - r, 255 - g, 255 - b);
|
| + PictureRecorder innerRecorder = new PictureRecorder();
|
| + Canvas innerCanvas = new Canvas(innerRecorder, bounds);
|
| + innerCanvas.drawCircle(size.center(Point.origin), radius * 0.5, innerPaint);
|
| +
|
| + paintingNode.setBackingDrawable(innerRecorder.endRecordingAsDrawable());
|
| + }
|
| + canvas.drawPaintingNode(paintingNode);
|
| +
|
| return recorder.endRecording();
|
| }
|
|
|
| @@ -29,16 +44,10 @@ bool handleEvent(Event event) {
|
| return true;
|
| }
|
|
|
| - if (event.type == "back") {
|
| - print("Pressed back button.");
|
| - return true;
|
| - }
|
| -
|
| return false;
|
| }
|
|
|
| void main() {
|
| - print("Hello, world");
|
| view.picture = draw(255, 0, 255, 0);
|
| view.scheduleFrame();
|
|
|
|
|