custom_coordinate_systems.dart 1.14 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
// This example shows how to build a render tree with a non-cartesian coordinate
// system. Most of the guts of this examples are in src/sector_layout.dart.

8
import 'package:flutter/rendering.dart';
9
import 'src/sector_layout.dart';
10 11

RenderBox buildSectorExample() {
12 13 14 15 16 17 18
  final RenderSectorRing rootCircle = RenderSectorRing(padding: 20.0);
  rootCircle.add(RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15));
  rootCircle.add(RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4));
  final RenderSectorSlice stack = RenderSectorSlice(padding: 2.0);
  stack.add(RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0));
  stack.add(RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0));
  stack.add(RenderSolidColor(const Color(0xFF00FF00)));
19
  rootCircle.add(stack);
20
  return RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle);
21 22 23
}

void main() {
24
  RenderingFlutterBinding(root: buildSectorExample()).scheduleFrame();
25
}