It is currently April 25th, 2024, 1:58 am

Display image based on sunrise / sunset measures

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

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Ok, I understand.
Thank you
Have the error gone?
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:Have the error gone?
Yeah, no longer it appears.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

:thumbup: I'm glad. :thumbup:
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote: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.
Some news ? :D
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Some news ? :D
Not too much. I'd extend the backgrounds, to cover the Sun path, too. For this you have to stretch those two images (bg1.png and bg2.png).
Beside this, I also rewrote a few things in the 24H.ini skin. Here is what I got:

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

[Variables]
UpdateRateSeconds=600
FontFace=century gothic
URL=#LocationURL#
W=20
U=[!UpdateMeasureGroup Faders][!UpdateMeterGroup Faders][!Redraw]
MinuteAlpha=255
HourAlpha=255

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

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

[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 ) / ( 0.00001 + MeasureDayLength ))

[MeasureTime]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
IfCondition=((#CURRENTSECTION#>=MeasureSunriseMoment)&&(#CURRENTSECTION#<MeasureSunsetMoment))
IfTrueAction=[!SetOption MeterSoil Y "250"][!ShowMeterGroup "Sun"][!ShowMeter "SUN"][!HideMeter "MOON"][!ShowMeter "Bg1"][!HideMeter "Bg2"][!UpdateMeterGroup "Sun"][!Redraw]
IfFalseAction=[!SetOption MeterSoil Y "0"][!HideMeterGroup "Sun"][!ShowMeter "MOON"][!HideMeter "SUN"][!ShowMeter "Bg2"][!HideMeter "Bg1"][!UpdateMeterGroup "Sun"][!Redraw]

[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
Group=Sun

[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
Group=Sun

[MeterSun]
Meter=Shape
X=0r
Y=0r
Shape=Ellipse (10+160*[MeasureSinceSunrise]),(20*(Abs([MeasureSinceSunrise]-0.5))+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
Group=Sun
I'm sorry I didn't come back to post this code, although I promised I will.
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

Thank you very much ! :bow:
The sun's position is even better now ! :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:The sun's position is even better now ! :thumbup:
This is the essence of the last modifications. Plus I hidden the elements of Sun's path over night.
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

Hi Balala
I would like to use the code above for the position of the moon.
I replaced sunrise and sunset with moonrise and moonset but the formulas should be adapted,I think.
Below is the code with the replacements
Thanks

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
Solidcolor=0,0,0,1


[Variables]
locationCode=FRXX0076
Link=https://weather.com/en-GB/weather/tenday/l/
URL=#Link##locationCode#


[MeasureMoon]
Measure=WebParser
Url=#URL#
RegExp=(?siU)(?(?=.*{"validDate":".*").*,"moonrise":"(.*)","moonset":"(.*)")
UpdateRate=600
LogSubstringErrors=0


[MeasureMoonrise]
Measure=WebParser
Url=[MeasureMoon]
StringIndex=1
RegExpSubstitute=1
Substitute="^.*T(.*):.*$":"\1"

[MeasureMoonset]
Measure=WebParser
Url=[MeasureMoon]
StringIndex=2
RegExpSubstitute=1
Substitute="^.*T(.*):.*$":"\1"

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

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

[MeasureMoonriseMoment]
Measure=Calc
Formula=( 60 * [MeasureMoonriseHour] + [MeasureMoonriseMinute] )
DynamicVariables=1

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

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

[MeasureMoonsetMoment]
Measure=Calc
Formula=( 60 * [MeasureMoonsetHour] + [MeasureMoonsetMinute] )
DynamicVariables=1

[MeasureHour]
Measure=Time
Format=%#H

[MeasureMinute]
Measure=Time
Format=%M

[MeasureDayLength]
Measure=Calc
Formula=( MeasureMoonsetMoment - MeasureMoonriseMoment )

[MeasureSinceMoonrise]
Measure=Calc
Formula=(( 60 * MeasureHour + MeasureMinute - MeasureMoonriseMoment ) / ( 0.00001 + MeasureDayLength ))

[MeasureTime2]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
IfCondition=((#CURRENTSECTION#>=MeasureMoonriseMoment)&&(#CURRENTSECTION#<MeasureMoonsetMoment))
IfTrueAction=[!ShowMeter "MeterMoon"]
IfFalseAction=[!HideMeter "MeterMoon"]

[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

[MeterMoonPath]
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


[MeterMoon]
Meter=Shape
X=0r
Y=0r
Shape=Ellipse (10+160*[MeasureSinceMoonrise]),(20*(Abs([MeasureSinceMoonrise]-0.5))+10*(1-Abs(2*[MeasureSinceMoonrise]-1))-80*Sin(Acos(2*[MeasureSinceMoonrise]-1))),10 | StrokeWidth 1 | Fill RadialGradient MyGradient1
MyGradient1=3,2 | 255,180,0 ; 0.0 | 210,210,0 ; 1.0
DynamicVariables=1

[MeterMoonrise]
Meter=String
MeasureName=MeasureMoonrise
X=10
Y=30r
W=300
H=38
FontSize=10
FontColor=255,255,255,190
StringStyle=Bold
StringEffect=SHADOW
FontFace=arial
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
Text=Moonrise %1


[MeterMoonset]
Meter=String
MeasureName=MeasureMoonset
X=10
Y=30r
W=300
H=38
FontSize=10
FontColor=255,255,255,190
StringStyle=Bold
StringEffect=SHADOW
FontFace=arial
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
Text=Moonset %1
Last edited by xenium on November 17th, 2019, 6:26 am, edited 3 times in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Display image based on sunrise / sunset measures

Post by eclectic-tech »

You have invalid measure names in [MeasureMoonriseHour] & [MeasureMoonriseMinute] causing the error, you have 'Moonrise' but should be 'MeasureMoonrise'...

Code: Select all

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

[MeasureMoonriseMinute]
Measure=String
String=[MeasureMoonrise]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1
User avatar
xenium
Posts: 866
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

eclectic-tech wrote: November 17th, 2019, 2:12 am You have invalid measure names in [MeasureMoonriseHour] & [MeasureMoonriseMinute] causing the error, you have 'Moonrise' but should be 'MeasureMoonrise'...

Code: Select all

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

[MeasureMoonriseMinute]
Measure=String
String=[MeasureMoonrise]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1
I have corrected the code posted above.
Thank you eclectic-tech.