Page 1 of 2

Animation of a fan on a motor shaft? - Solved

Posted: Thu Feb 04, 2021 1:51 pm
by DR White
I am working on a learning app for electrical motor controls.
When the controls request the motor to run, I want a fan on the end of the motor to turn.

Currently I am changing the visibility of three groups of objects to give the appearance of rotation, but it is slow and choppy.
The visibility sequence is controlled by a "send back to me" instruction every 100 milliseconds.

Is there a better way?

Thanks,

David

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 2:14 pm
by bogs
Why not just use an animated gif? Simplest solution I can think of.

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 2:20 pm
by DR White
How is that done?

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 2:30 pm
by Klaus
Hi David,

I would take three screenshots from your groups and use this image as an ICON in a button and
set the icon sequentially like you did with show/hide the groups.

This animation will be much smoother!


Best

Klaus

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 2:48 pm
by DR White
Thank You!

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 3:00 pm
by bogs
Pretty simply, actually. I went and grabbed the first animated gif I could find of a fan turning, because I figure you have your own look for this in mind, so it is pretty crappy looking heh, but it is good enough for demonstration purposes.

All of the code is sitting in the card level.
ElectricFanOnOffGif.zip
I feel a breeze...
(19.2 KiB) Downloaded 172 times

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 3:22 pm
by DR White
I love it when someone attaches an example!!

Why don't I see any code in your "on" and "Off' buttons?

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 3:39 pm
by bogs
Glad you liked it :)
DR White wrote:
Thu Feb 04, 2021 3:22 pm
Why don't I see any code in your "on" and "Off' buttons?
Well, for a few reasons, not the least of which being it isn't necessary to code the buttons, they are just there for the end user, and likely enough the end user would never be looking at the code. I could just as easily have used 1 button, and just changed it's text / label. Had I gone that way, the code probably would have been in the single button.

When I write something, though, whether it is for me or for someone else, I tend to centralize my code, i.e.. I tend to put it as far down the message path as I can, unless there is a specific reason not too.

Here is the same stack, single button, code in the button.
ElectricFanOnOffGif_v2.zip
Button button...
(19.22 KiB) Downloaded 167 times

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 4:43 pm
by richmond62
Personally I always open up an animated GIF with GIMP and export all the constituent frames as PNG images so
that I can control them more easily inwith LiveCode.

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 4:47 pm
by bogs
Not quite sure how your control would be any greater or lesser than just using the gif ?

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 5:19 pm
by DR White
I downloaded GIMP.

I opened gif with GIMP.

I see the all the constituent frames.

Don't see how to export into individual frames.

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 5:19 pm
by richmond62
Screenshot 2021-02-04 at 18.17.32.png
-
https://www.dropbox.com/s/yvnkkca3c3vmn ... e.zip?dl=0

Stopping, Starting, speeding up, slowing down . . .

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 5:26 pm
by bogs
DR White wrote:
Thu Feb 04, 2021 5:19 pm
I downloaded GIMP.

I opened gif with GIMP.

I see the all the constituent frames.

Don't see how to export into individual frames.
There are a number of ways to do that, this is probably the easiest.
https://www.digitalcitizen.life/how-exp ... -gif-file/

Re: Animation of a fan on a motor shaft?

Posted: Thu Feb 04, 2021 5:39 pm
by DR White
I see how richmond62 got the animation to work.

Pretty straight forward!

Thanks everyone so much!!

This forum is the BEST!! :D

Re: Animation of a fan on a motor shaft? - Solved

Posted: Thu Feb 04, 2021 7:37 pm
by richmond62
There are a number of ways to do that, this is probably the easiest.
https://www.digitalcitizen.life/how-exp ... -gif-file/
Not if you are running an OS other than Windoze.

https://ezgif.com/split

macOS: https://apps.apple.com/us/app/gif-separ ... 8801?mt=12