It is currently March 29th, 2024, 9:07 am

Display image based on sunrise / sunset measures

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote::17good
Thank you very much !
Does it work?
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:Does it work?
Yes, now pie chart displays the size of the day and night correctly
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Yes, now pie chart displays the size of the day and night correctly
:17good I'm glad in this case.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

Hi,
I'd like to do something like this, but I do not know how:
sun.PNG
When it is the time of the sunrise, an icon appears, which, depending on the time, passes a circle arc from point A (where is the sunrise) to point B (where it is sunset) and then the icon disappears.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Hi,
I'd like to do something like this, but I do not know how:
sun.PNG
When it is the time of the sunrise, an icon appears, which, depending on the time, passes a circle arc from point A (where is the sunrise) to point B (where it is sunset) and then the icon disappears.
You have to create a few measures to can calculate a few things and have to create the appropriate meters. I've done all these, adding all necessary measures and meters to the 24H.ini skin of your DIGI DayNightClock package. I hope this is ok. Please check the code below:

Code: Select all

[Rainmeter]
Update=1000
;DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureFadeTime "Execute 1"][!CommandMeasure MeasureFadeTime "Execute 2"][!CommandMeasure MeasureFadeTime "Execute 3"]

[Metadata]
Name=DIGI DayNightClock
Author=xxenium
Information=Displays time, sunrise, sunset, length of day and night
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

@include="#@#Location.inc"

[MeasureQuote]
Measure=Plugin
Plugin=QuotePlugin
Path="#@#Location.inc"

[Variables]
UpdateRateSeconds=600
FontFace=century gothic

URL=#LocationURL#

W=20
U=[!UpdateMeasureGroup Faders][!UpdateMeterGroup Faders][!Redraw]
MinuteAlpha=255
HourAlpha=255

=============Measures=============

[MeasureSunrise]
Measure=WebParser
Url=#URL#
RegExp=(?siU)Sun rise: <strong>(.*)</strong>.*Sun set:  <strong>(.*)</strong>

UpdateRate=#UpdateRateSeconds#
StringIndex=1

[MeasureSunriseHour]
Measure=String
String=[MeasureSunrise]
RegExpSubstitute=1
Substitute="^(\d{1,2}):\d{1,2}$":"\1","^$":"0"
DynamicVariables=1

[MeasureSunriseMinute]
Measure=String
String=[MeasureSunrise]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1

[MeasureSunriseMoment]
Measure=Calc
Formula=( 60 * [MeasureSunriseHour] + [MeasureSunriseMinute] )
DynamicVariables=1

[MeasureSunset]
Measure=WebParser
Url=[MeasureSunrise]
StringIndex=2

[MeasureSunsetHour]
Measure=String
String=[MeasureSunset]
RegExpSubstitute=1
Substitute="^(\d{1,2}):\d{1,2}$":"\1","^$":"0"
DynamicVariables=1

[MeasureSunsetMinute]
Measure=String
String=[MeasureSunset]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1

[MeasureSunsetMoment]
Measure=Calc
Formula=( 60 * [MeasureSunsetHour] + [MeasureSunsetMinute] )
DynamicVariables=1

[MeasureHour]
Measure=Time
Format=%#H
OnChangeAction=[!CommandMeasure MeasureFadeTime "Execute 1"]

[MeasureMinute]
Measure=Time
Format=%M
OnChangeAction=[!CommandMeasure MeasureFadeTime "Execute 2"]

[MeasureSecond]
Measure=Time
Format=%S
OnChangeAction=[!CommandMeasure MeasureFadeTime "Execute 3"]

[MeasureSinceSunrise]
Measure=Calc
Formula=(( 60 * MeasureHour + MeasureMinute - MeasureSunriseMoment ) / MeasureDayLength )

[MeasureTime]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
IfCondition=((#CURRENTSECTION#>=MeasureSunriseMoment)&&(#CURRENTSECTION#<MeasureSunsetMoment))
IfTrueAction=[!ShowMeter "MeterSun"][!ShowMeter "SUN"][!HideMeter "MOON"][!ShowMeter "Bg1"][!HideMeter "Bg2"]
IfFalseAction=[!HideMeter "MeterSun"][!ShowMeter "MOON"][!HideMeter "SUN"][!ShowMeter "Bg2"][!HideMeter "Bg1"]

[MeasureDayLength]
Measure=Calc
Formula=( MeasureSunsetMoment - MeasureSunriseMoment )

[MeasureDayLengthHour]
Measure=Calc
Formula=( Floor ( MeasureDayLength / 60 ))

[MeasureDayLengthMinute]
Measure=Calc
Formula=( MeasureDayLength % 60 )

[MeasureNightLength]
Measure=Calc
Formula=( 1440 - MeasureSunsetMoment + MeasureSunriseMoment )

[MeasureNightLengthHour]
Measure=Calc
Formula=( Floor ( MeasureNightLength / 60 ))

[MeasureNightLengthMinute]
Measure=Calc
Formula=( MeasureNightLength % 60 )

[MeasureCurrent]
Measure=Calc
Formula=(60 * MeasureHour + MeasureMinute)

[MeasureToSunrise]
Measure=Calc
Formula=(MeasureSunriseMoment - MeasureCurrent)

[MeasureToSunset]
Measure=Calc
Formula=(MeasureSunsetMoment - MeasureCurrent)
IfCondition=((MeasureCurrent>MeasureSunriseMoment)&&(MeasureCurrent<MeasureSunsetMoment))
IfTrueAction=[!SetVariable "upordown" "Sunset"]
IfFalseAction=[!SetVariable "upordown" "Sunrise"]
DynamicVariables=1

[MeasureLeft]
Measure=Calc
Formula=(((MeasureToSunrise < 0) && (MeasureToSunset < 0)) ? ( 1440 + MeasureToSunrise ) : (((MeasureToSunrise < 0) && (MeasureToSunset > 0)) ? MeasureToSunset : MeasureToSunrise))

[MeasureLeftHours]
Measure=Calc
Formula=(Floor(MeasureLeft / 60))
IfCondition=MeasureLeftHours > 1
IfTrueAction=[!SetVariable "hour" "[MeasureLeftHours] hrs"]
IfFalseAction=[!SetVariable "hour" "[MeasureLeftHours] hr"]
IfConditionMode=1

[MeasureLeftMin]
Measure=Calc
Formula=(MeasureLeft - 60 * MeasureLeftHours)
IfCondition=(MeasureLeftMin > 1)
IfTrueAction=[!SetVariable "min" "[MeasureLeftMin] mins"]
IfFalseAction=[!SetVariable "min" "[MeasureLeftMin] min"]
IfConditionMode=1

[MeasureDate]
Measure=Time
Format=%a, %b %d
Substitute="01":"1","02":"2","03":"3","04":"4","05":"5","06":"6","07":"7","08":"8","09":"9"

[MeasureFadeTime]
Measure=Plugin
Plugin=ActionTimer
Group=Faders
ActionList1=SetHoursTo1|Wait #W#|Repeat SetHoursCalc, #W#, 13
SetHoursTo1=[!SetVariable HourAlpha "1"]#U#
SetHoursCalc=[!SetVariable HourAlpha "(Min(#HourAlpha#+20,255))"]#U#
ActionList2=SetMinutesTo1|Wait #W#|Repeat SetMinutesCalc, #W#, 13
SetMinutesTo1=[!SetVariable MinuteAlpha "1"]#U#
SetMinutesCalc=[!SetVariable MinuteAlpha "(Min(#MinuteAlpha#+20,255))"]#U#
ActionList3=SetSecondsTo1|Wait #W#|Repeat SetSecondsCalc, #W#, 13
SetSecondsTo1=[!SetVariable SecondAlpha "1"]#U#
SetSecondsCalc=[!SetVariable SecondAlpha "(Min(#SecondAlpha#+20,255))"]#U#
IgnoreWarnings=1
DynamicVariables=1


==============Meters===================================

[Bg1]
Meter=Image
X=0
Y=0
ImageName=#@#bg1.png 
Hidden=1

[Bg2]
Meter=Image
X=0
Y=0
ImageName=#@#bg2.png
Hidden=1 

[MeterSunrise]
Meter=String
MeasureName=MeasureSunrise
X=6
Y=93
W=120
H=60
FontSize=8
FontColor=255,255,255,255
StringStyle=Bold
StringEffect=SHADOW
FontFace=century gothic
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
Prefix="Sunrise: "
InlineSetting=Color | 255,255,255,190
InlinePattern=(?U)^(.*):.*

[MeterSunset]
Meter=String
MeasureName=MeasureSunset
X=6
Y=15r
W=120
H=60
FontSize=8
FontColor=255,255,255,255
StringStyle=Bold
StringEffect=SHADOW
FontFace=century gothic
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
Prefix="Sunset: "
InlineSetting=Color | 255,255,255,190
InlinePattern=(?U)^(.*):.*

[MeterDayLength]
Meter=String
MeasureName=MeasureDayLengthHour
MeasureName2=MeasureDayLengthMinute
X=6
Y=15r
W=120
H=60
FontSize=8
FontColor=255,255,255,255
StringStyle=Bold
StringEffect=SHADOW
FontFace=century gothic
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
Prefix="Day Length: "
Text="%1 h %2 min"
InlineSetting=Color | 255,255,255,190
InlinePattern=(?U)^(.*):.*
InlineSetting2=Size | 7
InlinePattern2=h
InlineSetting3=Size | 7
InlinePattern3=min

[MeterNightLength]
Meter=String
MeasureName=MeasureNightLengthHour
MeasureName2=MeasureNightLengthMinute
X=6
Y=15r
W=120
H=60
FontSize=8
FontColor=255,255,255,255
StringStyle=Bold
StringEffect=SHADOW
FontFace=century gothic
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
Prefix="Night Length: "
Text="%1 h %2 min"
InlineSetting=Color | 255,255,255,190
InlinePattern=(?U)^(.*):.*
InlineSetting2=Size | 7
InlinePattern2=h
InlineSetting3=Size | 7
InlinePattern3=min

[MeterHoursRem]
Meter=String
MeasureName=MeasureLeftHours
MeasureName2=MeasureLeftMin
X=6
Y=64
FontSize=8
FontColor=255,255,0
FontFace=century gothic
StringAlign=left
StringStyle=BoldItalic
FontEffectColor=0,0,0,50
AntiAlias=1
Text=#hour# #min# #CRLF# until #upordown#
DynamicVariables=1

[SUN]
Meter=Image
ImageName=#@#sun.png
X=116
Y=73
Hidden=1
LeftMouseUpAction=!ToggleConfig "DIGI DayNightClock\Settings" "Settings.ini"

[MOON]
Meter=Image
ImageName=#@#moon.png
X=115
Y=73
Hidden=1
LeftMouseUpAction=!ToggleConfig "DIGI DayNightClock\Settings" "Settings.ini"

[MeterHour]
Meter=String
MeasureName=MeasureHour
Group=Faders
X=87
Y=0
FontSize=25
StringAlign=right
StringStyle=bold
FontFace=century gothic
FontColor=255,255,255,#HourAlpha#
SolidColor=0,0,0,1
AntiAlias=1
UpdateDivider=-1
DynamicVariables=1

[MeterColon]
Meter=String
X=16r
Y=0
FontSize=25
StringAlign=right
StringStyle=bold
FontFace=century gothic
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=:

[MeterMinute]
Meter=String
MeasureName=MeasureMinute
Group=Faders
X=42r
Y=0
FontSize=25
StringAlign=right
StringStyle=bold
FontFace=century gothic
FontColor=255,255,255,#MinuteAlpha#
SolidColor=0,0,0,1
AntiAlias=1
UpdateDivider=-1
DynamicVariables=1

[MeterSecond]
Meter=String
MeasureName=MeasureSecond
Group=Faders
X=25r
Y=17
FontSize=12
StringAlign=right
StringStyle=bold
FontFace=century gothic
FontColor=255,255,255,#SecondAlpha#
SolidColor=0,0,0,1
AntiAlias=1
UpdateDivider=-1
DynamicVariables=1

[MeterDate]
Meter=STRING
MeasureName=MeasureDate
X=171
Y=20r
FontSize=12
FontColor=255,255,255,240
StringAlign=right
StringStyle=BoldItalic
FontFace=century gothic
FontEffectColor=0,0,0,50
AntiAlias=1

[MeterSoil]
Meter=Shape
X=0
Y=250
Shape=Line 0,0,178,0 | Extend MyModifiers1
Shape2=Line 2,1,180,1 | Extend MyModifiers2
MyModifiers1=StrokeWidth 2 | Stroke Color 220,220,220
MyModifiers2=StrokeWidth 2 | Stroke Color 0,0,0,80
UpdateDivider=-1

[MeterSunPath]
Meter=Shape
X=0r
Y=0r
Shape=Arc 9,0,168,0,80,80 | Extend MyModifiers1
Shape2=Arc 11,1,170,1,80,80 | Extend MyModifiers2
MyModifiers1=StrokeWidth 2 | Stroke Color 220,220,220
MyModifiers2=StrokeWidth 2 | Stroke Color 0,0,0,80
UpdateDivider=-1

[MeterSun]
Meter=Shape
X=0r
Y=0r
Shape=Ellipse (10+160*[MeasureSinceSunrise]),(10*(1-Abs(2*[MeasureSinceSunrise]-1))-80*Sin(Acos(2*[MeasureSinceSunrise]-1))),10 | StrokeWidth 1 | Fill RadialGradient MyGradient1
MyGradient1=3,2 | 255,180,0 ; 0.0 | 210,210,0 ; 1.0
DynamicVariables=1
It's not yet perfect, especially not the Sun positioning. But before I start to improve it, I'd like to know if this feats your needs.
I commented out the DynamicWindowSize=1 option of the [Rainmeter] section, because on skins with a static background (like this one), this option isn't needed.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:It's not yet perfect, especially not the Sun positioning. But before I start to improve it, I'd like to know if this feats your needs.
:17good
That's great !
It's exactly what I wanted !
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:It's exactly what I wanted !
Great. But as I said there are things which should have to (or even must) be improved. I hope I will come back with some.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

Hi,
I have noticed that there is an error in Log :

[MeasureSinceSunrise] -Calc: Division by 0
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Hi,
I have noticed that there is an error in Log :

[MeasureSinceSunrise] -Calc: Division by 0
This is caused by the fact that at the very first moment the [MeasureDayLength] doesn't return a value (because it return one, only when the WebParser measures get their values), so in the Formula of the [MeasureSinceSunrise] measure, a division by 0 is done.
There is an extremely simple solution: add an extremely small, but non zero value to the denominator of the above formula. This small value has to be so small, to not change the result, but to avoid the error. For example: Formula=(( 60 * MeasureHour + MeasureMinute - MeasureSunriseMoment ) / ( 0.00001 + MeasureDayLength )).
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:This is caused by the fact that at the very first moment the [MeasureDayLength] doesn't return a value (because it return one, only when the WebParser measures get their values), so in the Formula of the [MeasureSinceSunrise] measure, a division by 0 is done.
There is an extremely simple solution: add an extremely small, but non zero value to the denominator of the above formula. This small value has to be so small, to not change the result, but to avoid the error. For example: Formula=(( 60 * MeasureHour + MeasureMinute - MeasureSunriseMoment ) / ( 0.00001 + MeasureDayLength )).
Ok, I understand.
Thank you