Animation of a fan on a motor shaft? - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Animation of a fan on a motor shaft? - Solved

Post by DR White » Thu Feb 04, 2021 1:51 pm

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
Last edited by DR White on Thu Feb 04, 2021 5:40 pm, edited 1 time in total.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Animation of a fan on a motor shaft?

Post by bogs » Thu Feb 04, 2021 2:14 pm

Why not just use an animated gif? Simplest solution I can think of.
Image

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Animation of a fan on a motor shaft?

Post by DR White » Thu Feb 04, 2021 2:20 pm

How is that done?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Animation of a fan on a motor shaft?

Post by Klaus » Thu Feb 04, 2021 2:30 pm

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

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Animation of a fan on a motor shaft?

Post by DR White » Thu Feb 04, 2021 2:48 pm

Thank You!

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Animation of a fan on a motor shaft?

Post by bogs » Thu Feb 04, 2021 3:00 pm

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 171 times
Image

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Animation of a fan on a motor shaft?

Post by DR White » Thu Feb 04, 2021 3:22 pm

I love it when someone attaches an example!!

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

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Animation of a fan on a motor shaft?

Post by bogs » Thu Feb 04, 2021 3:39 pm

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 166 times
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Animation of a fan on a motor shaft?

Post by richmond62 » Thu Feb 04, 2021 4:43 pm

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.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Animation of a fan on a motor shaft?

Post by bogs » Thu Feb 04, 2021 4:47 pm

Not quite sure how your control would be any greater or lesser than just using the gif ?
Image

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Animation of a fan on a motor shaft?

Post by DR White » 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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Animation of a fan on a motor shaft?

Post by richmond62 » Thu Feb 04, 2021 5:19 pm

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 . . .

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Animation of a fan on a motor shaft?

Post by bogs » Thu Feb 04, 2021 5:26 pm

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/
Image

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Animation of a fan on a motor shaft?

Post by DR White » Thu Feb 04, 2021 5:39 pm

I see how richmond62 got the animation to work.

Pretty straight forward!

Thanks everyone so much!!

This forum is the BEST!! :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Thu Feb 04, 2021 7:37 pm

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

Post Reply