Collin Jackson | 633b650 | 2015-07-16 11:54:25 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Adam Barth | 025c43d | 2016-02-13 14:30:37 -0800 | [diff] [blame] | 5 | // This example shows how to build a render tree with a non-cartesian coordinate |
| 6 | // system. Most of the guts of this examples are in src/sector_layout.dart. |
| 7 | |
Adam Barth | 65eba90 | 2015-10-09 20:44:52 -0700 | [diff] [blame] | 8 | import 'package:flutter/rendering.dart'; |
Adam Barth | 948ae15 | 2016-02-13 00:52:56 -0800 | [diff] [blame] | 9 | import 'src/sector_layout.dart'; |
Collin Jackson | 633b650 | 2015-07-16 11:54:25 -0700 | [diff] [blame] | 10 | |
| 11 | RenderBox buildSectorExample() { |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 12 | final RenderSectorRing rootCircle = RenderSectorRing(padding: 20.0); |
| 13 | rootCircle.add(RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15)); |
| 14 | rootCircle.add(RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); |
| 15 | final RenderSectorSlice stack = RenderSectorSlice(padding: 2.0); |
| 16 | stack.add(RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0)); |
| 17 | stack.add(RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0)); |
| 18 | stack.add(RenderSolidColor(const Color(0xFF00FF00))); |
Collin Jackson | 633b650 | 2015-07-16 11:54:25 -0700 | [diff] [blame] | 19 | rootCircle.add(stack); |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 20 | return RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); |
Collin Jackson | 633b650 | 2015-07-16 11:54:25 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void main() { |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 24 | RenderingFlutterBinding(root: buildSectorExample()); |
Collin Jackson | 633b650 | 2015-07-16 11:54:25 -0700 | [diff] [blame] | 25 | } |