custom_coordinate_systems.dart 1.15 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
// @dart = 2.10
6

7 8 9
// 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.

10
import 'package:flutter/rendering.dart';
11
import 'src/sector_layout.dart';
12 13

RenderBox buildSectorExample() {
14 15 16 17 18 19 20
  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)));
21
  rootCircle.add(stack);
22
  return RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle);
23 24 25
}

void main() {
26
  RenderingFlutterBinding(root: buildSectorExample());
27
}