Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: sky/examples/raw/sector_layout.dart

Issue 1164393002: Convert everything in the Sky API from degrees to radians. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/examples/raw/painting.sky ('k') | sky/examples/raw/spinning_image.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 import 'package:sky/framework/app.dart'; 7 import 'package:sky/framework/app.dart';
8 import 'package:sky/framework/rendering/box.dart'; 8 import 'package:sky/framework/rendering/box.dart';
9 import 'package:sky/framework/rendering/object.dart'; 9 import 'package:sky/framework/rendering/object.dart';
10 10
11 const double kTwoPi = 2 * math.PI; 11 const double kTwoPi = 2 * math.PI;
12 12
13 double deg(double radians) => radians * 180.0 / math.PI;
14
15 class SectorConstraints { 13 class SectorConstraints {
16 const SectorConstraints({ 14 const SectorConstraints({
17 this.minDeltaRadius: 0.0, 15 this.minDeltaRadius: 0.0,
18 this.maxDeltaRadius: double.INFINITY, 16 this.maxDeltaRadius: double.INFINITY,
19 this.minDeltaTheta: 0.0, 17 this.minDeltaTheta: 0.0,
20 this.maxDeltaTheta: kTwoPi 18 this.maxDeltaTheta: kTwoPi
21 }); 19 });
22 20
23 const SectorConstraints.tight({ double deltaRadius: 0.0, double deltaTheta: 0. 0 }) 21 const SectorConstraints.tight({ double deltaRadius: 0.0, double deltaTheta: 0. 0 })
24 : minDeltaRadius = deltaRadius, 22 : minDeltaRadius = deltaRadius,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 assert(parentData is SectorParentData); 119 assert(parentData is SectorParentData);
122 120
123 if (_decoration == null) 121 if (_decoration == null)
124 return; 122 return;
125 123
126 if (_decoration.backgroundColor != null) { 124 if (_decoration.backgroundColor != null) {
127 Paint paint = new Paint()..color = _decoration.backgroundColor; 125 Paint paint = new Paint()..color = _decoration.backgroundColor;
128 Path path = new Path(); 126 Path path = new Path();
129 double outerRadius = (parentData.radius + deltaRadius); 127 double outerRadius = (parentData.radius + deltaRadius);
130 Rect outerBounds = new Rect.fromLTRB(-outerRadius, -outerRadius, outerRadi us, outerRadius); 128 Rect outerBounds = new Rect.fromLTRB(-outerRadius, -outerRadius, outerRadi us, outerRadius);
131 path.arcTo(outerBounds, deg(parentData.theta), deg(deltaTheta), true); 129 path.arcTo(outerBounds, parentData.theta, deltaTheta, true);
132 double innerRadius = parentData.radius; 130 double innerRadius = parentData.radius;
133 Rect innerBounds = new Rect.fromLTRB(-innerRadius, -innerRadius, innerRadi us, innerRadius); 131 Rect innerBounds = new Rect.fromLTRB(-innerRadius, -innerRadius, innerRadi us, innerRadius);
134 path.arcTo(innerBounds, deg(parentData.theta + deltaTheta), deg(-deltaThet a), false); 132 path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false) ;
135 path.close(); 133 path.close();
136 canvas.drawPath(path, paint); 134 canvas.drawPath(path, paint);
137 } 135 }
138 } 136 }
139 } 137 }
140 138
141 class SectorChildListParentData extends SectorParentData with ContainerParentDat aMixin<RenderSector> { } 139 class SectorChildListParentData extends SectorParentData with ContainerParentDat aMixin<RenderSector> { }
142 140
143 class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende rObjectMixin<RenderSector, SectorChildListParentData> { 141 class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende rObjectMixin<RenderSector, SectorChildListParentData> {
144 RenderSectorWithChildren(BoxDecoration decoration) : super(decoration); 142 RenderSectorWithChildren(BoxDecoration decoration) : super(decoration);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta : kTwoPi * 0.4)); 497 rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta : kTwoPi * 0.4));
500 var stack = new RenderSectorSlice(padding: 2.0); 498 var stack = new RenderSectorSlice(padding: 2.0);
501 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0)); 499 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0));
502 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0)); 500 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0));
503 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); 501 stack.add(new RenderSolidColor(const Color(0xFF00FF00)));
504 rootCircle.add(stack); 502 rootCircle.add(stack);
505 503
506 var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCi rcle); 504 var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCi rcle);
507 app = new AppView(root); 505 app = new AppView(root);
508 } 506 }
OLDNEW
« no previous file with comments | « sky/examples/raw/painting.sky ('k') | sky/examples/raw/spinning_image.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698