Commit 37f0b024 authored by Hixie's avatar Hixie

Convert everything in the Sky API from degrees to radians.

Radians are the one true angle unit.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1164393002
parent 8ade37c5
......@@ -123,7 +123,7 @@ class TransformNode {
canvas.save();
canvas.translate(_position[0], _position[1]);
canvas.rotateDegrees(_rotation);
canvas.rotate(degrees2radians(_rotation));
canvas.translate(-_width*_pivot[0], -_height*_pivot[1]);
// TODO: Use transformation matrix instead of individual calls
......@@ -147,4 +147,4 @@ class TransformNode {
void update(double dt) {
}
}
\ No newline at end of file
}
......@@ -24,7 +24,7 @@ void main() {
context.translate(mid.x, mid.y);
paint.color = const Color.fromARGB(128, 255, 0, 255);
context.rotateDegrees(45.0);
context.rotate(math.PI/4.0);
Gradient yellowBlue = new Gradient.Linear(
[new Point(-radius, -radius), new Point(0.0, 0.0)],
......
......@@ -10,8 +10,6 @@ import 'package:sky/framework/rendering/object.dart';
const double kTwoPi = 2 * math.PI;
double deg(double radians) => radians * 180.0 / math.PI;
class SectorConstraints {
const SectorConstraints({
this.minDeltaRadius: 0.0,
......@@ -128,10 +126,10 @@ class RenderDecoratedSector extends RenderSector {
Path path = new Path();
double outerRadius = (parentData.radius + deltaRadius);
Rect outerBounds = new Rect.fromLTRB(-outerRadius, -outerRadius, outerRadius, outerRadius);
path.arcTo(outerBounds, deg(parentData.theta), deg(deltaTheta), true);
path.arcTo(outerBounds, parentData.theta, deltaTheta, true);
double innerRadius = parentData.radius;
Rect innerBounds = new Rect.fromLTRB(-innerRadius, -innerRadius, innerRadius, innerRadius);
path.arcTo(innerBounds, deg(parentData.theta + deltaTheta), deg(-deltaTheta), false);
path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false);
path.close();
canvas.drawPath(path, paint);
}
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:sky';
import 'package:sky/framework/net/image_cache.dart' as image_cache;
......@@ -16,7 +17,7 @@ void beginFrame(double timeStamp) {
double delta = timeStamp - timeBase;
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
canvas.translate(view.width / 2.0, view.height / 2.0);
canvas.rotateDegrees(delta / 10);
canvas.rotate(math.PI * delta / 1800);
canvas.scale(0.2, 0.2);
Paint paint = new Paint()..setARGB(255, 0, 255, 0);
if (image != null)
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:sky';
import 'dart:math' as math;
double timeBase = null;
......@@ -13,7 +14,7 @@ void beginFrame(double timeStamp) {
double delta = timeStamp - timeBase;
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
canvas.translate(view.width / 2.0, view.height / 2.0);
canvas.rotateDegrees(delta / 10);
canvas.rotate(math.PI * delta / 1800);
canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new Paint()..setARGB(255, 0, 255, 0));
view.picture = canvas.endRecording();
......
......@@ -14,7 +14,7 @@ void beginFrame(double timeStamp) {
double delta = timeStamp - timeBase;
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
canvas.translate(view.width / 2.0, view.height / 2.0);
canvas.rotateDegrees(delta / 10);
canvas.rotate(math.PI * delta / 1800);
canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new Paint()..setARGB(255, 0, 255, 0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment