It is currently April 18th, 2024, 12:51 pm

Conditional Images? Is This Possible?

Get help with creating, editing & fixing problems with skins
tjhuntley
Posts: 17
Joined: December 2nd, 2019, 3:10 pm

Conditional Images? Is This Possible?

Post by tjhuntley »

I have widgets that pull info from a spreadsheet to my desktop. The image used is currently white. I want them to remain white while the info pulled is a "0" value and red when it goes above "0". I am new but guessing the best way to do this is to have a white and red image along with an "if" formula. I know nothing about Rainmeter and I am also guessing that if this is possible there is a simple answer for some of you pros.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Conditional Images? Is This Possible?

Post by mak_kawa »

Hi tjhuntley

You mean you want to change color for a single image? Generally speaking, it is possible using IfCondition and ImageTint options. An example as follows.
Untitled-1.png

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=128,128,128,128

[Variables]
Red=255,0,0
White=255,255,255
Value=10

[MeasureValue]
Measure=Calc
Formula=#Value#
IfCondition=(MeasureValue=0)
IfTrueAction=[!SetOption MeterImage ImageTint #White#]
IfCondition2=(MeasureValue>0)
IfTrueAction2=[!SetOption MeterImage ImageTint #Red#]
DynamicVariables=1

[MeterImage]
Meter=Image
ImageName=test.png
ImageTint=255,255,255,255
X=5
Y=5
W=50
H=50

[MeterValue]
Meter=String
FontColor=0,0,0,255
X=10
Y=10
W=20
H=15
Text=#Value#
DynamicVariables=1
DynamicVariables=1 option is not needed for above code, but necessary when you get dynamic value from outside, possibly.

Is this what you want?
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Images? Is This Possible?

Post by balala »

tjhuntley wrote: March 25th, 2020, 6:16 am I have widgets that pull info from a spreadsheet to my desktop.
Not sure how could you get information from a spreadsheet. Rainmeter natively is not capable of working with any kind of spreadsheet. It can read information from plain text files, but not from spreadsheets. So, the first question, beside mak_kawa's reply, is if you have any approach on how to pull the needed information from the spreadsheet?
tjhuntley
Posts: 17
Joined: December 2nd, 2019, 3:10 pm

Re: Conditional Images? Is This Possible?

Post by tjhuntley »

I guess I should have said calendar because I am doing a workaround to get the spreadsheet's info onto my desktop. I am using Google Sheets and sending the info to my Google Calendar and then I have modified the Gcal meter to get the info.

That is EXACTLY what I need above. I have tried to add this to my existing code but I have limited knowledge of Rainmeter and how it works. If you have time, maybe you can tell me if there is something in my code preventing this from changing to red when the value goes above zero... Here is the code I am using:

Code: Select all

[Rainmeter]
MiddleMouseUpAction=!Refresh
LeftMouseDoubleClickAction=!ActivateConfig #CURRENTCONFIG#

[Variables]



;-----------------------
; FEEDS

; GoogleCalendar1=https://calendar.google.com/calendar/ical/.../full.ics
GoogleCalendar1=https://calendar.google.com/calendar/ical/cduyrrt80kkabc123abc123abc123%33group.calendar.google.com/private-31555abv67yyyyabc123abc123abc123/basic.ics

;--------------------------------------------------------------------------------------------


; ENIGMA DARK

Color1=255,255,255
Color2=#Color1#,160
Color3=#Color1#,108
Color4=#Color1#,25
ColorLink=128,192,255
ColorLink2=#ColorLink#,217
ColorLink3=#ColorLink#,160
ColorBorder=192, 192, 192
ColorBorder2=#ColorBorder#, 128
ColorBorder3=#ColorBorder#, 92
ColorBorder4=#ColorBorder#, 64
ColorPanel=24,24,24
ColorPanel2=#ColorPanel#,128
ColorFilter=0,0,0
ColorFilter2=#ColorFilter#,192
ColorFilter3=#ColorFilter#,128
ColorEvent=255,0,0
ColorEvent2=#ColorEvent#,92
ColorTransparent=0,0,0,2
ColorImage=W


Size1=23
Size4=11
Size3=9
Size2=10
Font=Open Sans
SkinBackgroundAlpha=0
HideBordersTop=1
HideBordersBottom=1

SidebarWidth=275
SidebarSpacingFixed=1
SidebarAlpha=128
SidebarImage=#@#Images\Sidebar\SidebarLeft.#ColorImage#.jpg
SecondSidebarImage=#@#Images\Sidebar\SidebarRight.#ColorImage#.jpg

;-----------------------
; GENERAL

TriptychInterval=30
TriptychDisabled=0
ProcessInterval=5

SkinMouseOver=0
Reset=1
SwitcherInterval=30
SwitcherDisabled=0
SwitcherInterval=#TriptychInterval#
SwitcherAction=!CommandMeasure "MeasureScriptReader" "ShowNext()"
SwitcherDisabled=#TriptychDisabled#

GoogleCalendarWriteEvents=0
CurrentFeed=1

; 1~3 tabs
NumberOfTabs=1
; 1~8 items
NumOfItems=8
ReaderURL1=#GoogleCalendar1#?futureevents=true&singleevents=true&orderby=starttime&sortorder=a
ReaderURL2=#GoogleCalendar2#?futureevents=true&singleevents=true&orderby=starttime&sortorder=a
ReaderURL3=#GoogleCalendar3#?futureevents=true&singleevents=true&orderby=starttime&sortorder=a
ReaderUpdateRate=60
ReaderWriteEvents=#GoogleCalendarWriteEvents#
ReaderEventFile=#@#User\Calendars\GoogleCalendar1.xml|#@#User\Calendars\GoogleCalendar2.xml|#@#User\Calendars\GoogleCalendar3.xml

FeedTitle=Loading...
Item1Title=
Item1Date=



; WebParserSubstitute="<![CDATA[":"","]]>":"","/PRE&gt;":"","PRE&gt;":"","&nbsp;":" ","'s Facebook Notifications":"","Top Stories - Google ":""

; Alternate substitution
WebParserSubstitute="<![CDATA[":"","]]>":"","/PRE&gt;":"","PRE&gt;":"","&nbsp;":" ","'s Facebook Notifications":"","Top Stories - Google ":"","&quot;":'"',"&amp;":"&","&apos;":"'","&lt;":"<","&gt;":">","&nbsp;":" ","&iexcl;":"¡","&cent;":"¢","&pound;":"£","&curren;":"¤","&yen;":"¥","&brvbar;":"¦","&sect;":"§","&uml;":"¨","&copy;":"©","&ordf;":"ª","&laquo;":"«","&not;":"¬","&shy;":" ","&reg;":"®","&macr;":"¯","&deg;":"°","&plusmn;":"±","&sup2;":"²","&sup3;":"³","&acute;":"´","&micro;":"µ","&para;":"¶","&middot;":"·","&cedil;":"¸","&sup1;":"¹","&ordm;":"º","&raquo;":"»","&frac14;":"¼","&frac12;":"½","&frac34;":"¾","&iquest;":"¿","&Agrave;":"À","&Aacute;":"Á","&Acirc;":"Â","&Atilde;":"Ã","&Auml;":"Ä","&Aring;":"Å","&AElig;":"Æ","&Ccedil;":"Ç","&Egrave;":"È","&Eacute;":"É","&Ecirc;":"Ê","&Euml;":"Ë","&Igrave;":"Ì","&Iacute;":"Í","&Icirc;":"Î","&Iuml;":"Ï","&ETH;":"Ð","&Ntilde;":"Ñ","&Ograve;":"Ò","&Oacute;":"Ó","&Ocirc;":"Ô","&Otilde;":"Õ","&Ouml;":"Ö","&times;":"×","&Oslash;":"Ø","&Ugrave;":"Ù","&Uacute;":"Ú","&Ucirc;":"Û","&Uuml;":"Ü","&Yacute;":"Ý","&THORN;":"Þ","&szlig;":"ß","&agrave;":"à","&aacute;":"á","&acirc;":"â","&atilde;":"ã","&auml;":"ä","&aring;":"å","&aelig;":"æ","&ccedil;":"ç","&egrave;":"è","&eacute;":"é","&ecirc;":"ê","&euml;":"ë","&igrave;":"ì","&iacute;":"í","&icirc;":"î","&iuml;":"ï","&eth;":"ð","&ntilde;":"ñ","&ograve;":"ò","&oacute;":"ó","&ocirc;":"ô","&otilde;":"õ","&ouml;":"ö","&divide;":"÷","&oslash;":"ø","&ugrave;":"ù","&uacute;":"ú","&ucirc;":"û","&uuml;":"ü","&yacute;":"ý","&thorn;":"þ","&yuml;":"ÿ","&OElig;":"Œ","&oelig;":"œ","&Scaron;":"Š","&scaron;":"š","&Yuml;":"Ÿ","&fnof;":"ƒ","&circ;":"ˆ","&tilde;":"˜","&Alpha;":"?","&Beta;":"?","&Gamma;":"G","&Delta;":"?","&Epsilon;":"?","&Zeta;":"?","&Eta;":"?","&Theta;":"T","&Iota;":"?","&Kappa;":"?","&Lambda;":"?","&Mu;":"?","&Nu;":"?","&Xi;":"?","&Omicron;":"?","&Pi;":"?","&Rho;":"?","&Sigma;":"S","&Tau;":"?","&Upsilon;":"?","&Phi;":"F","&Chi;":"?","&Psi;":"?","&Omega;":"O","&alpha;":"a","&beta;":"ß","&gamma;":"?","&delta;":"d","&epsilon;":"e","&zeta;":"?","&eta;":"?","&theta;":"?","&iota;":"?","&kappa;":"?","&lambda;":"?","&mu;":"µ","&nu;":"?","&xi;":"?","&omicron;":"?","&pi;":"p","&rho;":"?","&sigmaf;":"?","&sigma;":"s","&tau;":"t","&upsilon;":"?","&phi;":"f","&chi;":"?","&psi;":"?","&omega;":"?","&thetasym;":"?","&upsih;":"?","&piv;":"?","&ensp;":" ","&emsp;":" ","&thinsp;":" ","&zwnj;":" ","&zwj;":" ","&lrm;":" ","&rlm;":" ","&ndash;":"–","&mdash;":"—","&lsquo;":"‘","&rsquo;":"’","&sbquo;":"‚","&ldquo;":"“","&rdquo;":"”","&bdquo;":"„","&dagger;":"†","&Dagger;":"‡","&bull;":"•","&hellip;":"…","&permil;":"‰","&prime;":"'","&Prime;":"?","&lsaquo;":"‹","&rsaquo;":"›","&oline;":"?","&frasl;":"/","&euro;":"€","&image;":"I","&weierp;":"P","&real;":"R","&trade;":"™","&alefsym;":"?","&larr;":"?","&uarr;":"?","&rarr;":"?","&darr;":"?","&harr;":"?","&crarr;":"?","&lArr;":"?","&uArr;":"?","&rArr;":"?","&dArr;":"?","&hArr;":"?","&forall;":"?","&part;":"?","&exist;":"?","&empty;":"Ø","&nabla;":"?","&isin;":"?","&notin;":"?","&ni;":"?","&prod;":"?","&sum;":"?","&minus;":"-","&lowast;":"*","&radic;":"v","&prop;":"?","&infin;":"8","&ang;":"?","&and;":"?","&or;":"?","&cap;":"n","&cup;":"?","&int;":"?","&there4;":"?","&sim;":"~","&cong;":"?","&asymp;":"˜","&ne;":"?","&equiv;":"=","&le;":"=","&ge;":"=","&sub;":"?","&sup;":"?","&nsub;":"?","&sube;":"?","&supe;":"?","&oplus;":"?","&otimes;":"?","&perp;":"?","&sdot;":"·","&vellip;":"?","&lceil;":"?","&rceil;":"?","&lfloor;":"?","&rfloor;":"?","&lang;":"<","&rang;":">","&loz;":"?","&spades;":"?","&clubs;":"?","&hearts;":"?","&diams;":"?"


;---------------------------------------------------------------------
; STYLES

[StyleReaderText]
;*SLIDES TEXT LEFT AND RIGHT*
Meter=String
StringAlign=Center
X=37
ClipString=1
StringStyle=NORMAL
FontColor=#Color1#
FontSize=#Size3#
FontFace=#Font#
AntiAlias=1
DynamicVariables=1


[StyleReaderTextSubheading]
;*CHANGE LINE SPACING*
Y=23r
;*ITALIC OR BOLD*
StringStyle=NORMAL
[StyleReaderTextFirst]
;*SLIDES ALL TEXT UP AND DOWN*
Y=47

[StyleReaderSubtext]
X=22
Y=14r
H=14
W=(#SidebarWidth#-34)
ClipString=1
StringStyle=NORMAL
FontColor=#Color2#
FontSize=#Size4#
FontFace=#Font#
AntiAlias=1
ToolTipWidth=#SidebarWidth#
DynamicVariables=1


;-----------------------
; GRABBERS

[StyleReaderGrabber]
X=R
Y=r
H=15
W=15
DynamicVariables=1

[StyleReaderGrabberFirst]
X=(#SidebarWidth#-(#NumberOfTabs#*15)-10)
Y=-7r

[StyleReaderGrabber0]
ImageName=#@#Images\Grabber.#ColorImage#.png
ImageAlpha=128
ToolTipWidth=#SidebarWidth#
ToolTipText=Click to switch to this page.

[StyleReaderGrabber1]
ImageName=#@#Images\GrabberActive.#ColorImage#.png

;---------------------------------------------------------------------
; MEASURES

;-----------------------

[MeasureScriptReader]
Measure=Script
ScriptFile="#@#Measures\Reader.lua"
MeasureName=MeasureFeed1
MinItems=#NumOfItems#
WriteEvents=#ReaderWriteEvents#
EventFile=#ReaderEventFile#
FinishAction=[!UpdateMeasureGroup "FeedData"][!UpdateMeterGroup "FeedData"][!Redraw][!SetVariable Reset 0]

[MeasureActivateTabs]
Measure=Script
ScriptFile=#@#Measures\Tabs.lua
UpdateDivider=-1
Type=Reader
TotalTabs=1

[MeasureFeed1]
Measure=Plugin
Plugin=WebParser
UpdateRate=#ReaderUpdateRate#
URL=#ReaderURL1#
RegExp=(?siU)(.*)$
DecodeCharacterReference=1
Substitute=#WebParserSubstitute#
FinishAction=!CommandMeasure MeasureScriptReader Refresh(1)

[MeasureFeed2]
Measure=Plugin
Plugin=WebParser
UpdateRate=#ReaderUpdateRate#
URL=#ReaderURL2#
RegExp=(?siU)(.*)$
DecodeCharacterReference=1
Substitute=#WebParserSubstitute#
FinishAction=!CommandMeasure MeasureScriptReader Refresh(2)
Group=Tab2
Disabled=1

[MeasureFeed3]
Measure=Plugin
Plugin=WebParser
UpdateRate=#ReaderUpdateRate#
URL=#ReaderURL3#
RegExp=(?siU)(.*)$
DecodeCharacterReference=1
Substitute=#WebParserSubstitute#
FinishAction=!CommandMeasure MeasureScriptReader Refresh(3)
Group=Tab3
Disabled=1

[MeasureActive1]
Measure=Calc
Formula=#CurrentFeed#=1
DynamicVariables=1
Group=FeedData | Tab2
Disabled=1

[MeasureActive2]
Measure=Calc
Formula=#CurrentFeed#=2
DynamicVariables=1
Group=FeedData | Tab2
Disabled=1

[MeasureActive3]
Measure=Calc
Formula=#CurrentFeed#=3
DynamicVariables=1
Group=FeedData | Tab3
Disabled=1

;---------------------------------------------------------------------
; METERS

[Background]
Meter=IMAGE
ImageName=#@#Images\SkinBackground.#ColorImage#.png
ScaleMargins=12,12,12,12
ImageAlpha=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageAlpha #SkinBackgroundAlpha#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageAlpha 1][!UpdateMeter #CURRENTSECTION#][!Redraw]
W=#SidebarWidth#
H=(39 * #NumOfItems#)

[Border]
Meter=IMAGE
SolidColor=#ColorBorder4#
X=10
Y=0
W=(#SidebarWidth#-26)
H=1
Hidden=#HideBordersTop#

[Icon]
Meter=IMAGE
Group=FeedData
ImageName=#@#Images\Gcal.#ColorImage#.png
X=0
Y=6
W=73
H=73


[Title]
Meter=STRING
Group=FeedData
X=11
Y=28
H=15
W=(#SidebarWidth#-0)
ClipString=1
StringStyle=NORMAL
FontColor=#Color1#
FontSize=#Size3#
FontFace=#Font#
AntiAlias=1
ToolTipWidth=#SidebarWidth#
DynamicVariables=1
Text=#FeedTitle#
LeftMouseUpAction=["https://docs.google.com/spreadsheets/d/1234567890abcdefghijklmnopqrstuvwxyzebrasarecool"]
ToolTipText=#FeedLink#

;-----------------------
; ITEMS

[ItemWhat1]
Meter=STRING
Group=FeedData
MeterStyle=StyleReaderText | StyleReaderTextSubheading | StyleReaderTextFirst
Text=#Item1Title#



;-----------------------
; BORDER & GRABBERS

[BorderBottom]
Meter=IMAGE
SolidColor=#ColorBorder4#
X=10
Y=40r
W=(#SidebarWidth#-26)
H=1
Hidden=#HideBordersBottom#

[Grabber1]
Meter=IMAGE
MeterStyle=StyleReaderGrabber | StyleReaderGrabber[MeasureActive1] | StyleReaderGrabberFirst
LeftMouseUpAction=!CommandMeasure "MeasureScriptReader" "Show(1)"
Group=FeedData | Tab2
Hidden=1

[Grabber2]
Meter=IMAGE
MeterStyle=StyleReaderGrabber | StyleReaderGrabber[MeasureActive2]
LeftMouseUpAction=!CommandMeasure "MeasureScriptReader" "Show(2)"
Group=FeedData | Tab2
Hidden=1

[Grabber3]
Meter=IMAGE
MeterStyle=StyleReaderGrabber | StyleReaderGrabber[MeasureActive3]
LeftMouseUpAction=!CommandMeasure "MeasureScriptReader" "Show(3)"
Group=FeedData | Tab3
Hidden=1

[Switcher]
Measure=CALC
Formula=((Switcher+1-#SkinMouseOver#) % (#SwitcherInterval#+2)) * #Reset#
IfBelowValue=1
IfBelowAction=!SetVariable Reset 1
IfAboveValue=#SwitcherInterval#
IfAboveAction=#SwitcherAction#
DynamicVariables=1
Disabled=#SwitcherDisabled#



;---------------------------------------------------------------------
; METADATA

[Metadata]
Name=Google Calendar
Information=Shows upcoming events on your Google Calendars in rotating tabs. Based on Enigma GCal by Kaelri
Version=5.0
License=Creative Commons BY-NC-SA 3.0
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Images? Is This Possible?

Post by balala »

tjhuntley wrote: March 25th, 2020, 11:58 am I guess I should have said calendar because I am doing a workaround to get the spreadsheet's info onto my desktop. I am using Google Sheets and sending the info to my Google Calendar and then I have modified the Gcal meter to get the info.
So, you're getting the information online, through WebParser measures. That's another thing...
tjhuntley wrote: March 25th, 2020, 11:58 am That is EXACTLY what I need above. I have tried to add this to my existing code but I have limited knowledge of Rainmeter and how it works. If you have time, maybe you can tell me if there is something in my code preventing this from changing to red when the value goes above zero...
There is nothing in your code which would do this change (at least I couldn't identify it). But I can't even get your code working, especially that there are needed a few files I don't have, for instance @Resources\Measures\Reader.lua or @Resources\Measures\Tabs.lua. As said, I also don't see where the IfCondition proposed by mak_kawa to be added, are added. Even if you add them, you probably won't get them working, because adding them to a Calc measure (as mak_kawa posted in his code) is a completely different thing than adding them to a WebParser measure. But it definitely is possible, just we should get the skin working.
So, in order to can give good advice, please pack the whole config you have (the folder in the Skins folder, which contains the .ini file with the above code, as well as the @Resources folder, with the two .lua files) and upload the package here. This way we'll have the needed files and I hope we'll get the skin working.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Conditional Images? Is This Possible?

Post by Yincognito »

balala wrote: March 25th, 2020, 6:23 pm So, you're getting the information online, through WebParser measures. That's another thing...

There is nothing in your code which would do this change (at least I couldn't identify it). But I can't even get your code working, especially that there are needed a few files I don't have, for instance @Resources\Measures\Reader.lua or @Resources\Measures\Tabs.lua. As said, I also don't see where the IfCondition proposed by mak_kawa to be added, are added. Even if you add them, you probably won't get them working, because adding them to a Calc measure (as mak_kawa posted in his code) is a completely different thing than adding them to a WebParser measure. But it definitely is possible, just we should get the skin working.
So, in order to can give good advice, please pack the whole config you have (the folder in the Skins folder, which contains the .ini file with the above code, as well as the @Resources folder, with the two .lua files) and upload the package here. This way we'll have the needed files and I hope we'll get the skin working.
The skin he's talking about is eclectic tech's Google Calendar, so there isn't any problem in having all the files, with a little intuition. But, yes, there is another problem, which is knowing which one of the images there the OP wants to become red. Anyway, I have the feeling that if he's talking about one of the images that already exist in that skin's @Resources folder and the red color is not something that's subject to change, an easier way to accomplish this would be to just edit the desired image and turn it red in an image editing program...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
tjhuntley
Posts: 17
Joined: December 2nd, 2019, 3:10 pm

Re: Conditional Images? Is This Possible?

Post by tjhuntley »

Thanks. You guys are awesome. I am just starting to learn this and listening to you two is helping a lot.... and yes, that is the meter I am using, just modified a bit. That is what I was originally thinking, having two images, one white and one red. Then have an ifcondition or something similar to have it white on "0" then change it to the red image if it goes above "0". This is the part of code that adds the image:

Code: Select all

[Icon]
Meter=IMAGE
Group=FeedData
ImageName=#@#Images\Gcal.#ColorImage#.png
X=0
Y=6
W=73
H=73
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Images? Is This Possible?

Post by balala »

tjhuntley wrote: March 27th, 2020, 8:29 pm That is what I was originally thinking, having two images, one white and one red. Then have an ifcondition or something similar to have it white on "0" then change it to the red image if it goes above "0". This is the part of code that adds the image:
Yes, in this case you can use mak_kawa's code, modifying it a little bit. The essence is to add the IfConditions to the appropriate WebParser measure, which is returning the numeric value which has to be compared with 0. Another possibility is to modify the code of the [Icon] meter, to use not the #ColorImage# variable into its ImageName option, but directly the appropriate WebParser measure (as said, I'm not sure which measure is that one).
For instance here is a solution for the ImageName option, which might work only if the values returned by the WebParser measure are right: ImageName=#@#Images\Gcal.[MeasureWebParser].png (requires to add a DynamicVariables=1 option to the [Icon] meter as well). Obviously you have to replace the [MeasureWebParser] section variable with the appropriate measure name and have to ensure that the values returned by this measure match the names of the image files existing into the @Resources\Images folder.
Alternatively you could modify mak_kawa's IfConditions, adding them to the appropriate WebParser measure, which returns the value which has to be compared by 0. For instance:

Code: Select all

[MeasureWebParser]
Measure=WebParser
...
IfCondition=(MeasureValue>0)
IfTrueAction=[!SetOption Icon ImageName "#@#Images\Gcal.1.png"][!UpdateMeter "Icon"][!Redraw]
IfFalseAction=[!SetOption Icon ImageName "#@#Images\Gcal.0.png"][!UpdateMeter "Icon"][!Redraw]
As you can see, there are more possible soltions and a lot of details have to be taken into account when choosing any solution. Which one would be the best for you, depends on a lot of things. Not getting the posted code working, me personally unfortunately can't give you more advices. Sorry...
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Conditional Images? Is This Possible?

Post by Yincognito »

tjhuntley wrote: March 27th, 2020, 8:29 pm Thanks. You guys are awesome. I am just starting to learn this and listening to you two is helping a lot.... and yes, that is the meter I am using, just modified a bit. That is what I was originally thinking, having two images, one white and one red. Then have an ifcondition or something similar to have it white on "0" then change it to the red image if it goes above "0". This is the part of code that adds the image:

Code: Select all

[Icon]
Meter=IMAGE
Group=FeedData
ImageName=#@#Images\Gcal.#ColorImage#.png
X=0
Y=6
W=73
H=73
Balala's advice is correct: I also use a similar code to the one he posted in one of my skins. More to the point, if by any chance the "value" you want compared to 0 is the one provided by the [MeasureActive1] measure (this is the only one I could think of, since it's dynamically changing after a "counter" reaches 30 seconds) and you have a photoshop-ed red image ready (say, Gcal.R.png in the @Resources\Images path from your skin - where the black and white images are located as well), then the code for that measure would become:

Code: Select all

[MeasureActive1]
Measure=Calc
Formula=#CurrentFeed#=1
DynamicVariables=1
Group=FeedData | Tab2
Disabled=1
IfCondition=(MeasureActive1>0)
IfTrueAction=[!SetOption Icon ImageName "#@#Images\Gcal.R.png"][!UpdateMeter "Icon"][!Redraw]
IfFalseAction=[!SetOption Icon ImageName "#@#Images\Gcal.#ColorImage#.png"][!UpdateMeter "Icon"][!Redraw]
Something like balala's version, but keeping the (and probably white) Gcal.#ColorImage#.png image unchanged if the measure's value is 0.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Images? Is This Possible?

Post by balala »

Yincognito wrote: March 27th, 2020, 11:41 pm you have a photoshop-ed red image ready
Another possible approach to apply different colors to an image is to recolor the image through ColorMatrix options. Not a simple and obvious possibility, but it is one.