I drew a rectangle in the vision, and when a bool variable is true, the rectangle starts rotating 10 ° every second. What should I do? Thank you very much
My original answer was incorrect. toRadians
is not required as the angle property uses degrees. Correct version shown below.
While this will probably work for a while, this approach is prone to a cumulative floating point errors that will eventually result in unexpected behaviors. Something with explicitly integer angles, such as the style customizer, a timer component, or evan an expression binding with a case statement are the preferred method for rotating animations in Vision.
How come? I appreciate that the now(1000)
won't fire on a 0 ms transition so the script could probably do with an int()
to fix this, but where is the opportunity for cumulative errors? The %
modulo arithmetic should prevent that.
Perhaps you're right. On my phone, I see this in your picture, so it makes me think there is a fractional element to this approach.
That's probably from the toRadians()
function.
Because converting to radians requires the use of Pi
A better solution in this instance is to just force the addition of 10 every second. I would probably lean towards a timer component.
I also like to use the canvas with a timer component for this sort of thing.
Agree particularly for complex shapes. Also prevents the shape from flying off the screen, though if the position isn't changing that shouldn't be an issue.
That will definitely cause a creep due to the π rounding error (but see below).
I'm not arguing for my solution in particular. I don't work in Vision anymore and on further inspection the angle is in degrees, not radians! I'll edit my original answer. The new one uses floor()
to ensure that the rectangle starts at 0° and there is no creep.
Thank you very much for your enthusiastic help
As a user of traditional scada, I was greatly shocked by the experience with igniton. Once again, thank you and other friends for providing me with ideas
getsecond( now() )*10.
This should be simpler.
getsecond( now() ) * 10
should be simpler.
Yes, but gives you 0°, 10°, 20°, ... 340°, 350° 360°, 370° ..., 580°, 590° before resetting with a big jump.