support (-360,360) angles for whalesong/image rotate
This commit is contained in:
parent
5d5ab6b32a
commit
08ed474897
|
@ -154,6 +154,9 @@ var checkPlaceY = plt.baselib.check.makeCheckArgumentType(
|
|||
var checkAngle = plt.baselib.check.makeCheckArgumentType(
|
||||
isAngle,
|
||||
"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(
|
||||
|
@ -790,9 +793,13 @@ EXPORTS['rotate'] =
|
|||
'rotate',
|
||||
2,
|
||||
function(MACHINE) {
|
||||
var angle = checkAngle(MACHINE, "rotate", 0);
|
||||
var angle = checkRotateAngle(MACHINE, "rotate", 0);
|
||||
var img = checkImage(MACHINE, "rotate", 1);
|
||||
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.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.
|
||||
|
@ -1469,6 +1475,7 @@ EXPORTS.isImage = isImage;
|
|||
EXPORTS.isScene = isScene;
|
||||
EXPORTS.isColorOrColorString = isColorOrColorString;
|
||||
EXPORTS.isAngle = isAngle;
|
||||
EXPORTS.isRotateAngle = isRotateAngle;
|
||||
EXPORTS.isSideCount = isSideCount;
|
||||
EXPORTS.isStepCount = isStepCount;
|
||||
EXPORTS.isPointsCount = isPointsCount;
|
||||
|
|
Loading…
Reference in New Issue
Block a user