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' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import 'package:sky/rendering/box.dart'; | 7 import 'package:sky/rendering/box.dart'; |
8 import 'package:sky/rendering/flex.dart'; | 8 import 'package:sky/rendering/flex.dart'; |
9 import 'package:sky/theme2/colors.dart'; | 9 import 'package:sky/theme2/colors.dart'; |
10 import 'package:sky/theme2/edges.dart'; | 10 import 'package:sky/theme2/edges.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 RenderBox initCircle() { | 21 RenderBox initCircle() { |
22 return new RenderBoxToRenderSectorAdapter( | 22 return new RenderBoxToRenderSectorAdapter( |
23 innerRadius: 25.0, | 23 innerRadius: 25.0, |
24 child: new RenderSectorRing(padding: 0.0) | 24 child: new RenderSectorRing(padding: 0.0) |
25 ); | 25 ); |
26 } | 26 } |
27 | 27 |
28 class SectorApp extends App { | 28 class SectorApp extends App { |
29 | 29 |
30 RenderBoxToRenderSectorAdapter sectors = initCircle(); | 30 RenderBoxToRenderSectorAdapter sectors = initCircle(); |
31 math.Random rand = new math.Random(); | 31 math.Random rand = new math.Random(1); |
32 | 32 |
33 void addSector() { | 33 void addSector() { |
34 double deltaTheta; | 34 double deltaTheta; |
35 var ring = (sectors.child as RenderSectorRing); | 35 var ring = (sectors.child as RenderSectorRing); |
36 SectorDimensions currentSize = ring.getIntrinsicDimensions(const SectorConst
raints(), ring.deltaRadius); | 36 SectorDimensions currentSize = ring.getIntrinsicDimensions(const SectorConst
raints(), ring.deltaRadius); |
37 if (currentSize.deltaTheta >= kTwoPi - (math.PI * 0.2 + 0.05)) | 37 if (currentSize.deltaTheta >= kTwoPi - (math.PI * 0.2 + 0.05)) |
38 deltaTheta = kTwoPi - currentSize.deltaTheta; | 38 deltaTheta = kTwoPi - currentSize.deltaTheta; |
39 else | 39 else |
40 deltaTheta = math.PI * rand.nextDouble() / 5.0 + 0.05; | 40 deltaTheta = math.PI * rand.nextDouble() / 5.0 + 0.05; |
41 Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); | 41 Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void main() { | 137 void main() { |
138 runApp(new SectorApp()); | 138 runApp(new SectorApp()); |
139 WidgetAppView.appView.onFrame = () { | 139 WidgetAppView.appView.onFrame = () { |
140 // uncomment this for debugging: | 140 // uncomment this for debugging: |
141 // WidgetAppView.appView.debugDumpRenderTree(); | 141 // WidgetAppView.appView.debugDumpRenderTree(); |
142 }; | 142 }; |
143 } | 143 } |
OLD | NEW |