HTML5 Canvas - Rotate symbol and convert angle between 1 and 180 degrees
I am rotating a symbol in code. During the rotation, the code converts to symbol's rotation property:
if (LFAngle > 180){
LFAngle = LFAngle - 180;
}
if(LFAngle == 0){
LFAngle = 180;
}This conversion is a technical requirement.
When rotating the symbol in the compiled application, there are some logic problems with the LFAngle:
LFAngle will show 0, and then 180 on another roation step.
The first rotation of 360 degrees is OK (except the issues above), but then starts increasing from 180 to 360, which is what the logic above is tying to stop.
Full code:
var LFAngle;
function updateLF_RotateCW() {
var angle = 1 / Math.PI;
root.LFLensHolder.rotation += angle;
root.LFLensSupports.rotation += angle;
root.lensParentLeft.rotation += angle;
LFAngle = root.lensParentLeft.rotation;
if (LFAngle > 180){
LFAngle = LFAngle - 180;
}
if(LFAngle == 0){
LFAngle = 180;
}
root.cylinderAngle.text = (Math.round(((LFAngle) * 100) / 100)) + "\u00B0";
}
