Merge pull request #24 from stchang/master
support (-360,360) angles for whalesong/image rotate
This commit is contained in:
commit
0b6ab32f8d
|
@ -154,6 +154,9 @@ var checkPlaceY = plt.baselib.check.makeCheckArgumentType(
|
||||||
var checkAngle = plt.baselib.check.makeCheckArgumentType(
|
var checkAngle = plt.baselib.check.makeCheckArgumentType(
|
||||||
isAngle,
|
isAngle,
|
||||||
"finite real number between 0 and 360");
|
"finite real number between 0 and 360");
|
||||||
|
var checkRotateAngle = plt.baselib.check.makeCheckArgumentType(
|
||||||
|
isRotateAngle,
|
||||||
|
"finite real number between -360 and 360");
|
||||||
|
|
||||||
|
|
||||||
var checkMode = plt.baselib.check.makeCheckArgumentType(
|
var checkMode = plt.baselib.check.makeCheckArgumentType(
|
||||||
|
@ -790,9 +793,13 @@ EXPORTS['rotate'] =
|
||||||
'rotate',
|
'rotate',
|
||||||
2,
|
2,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var angle = checkAngle(MACHINE, "rotate", 0);
|
var angle = checkRotateAngle(MACHINE, "rotate", 0);
|
||||||
var img = checkImage(MACHINE, "rotate", 1);
|
var img = checkImage(MACHINE, "rotate", 1);
|
||||||
return makeRotateImage(jsnums.toFixnum(-angle), img);
|
if (jsnums.lessThan(angle, 0)) {
|
||||||
|
return makeRotateImage(jsnums.toFixnum(-(360 + angle)), img);
|
||||||
|
} else {
|
||||||
|
return makeRotateImage(jsnums.toFixnum(-angle), img);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,12 @@ var isAngle = function(x) {
|
||||||
jsnums.greaterThanOrEqual(x, 0) &&
|
jsnums.greaterThanOrEqual(x, 0) &&
|
||||||
jsnums.lessThan(x, 360);
|
jsnums.lessThan(x, 360);
|
||||||
};
|
};
|
||||||
|
// differentiate between rotation angle and other angles
|
||||||
|
var isRotateAngle = function(x) {
|
||||||
|
return plt.baselib.numbers.isReal(x) &&
|
||||||
|
jsnums.greaterThan(x, -360) &&
|
||||||
|
jsnums.lessThan(x, 360);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Produces true if the value is a color or a color string.
|
// Produces true if the value is a color or a color string.
|
||||||
|
@ -1469,6 +1475,7 @@ EXPORTS.isImage = isImage;
|
||||||
EXPORTS.isScene = isScene;
|
EXPORTS.isScene = isScene;
|
||||||
EXPORTS.isColorOrColorString = isColorOrColorString;
|
EXPORTS.isColorOrColorString = isColorOrColorString;
|
||||||
EXPORTS.isAngle = isAngle;
|
EXPORTS.isAngle = isAngle;
|
||||||
|
EXPORTS.isRotateAngle = isRotateAngle;
|
||||||
EXPORTS.isSideCount = isSideCount;
|
EXPORTS.isSideCount = isSideCount;
|
||||||
EXPORTS.isStepCount = isStepCount;
|
EXPORTS.isStepCount = isStepCount;
|
||||||
EXPORTS.isPointsCount = isPointsCount;
|
EXPORTS.isPointsCount = isPointsCount;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user