It is currently April 23rd, 2024, 9:06 am

Animated Image Tint applied to an ImageCrop

Tips and Tricks from the Rainmeter Community
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Animated Image Tint applied to an ImageCrop

Post by Seahorse »

I have had this idea about animated backgrounds for meters in my head for a while, as always with me I know the WHAT, but invariably not the HOW. Once again I could see a way of combining some ideas, but needed help in getting there.

OK, so I have re-and re-read this Sliced image display with ImageCrop tip by Kenzo a bunch of times but struggled to follow it. Yesterday however, I reached the point where I understood enough of it to remove all the bits I am not interested in, spaces, grids and most especially ColorMatrix which makes my brain hurt. I understand ImageTint, which is what I intended to replace that with.

On to the animation, I presume it could be done with an animated GIF, but that gives no control in the skin and my powers with Gimp are weak O.O It did occur to me that Smurfier's Counters could be used to control things. What I needed a hand with after a couple of days of beating the code with a blunt instrument was a way of using 1 counter to control multiple meters individually, this is where Kaelri pointed me in the right direction with a measure per meter (Calc), I'm also relatively comfortable with these.

So, this is where I am today:
Capture.png
Now that it is working as I want, the number of slices will go up, and the image will be replaced with a transparent background mesh which I'm planning to use as an animated background for skins. Take one big grid, then use the ImageWidth and ImageHeight variables to define the size of the background. As I'm using rounded corners, I will also use X & Y in [MeterImage1/1] to control the offset to clear the corners. What this gives is a single source regardless image you can "chop" bits out of to match meter size. Below is a capture this mornings first test of an animated background in a meter which illustrates what I want to do with this, I need to play with colours now to find a colour combination that stands out enough to be seen, but not so that it overwhelms the skin. Anyhow, putting it out here as a guide for what I wanted, but you might see another use... :thumbup:
Capture2.PNG

Code: Select all

[Rainmeter]
Update=1000
Author=Seahorse, 
BackgroundMode=2
SolidColor=0,0,0,1

[Metadata]
Name=Animated Tint 

;===============================================================================================
;Variables
;===============================================================================================

[Variables]

;Needs to be the actual image dimensions if you want the full picture, otherwise you crop the image.

ImageName=Smile.jpg
ImageWidth=532
ImageHeight=441

;White Solid - does NOTHING to the displayed image
Colour1=255,255,255,255

;Light Blue - the colour of the tint, tranparencies make the image seethrough too, not wanted here.
Colour2=102,204,255,255

;===============================================================================================
;Calcs
;===============================================================================================


;Workout the width of s column

[W]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)

;X= Position of Column 1, X2 is column 2 etc

[X1]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)*0

[X2]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)*1

[X3]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)*2

[X4]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)*3

[X5]
Measure=Calc
Formula=ROUND(#ImageWidth#/5)*4

;5-second counter that resets at 5, you could add a pause by increasing the %6 (must be 1 MORE than the number you want)

[CalcCounter]
Measure=Calc
Formula=(CalcCounter+1)%6

;Tint details for first coloumn Meter, etc...

[CalcMeterImage1/1]
Measure=CALC
Formula=(CalcCounter=1)
IfAboveValue=0
IfAboveAction=!SetVariable Meter1Tint #Colour2#
IfEqualValue=0
IfEqualAction=!SetVariable Meter1Tint #Colour1#

[CalcMeterImage1/2]
Measure=CALC
Formula=(CalcCounter=2)
IfAboveValue=0
IfAboveAction=!SetVariable Meter2Tint #Colour2#
IfEqualValue=0
IfEqualAction=!SetVariable Meter2Tint #Colour1#

[CalcMeterImage1/3]
Measure=CALC
Formula=(CalcCounter=3)
IfAboveValue=0
IfAboveAction=!SetVariable Meter3Tint #Colour2#
IfEqualValue=0
IfEqualAction=!SetVariable Meter3Tint #Colour1#

[CalcMeterImage1/4]
Measure=CALC
Formula=(CalcCounter=4)
IfAboveValue=0
IfAboveAction=!SetVariable Meter4Tint #Colour2#
IfEqualValue=0
IfEqualAction=!SetVariable Meter4Tint #Colour1#

[CalcMeterImage1/5]
Measure=CALC
Formula=(CalcCounter=5)
IfAboveValue=0
IfAboveAction=!SetVariable Meter5Tint #Colour2#
IfEqualValue=0
IfEqualAction=!SetVariable Meter5Tint #Colour1#

;===============================================================================================
;Measures
;===============================================================================================

;The actual Image Measure

[StyleImage]
ImageName=#ImageName#
X=(#ImageWidth#/5)r
Y=0r
W=[W]
H=#ImageHeight#
DynamicVariables=1

;===============================================================================================
;Meters
;===============================================================================================


;Putting the slices on screen, you can offset this is used as a background combined with clipping in the ImageWidth
& ImageHeight variables - whic is how I intend to use it...

[MeterImage1/1]
Meter=IMAGE
MeterStyle=StyleImage
X=0
Y=0
ImageCrop=[X1],0,[W],#ImageHeight#
ImageTint=#Meter1Tint#
DynamicVariables=1

[MeterImage1/2]
Meter=IMAGE
MeterStyle=StyleImage
ImageTint=#Meter2Tint#
DynamicVariables=1
ImageCrop=[X2],0,[W],#ImageHeight#

[MeterImage1/3]
Meter=IMAGE
MeterStyle=StyleImage
ImageTint=#Meter3Tint#
DynamicVariables=1
ImageCrop=[X3],0,[W],#ImageHeight#

[MeterImage1/4]
Meter=IMAGE
MeterStyle=StyleImage
ImageTint=#Meter4Tint#
DynamicVariables=1
ImageCrop=[X4],0,[W],#ImageHeight#

[MeterImage1/5]
Meter=IMAGE
MeterStyle=StyleImage
ImageTint=#Meter5Tint#
DynamicVariables=1
ImageCrop=[X5],0,[W],#ImageHeight#
smile.jpg
You do not have the required permissions to view the files attached to this post.
Last edited by Seahorse on July 20th, 2011, 12:02 pm, edited 2 times in total.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Animated Image Tint applied to an ImageCrop

Post by smurfier »

If I understand what you are doing properly...

Code: Select all

[Rainmeter]
Author=Smurfier
Update=1000

[Metadata]
Name=
Config=
Description=
Instructions=
Version=
Tags=
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Variant=
Preview=

[Variables]
Height=441
Width=532
Tint=0,255,0,255
Slices=5
Image=Smile.jpg

[cTimer]
Measure=Calc
Formula=(cTimer+1)%#Slices#

[cCrop]
Measure=Calc
Formula=(#Width#/#Slices#)*cTimer

[cWidth]
Measure=Calc
Formula=#Width#/#Slices#

[mBack]
Meter=Image
ImageName=#Image#

[mFront]
Meter=Image
ImageName=#Image#
ImageTint=#Tint#
W=[cWidth]
H=#Height#
ImageCrop=[cCrop],0,[cWidth],#Height#
X=[cCrop]
DynamicVariables=1
And if you want it to start with no tint then have 5 tinted bars, just change these two measures:

Code: Select all

[cTimer]
Measure=Calc
Formula=(cTimer+1)%(#Slices#+1)

[cCrop]
Measure=Calc
Formula=(#Width#/#Slices#)*(cTimer-1)
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Animated Image Tint applied to an ImageCrop

Post by Seahorse »

Holy crap! you do!

Same result with a third of the code, that is genius :thumbup:
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt