It is currently April 23rd, 2024, 5:57 pm

Animated gif

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Animated gif

Post by xenium »

Hi,
I have an animated gif consisting of 30 images (0-29) and one icon.
I would like to click on the icon and gif to run once and stop at picture 15.
Then when I click on the icon again, keep running from picture 16 to picture 29 and stop again.
The process will resume again when the icon is clicked again

The code below runs gif when the skin starts and stops at picture 15.
I do not know how to run after the break from 16 to 29, and what commands to have the icon
Thanks

Code: Select all

[Rainmeter]
Update=100


[Variables]
ImageNumber=0
Pause=1

[ImageNumberCalc]
Measure=Calc
Formula=(ImageNumberCalc%16)+#Pause#
Substitute=".00000":""
IfEqualValue=15
IfEqualAction=[!SetVariable Pause (1-#Pause#)]
DynamicVariables=1

[ImageMeter]
Meter=Image
ImageName="Frame.\Frame[ImageNumberCalc].png"
X=25
Y=29
H=150
W=150
DynamicVariables=1



[Icon]
Meter=Image
ImageName=#@#icon.png            
x=250
y=100
LeftMouseUpAction= 
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Animated gif

Post by balala »

xenium wrote:The code below runs gif when the skin starts and stops at picture 15.
I do not know how to run after the break from 16 to 29, and what commands to have the icon
Since we have the !Delay bang, it's easier then ever before. Replace the [ImageNumberCalc] measure with the following one:

Code: Select all

[ImageNumberCalc]
Measure=Calc
Formula=(( ImageNumberCalc + 1 ) % 30 )
IfCondition=(#CURRENTSECTION#=15)
IfTrueAction=[!PauseMeasure "#CURRENTSECTION#"][!Delay "2000"][!UnpauseMeasure "#CURRENTSECTION#"]
Note here that I replaced the posted IfAction, with an IfCondition. The number used under the !Delay bang is the length of the pause in milliseconds.
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Animated gif

Post by xenium »

balala wrote:Since we have the !Delay bang, it's easier then ever before. Replace the [ImageNumberCalc] measure with the following one:

Code: Select all

[ImageNumberCalc]
Measure=Calc
Formula=(( ImageNumberCalc + 1 ) % 30 )
IfCondition=(#CURRENTSECTION#=15)
IfTrueAction=[!PauseMeasure "#CURRENTSECTION#"][!Delay "2000"][!UnpauseMeasure "#CURRENTSECTION#"]
Note here that I replaced the posted IfAction, with an IfCondition. The number used under the !Delay bang is the length of the pause in milliseconds.
it's not what I want.
now the gif runs alone up to picture 15, pauses, then continues alone until the end and then starts again.
I want the gif to start only when I click on the icon (button), run up to picture 15 and stop.
Just when I click on the button again, it starts running again from picture 15 to picture 29 and stop.
So ,the gif starts running only when I click the icon (button)
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Animated gif

Post by balala »

xenium wrote:I want the gif to start only when I click on the icon (button), run up to picture 15 and stop.
Just when I click on the button again, it starts running again from picture 15 to picture 29 and stop.
So ,the gif starts running only when I click the icon (button)
You're right this was your initial request, sorry for my inattention.
Here is the fix: add a Paused=1 option to the [ImageNumberCalc] measure. Then replace the IfCondition and IfTrueAction options of the same [ImageNumberCalc] measure, as it follows:

Code: Select all

[ImageNumberCalc]
...
IfCondition=((#CURRENTSECTION#=15)||(#CURRENTSECTION#=29))
IfTrueAction=[!PauseMeasure "#CURRENTSECTION#"]
Paused=1
And add the following LeftMouseUpAction option to the icon (button): LeftMouseUpAction=[!UnpauseMeasure "ImageNumberCalc"]
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Animated gif

Post by xenium »

balala wrote:You're right this was your initial request, sorry for my inattention.
Here is the fix: add a Paused=1 option to the [ImageNumberCalc] measure. Then replace the IfCondition and IfTrueAction options of the same [ImageNumberCalc] measure, as it follows:

Code: Select all

[ImageNumberCalc]
...
IfCondition=((#CURRENTSECTION#=15)||(#CURRENTSECTION#=29))
IfTrueAction=[!PauseMeasure "#CURRENTSECTION#"]
Paused=1
And add the following LeftMouseUpAction option to the icon (button): LeftMouseUpAction=[!UnpauseMeasure "ImageNumberCalc"]
and what are the two commands LeftMouseUpAction =? to start running the gif,because now the gif is not running?
-first command, click on the button and start running gif to image 15 and stop
-the second command, when you click the button again and start the gif to run from image 15 to picture 29 and stop

Or can not you click twice for two commands on the same button and 2 buttons are required, one for each command?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Animated gif

Post by eclectic-tech »

You could do this using ActionTimer... balala may give you an answer to resolve your original code.

ActionTimer version:

Code: Select all

[Rainmeter]
Update=1000


[Variables]
W=150
U=[!UpdateMeasure MeasureActionTimer][!UpdateMeter ImageMeter][!Redraw]
ImageNumber=0

[MeasureActionTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat CountTo15, #W#, 15
ActionList2=Repeat CountTo30, #W#, 15
CountTo15=[!SetVariable ImageNumber (Clamp(#ImageNumber#+1,0,15))]#U#
CountTo30=[!SetVariable ImageNumber (Clamp(#ImageNumber#+1,16,30))]#U#
IfCondition=(#ImageNumber#=15)
IfTrueAction=[!SetOption Icon LeftMouseUpAction """[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 2"]"""]
IfCondition2=(#ImageNumber#=30)
IfTrueAction2=[!SetVariable ImageNumber 0][!SetOption Icon LeftMouseUpAction """[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 1"]"""]
DynamicVariables=1


[ImageMeter]
Meter=Image
ImageName="Frame.\Frame#ImageNumber#.png"
X=25
Y=29
H=150
W=150
DynamicVariables=1

[Icon]
Meter=Image
ImageName=#@#icon.png           
X=250
Y=100
LeftMouseUpAction=[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 1"]
It uses 2 timer actions to change the ImageNumber variable and changes the LeftMouseUpAction when the ImageNumber is 15 and again when it reaches 30.
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Animated gif

Post by xenium »

eclectic-tech wrote:You could do this using ActionTimer... balala may give you an answer to resolve your original code.

ActionTimer version:

Code: Select all

[Rainmeter]
Update=1000


[Variables]
W=150
U=[!UpdateMeasure MeasureActionTimer][!UpdateMeter ImageMeter][!Redraw]
ImageNumber=0

[MeasureActionTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat CountTo15, #W#, 15
ActionList2=Repeat CountTo30, #W#, 15
CountTo15=[!SetVariable ImageNumber (Clamp(#ImageNumber#+1,0,15))]#U#
CountTo30=[!SetVariable ImageNumber (Clamp(#ImageNumber#+1,16,30))]#U#
IfCondition=(#ImageNumber#=15)
IfTrueAction=[!SetOption Icon LeftMouseUpAction """[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 2"]"""]
IfCondition2=(#ImageNumber#=30)
IfTrueAction2=[!SetVariable ImageNumber 0][!SetOption Icon LeftMouseUpAction """[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 1"]"""]
DynamicVariables=1


[ImageMeter]
Meter=Image
ImageName="Frame.\Frame#ImageNumber#.png"
X=25
Y=29
H=150
W=150
DynamicVariables=1

[Icon]
Meter=Image
ImageName=#@#icon.png           
X=250
Y=100
LeftMouseUpAction=[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!CommandMeasure MeasureActionTimer "Execute 1"]
It uses 2 timer actions to change the ImageNumber variable and changes the LeftMouseUpAction when the ImageNumber is 15 and again when it reaches 30.
That's it !!! :17good
It's exactly what I wanted.

Thank you very much for your help !
:welcome: :welcome: :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Animated gif

Post by balala »

xenium wrote:That's it !!! :17good
It's exactly what I wanted.
My code did almost the same thing as eclectic-tech's code, just without using the ActionTimer plugin and with the only difference that my code stopped at the last frame, not to the fist one. Finally I think this was what you asked for:
xenium wrote:it starts running again from picture 15 to picture 29 and stop.
In many cases, the ActionTimer plugin can be useful. I didn't use it to not complicate things.
However I'm glad if you got it working well, even if you did it with eclectic-tech's code.
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Animated gif

Post by xenium »

balala wrote:My code did almost the same thing as eclectic-tech's code, just without using the ActionTimer plugin and with the only difference that my code stopped at the last frame, not to the fist one. Finally I think this was what you asked for:

In many cases, the ActionTimer plugin can be useful. I didn't use it to not complicate things.
However I'm glad if you got it working well, even if you did it with eclectic-tech's code.

Sorry, I did not notice that you also wrote the LeftMouseUpAction option for the icon,
and there was no way I could see if the code worked or not.
I noticed later
You're right your code does the same thing as eclectic-tech code
Sorry again

I have one more question:

I have an animated gif consisting of 155 images (0-154) and 2 icons (icon 1, icon 2)
How do I make the animated gif run like this:
- Click on icon 1, the gif runs up to image 136, then resumes itself without pausing from image 42 to image 136. (so do not resume from image 0 !)
-click on icon 2, stops the action from icon 1 and the gif runs from image 136 to image 154 and stops.
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Animated gif

Post by balala »

xenium wrote:Sorry, I did not notice that you also wrote the LeftMouseUpAction option for the icon,
and there was no way I could see if the code worked or not.
I noticed later
You're right your code does the same thing as eclectic-tech code
Sorry again
Don't worry, I'm not upset, don't apologize. eclectic-tech's code is definitely better then mine, because it uses the ActionTimer plugin, which in this case can make a very good service.
xenium wrote:I have one more question:

I have an animated gif consisting of 155 images (0-154) and 2 icons (icon 1, icon 2)
How do I make the animated gif run like this:
- Click on icon 1, the gif runs up to image 136, then resumes itself without pausing from image 42 to image 136. (so do not resume from image 0 !)
-click on icon 2, stops the action from icon 1 and the gif runs from image 136 to image 154 and stops.
I wrote a code with three ActionTimer plugin measures. Here it is:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
ImageNum=0
U1=[!UpdateMeasure "MeasureSlide1"][!UpdateMeter "MeterImage"][!Redraw]
U2=[!UpdateMeasure "MeasureSlide2"][!UpdateMeter "MeterImage"][!Redraw]
U3=[!UpdateMeasure "MeasureSlide3"][!UpdateMeter "MeterImage"][!Redraw]
Limit1=42
Limit2=136
Limit3=154
Wait=250

[MeasureSlide1]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up1,#Wait#,#Limit1#
Up1=[!SetVariable ImageNum "(Clamp((#ImageNum#+1),0,#Limit1#))"]#U1#
IfCondition=(#ImageNum#=#Limit1#)
IfTrueAction=[!UpdateMeasure "MeasureSlide2"][!CommandMeasure "MeasureSlide1" "Stop 1"][!CommandMeasure "MeasureSlide2" "Execute 1"]
DynamicVariables=1

[MeasureSlide2]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up2,#Wait#,#Limit2#+2
Up2=[!SetVariable ImageNum "(Clamp((#ImageNum#+1),#Limit1#,#Limit3#))"]#U2#
IfCondition=(#ImageNum#=#Limit2#+1)
IfTrueAction=[!SetVariable Imagenum "(#Limit1#-1)"][!UpdateMeasure "MeasureSlide2"][!CommandMeasure "MeasureSlide1" "Stop 1"][!CommandMeasure "MeasureSlide2" "Stop 1"][!CommandMeasure "MeasureSlide2" "Execute 1"]
DynamicVariables=1

[MeasureSlide3]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up2,#Wait#,#Limit3#-#Limit2#+2
Up2=[!SetVariable ImageNum "(Clamp((#ImageNum#+1),#Limit2#,#Limit3#))"]#U3#
IfCondition=(#ImageNum#=#Limit3#)
IfTrueAction=[!CommandMeasure "MeasureSlide3" "Stop 1"]
DynamicVariables=1

[MeterButton1]
Meter=Image
SolidColor=255,0,0
X=0
Y=25
W=30
H=20
LeftMouseUpAction=[!CommandMeasure "MeasureSlide1" "Execute 1"]

[MeterButton2]
Meter=Image
SolidColor=255,240,0
X=10R
Y=0r
W=30
H=20
LeftMouseUpAction=[!SetVariable ImageNum "(#Limit2#-1)"][!UpdateMeasure "MeasureSlide3"][!CommandMeasure "MeasureSlide1" "Stop 1"][!CommandMeasure "MeasureSlide2" "Stop 1"][!CommandMeasure "MeasureSlide3" "Execute 1"]

[MeterImage]
Meter=Image
X=0
Y=10R
ImageName=#@#Frame\Frame#ImageNum#.png
DynamicVariables=1
Note the followings:
  • The Update value of this code is set to -1, which means the skin never updates "by default". Updates are made throught the U1, U2 and respectively U3 variables.
  • If you already have a code, just copy the LeftMouseUpAction options of the [MeterButton1] and [MeterButton2] meters and add them to the appropriate meters in your code. I had to create some meters to can control the skin.
  • See the limits of the whole proces, defined as the Limit1, Limit2 and Limit3 variables in the [Variables] section. I think you can freely modify them.
  • The images are controlled by the value of the ImageNum variable. The code as it is, will work if you have the images placed in the @Resources\Frame folder, their name are Frame and a number from 0 to 154 and their extension is .png. If these conditions aren't met, modify the code appropriately.
Please test this code and let me know if it does what you need.