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 import 'package:sky/framework/layout2.dart'; | 7 import 'package:sky/framework/layout2.dart'; |
8 | 8 |
9 class RenderBlueCircle extends RenderBox { | 9 class SimpleBlock extends RenderDecoratedBox { |
eseidel
2015/05/21 18:08:14
Simple isnt' a very good name. SolidColorBlock?
Hixie
2015/05/21 19:45:03
TwoHundredPixelHighBlock? :-)
| |
10 void paint(RenderNodeDisplayList canvas) { | 10 SimpleBlock(int backgroundColor) |
11 double radius = min(width, height) * 0.45; | 11 : super(new BoxDecoration(backgroundColor: backgroundColor)); |
12 Paint paint = new Paint()..setARGB(255, 0, 255, 255); | 12 |
13 canvas.drawCircle(width / 2, height / 2, radius, paint); | 13 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
14 return new BoxDimensions.withConstraints(constraints, height: 200.0); | |
15 } | |
16 | |
17 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { | |
18 setWidth(constraints, constraints.maxWidth); | |
19 setHeight(constraints, 200.0); | |
20 layoutDone(); | |
14 } | 21 } |
15 } | 22 } |
16 | 23 |
17 void main() { | 24 void main() { |
18 RenderView renderView = new RenderView(root: new RenderBlueCircle()); | 25 var root = new RenderBlock( |
26 decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF)); | |
27 | |
28 root.add(new SimpleBlock(0xFF00FF00)); | |
29 root.add(new SimpleBlock(0xFF0000FF)); | |
30 | |
31 RenderView renderView = new RenderView(root: root); | |
19 renderView.layout(newWidth: view.width, newHeight: view.height); | 32 renderView.layout(newWidth: view.width, newHeight: view.height); |
20 renderView.paintFrame(); | 33 renderView.paintFrame(); |
21 } | 34 } |
OLD | NEW |