I have the following which returns the rotation in degrees of an object, lensParentRight
, through 360.
This is in Adobe Animate HTML5 Canvas (create.js/easel.js would apply). cylinderAngle is just an offset.
var cylinderAngleText = Math.abs((Math.round(((root.lensParentRight.rotation + cylinderAngle) * 100) / 100))) + "\u00B0";
I want to keep the angle returned between 1 and 180.
How would this be done in JavaScript?
You could always limit your variable values using mod "%" at end of your mathematical expression. ((exp)%180) in your case. I hope that helps.