It is currently April 25th, 2024, 5:39 pm
Conditional Images? Is This Possible?
-
- Posts: 17
- Joined: December 2nd, 2019, 3:10 pm
Conditional Images? Is This Possible?
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.
-
- Posts: 908
- Joined: December 30th, 2015, 9:47 am
Re: Conditional Images? Is This Possible?
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.
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 mean you want to change color for a single image? Generally speaking, it is possible using IfCondition and ImageTint options. An example as follows.
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
Is this what you want?
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16169
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Conditional Images? Is This Possible?
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?
-
- Posts: 17
- Joined: December 2nd, 2019, 3:10 pm
Re: Conditional Images? Is This Possible?
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:
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>":"","PRE>":""," ":" ","'s Facebook Notifications":"","Top Stories - Google ":""
; Alternate substitution
WebParserSubstitute="<![CDATA[":"","]]>":"","/PRE>":"","PRE>":""," ":" ","'s Facebook Notifications":"","Top Stories - Google ":"",""":'"',"&":"&","'":"'","<":"<",">":">"," ":" ","¡":"¡","¢":"¢","£":"£","¤":"¤","¥":"¥","¦":"¦","§":"§","¨":"¨","©":"©","ª":"ª","«":"«","¬":"¬","­":" ","®":"®","¯":"¯","°":"°","±":"±","²":"²","³":"³","´":"´","µ":"µ","¶":"¶","·":"·","¸":"¸","¹":"¹","º":"º","»":"»","¼":"¼","½":"½","¾":"¾","¿":"¿","À":"À","Á":"Á","Â":"Â","Ã":"Ã","Ä":"Ä","Å":"Å","Æ":"Æ","Ç":"Ç","È":"È","É":"É","Ê":"Ê","Ë":"Ë","Ì":"Ì","Í":"Í","Î":"Î","Ï":"Ï","Ð":"Ð","Ñ":"Ñ","Ò":"Ò","Ó":"Ó","Ô":"Ô","Õ":"Õ","Ö":"Ö","×":"×","Ø":"Ø","Ù":"Ù","Ú":"Ú","Û":"Û","Ü":"Ü","Ý":"Ý","Þ":"Þ","ß":"ß","à":"à","á":"á","â":"â","ã":"ã","ä":"ä","å":"å","æ":"æ","ç":"ç","è":"è","é":"é","ê":"ê","ë":"ë","ì":"ì","í":"í","î":"î","ï":"ï","ð":"ð","ñ":"ñ","ò":"ò","ó":"ó","ô":"ô","õ":"õ","ö":"ö","÷":"÷","ø":"ø","ù":"ù","ú":"ú","û":"û","ü":"ü","ý":"ý","þ":"þ","ÿ":"ÿ","Œ":"Œ","œ":"œ","Š":"Š","š":"š","Ÿ":"Ÿ","ƒ":"ƒ","ˆ":"ˆ","˜":"˜","Α":"?","Β":"?","Γ":"G","Δ":"?","Ε":"?","Ζ":"?","Η":"?","Θ":"T","Ι":"?","Κ":"?","Λ":"?","Μ":"?","Ν":"?","Ξ":"?","Ο":"?","Π":"?","Ρ":"?","Σ":"S","Τ":"?","Υ":"?","Φ":"F","Χ":"?","Ψ":"?","Ω":"O","α":"a","β":"ß","γ":"?","δ":"d","ε":"e","ζ":"?","η":"?","θ":"?","ι":"?","κ":"?","λ":"?","μ":"µ","ν":"?","ξ":"?","ο":"?","π":"p","ρ":"?","ς":"?","σ":"s","τ":"t","υ":"?","φ":"f","χ":"?","ψ":"?","ω":"?","ϑ":"?","ϒ":"?","ϖ":"?"," ":" "," ":" "," ":" ","‌":" ","‍":" ","‎":" ","‏":" ","–":"–","—":"—","‘":"‘","’":"’","‚":"‚","“":"“","”":"”","„":"„","†":"†","‡":"‡","•":"•","…":"…","‰":"‰","′":"'","″":"?","‹":"‹","›":"›","‾":"?","⁄":"/","€":"€","ℑ":"I","℘":"P","ℜ":"R","™":"™","ℵ":"?","←":"?","↑":"?","→":"?","↓":"?","↔":"?","↵":"?","⇐":"?","⇑":"?","⇒":"?","⇓":"?","⇔":"?","∀":"?","∂":"?","∃":"?","∅":"Ø","∇":"?","∈":"?","∉":"?","∋":"?","∏":"?","∑":"?","−":"-","∗":"*","√":"v","∝":"?","∞":"8","∠":"?","∧":"?","∨":"?","∩":"n","∪":"?","∫":"?","∴":"?","∼":"~","≅":"?","≈":"˜","≠":"?","≡":"=","≤":"=","≥":"=","⊂":"?","⊃":"?","⊄":"?","⊆":"?","⊇":"?","⊕":"?","⊗":"?","⊥":"?","⋅":"·","⋮":"?","⌈":"?","⌉":"?","⌊":"?","⌋":"?","⟨":"<","⟩":">","◊":"?","♠":"?","♣":"?","♥":"?","♦":"?"
;---------------------------------------------------------------------
; 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
-
- Rainmeter Sage
- Posts: 16169
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Conditional Images? Is This Possible?
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.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...
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.
-
- Rainmeter Sage
- Posts: 7164
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Conditional Images? Is This Possible?
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...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.
-
- Posts: 17
- Joined: December 2nd, 2019, 3:10 pm
Re: Conditional Images? Is This Possible?
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
-
- Rainmeter Sage
- Posts: 16169
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Conditional Images? Is This Possible?
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]
-
- Rainmeter Sage
- Posts: 7164
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Conditional Images? Is This Possible?
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: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
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]
-
- Rainmeter Sage
- Posts: 16169
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Conditional Images? Is This Possible?
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.