mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
added angleDeg flag that enables developers to choose radians if they like
This commit is contained in:
parent
ddf34d0af9
commit
e5562f5dbb
@ -428,7 +428,7 @@
|
|||||||
fillPatternX = shape.getFillPatternX(),
|
fillPatternX = shape.getFillPatternX(),
|
||||||
fillPatternY = shape.getFillPatternY(),
|
fillPatternY = shape.getFillPatternY(),
|
||||||
fillPatternScale = shape.getFillPatternScale(),
|
fillPatternScale = shape.getFillPatternScale(),
|
||||||
fillPatternRotation = shape.getFillPatternRotation(),
|
fillPatternRotation = Kinetic.getAngle(shape.getFillPatternRotation()),
|
||||||
fillPatternOffset = shape.getFillPatternOffset(),
|
fillPatternOffset = shape.getFillPatternOffset(),
|
||||||
fillPatternRepeat = shape.getFillPatternRepeat();
|
fillPatternRepeat = shape.getFillPatternRepeat();
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
/*jshint -W079, -W020*/
|
/*jshint -W079, -W020*/
|
||||||
var Kinetic = {};
|
var Kinetic = {};
|
||||||
(function(root) {
|
(function(root) {
|
||||||
|
var PI_OVER_180 = Math.PI / 180;
|
||||||
|
|
||||||
Kinetic = {
|
Kinetic = {
|
||||||
// public
|
// public
|
||||||
version: '@@version',
|
version: '@@version',
|
||||||
@ -51,7 +53,7 @@ var Kinetic = {};
|
|||||||
dblClickWindow: 400,
|
dblClickWindow: 400,
|
||||||
pixelRatio: undefined,
|
pixelRatio: undefined,
|
||||||
dragDistance : 0,
|
dragDistance : 0,
|
||||||
enableThrottling: true,
|
angleDeg: true,
|
||||||
|
|
||||||
// user agent
|
// user agent
|
||||||
UA: (function() {
|
UA: (function() {
|
||||||
@ -295,6 +297,9 @@ var Kinetic = {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getAngle: function(angle) {
|
||||||
|
return this.angleDeg ? angle * PI_OVER_180 : angle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
@ -1154,7 +1154,7 @@
|
|||||||
var m = new Kinetic.Transform(),
|
var m = new Kinetic.Transform(),
|
||||||
x = this.getX(),
|
x = this.getX(),
|
||||||
y = this.getY(),
|
y = this.getY(),
|
||||||
rotation = this.getRotation() * Math.PI / 180,
|
rotation = Kinetic.getAngle(this.getRotation()),
|
||||||
scaleX = this.getScaleX(),
|
scaleX = this.getScaleX(),
|
||||||
scaleY = this.getScaleY(),
|
scaleY = this.getScaleY(),
|
||||||
skewX = this.getSkewX(),
|
skewX = this.getSkewX(),
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
var PI_OVER_180 = Math.PI / 180;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arc constructor
|
* Arc constructor
|
||||||
* @constructor
|
* @constructor
|
||||||
@ -34,7 +36,7 @@
|
|||||||
this.sceneFunc(this._sceneFunc);
|
this.sceneFunc(this._sceneFunc);
|
||||||
},
|
},
|
||||||
_sceneFunc: function(context) {
|
_sceneFunc: function(context) {
|
||||||
var angle = this.angle() * Math.PI / 180,
|
var angle = Kinetic.getAngle(this.angle()),
|
||||||
clockwise = this.clockwise();
|
clockwise = this.clockwise();
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
_sceneFunc: function(context) {
|
_sceneFunc: function(context) {
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.arc(0, 0, this.getRadius(), 0, this.getAngle() * Math.PI / 180, this.getClockwise());
|
context.arc(0, 0, this.getRadius(), 0, Kinetic.getAngle(this.getAngle()), this.getClockwise());
|
||||||
context.lineTo(0, 0);
|
context.lineTo(0, 0);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
context.fillStrokeShape(this);
|
context.fillStrokeShape(this);
|
||||||
|
@ -4,4 +4,17 @@ suite('Global', function() {
|
|||||||
test('test Kinetic version number', function() {
|
test('test Kinetic version number', function() {
|
||||||
assert.equal(Kinetic.version, 'dev');
|
assert.equal(Kinetic.version, 'dev');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('getAngle()', function() {
|
||||||
|
// test that default angleDeg is true
|
||||||
|
assert.equal(Kinetic.angleDeg, true);
|
||||||
|
assert.equal(Kinetic.getAngle(180), Math.PI);
|
||||||
|
|
||||||
|
Kinetic.angleDeg = false;
|
||||||
|
assert.equal(Kinetic.getAngle(1), 1);
|
||||||
|
|
||||||
|
// set angleDeg back to true for future tests
|
||||||
|
Kinetic.angleDeg = true;
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user