It is currently March 29th, 2024, 1:35 am

Clock face based on the sunset and sunrise

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: Clock face based on the sunset and sunrise

Post by balala »

Although probably eclectic-tech's solution is perfect (however didn't test it), a completely different approach is also possible. The Sunrise / Sunset can be calculated, not downloaded from internet. Lua code involved in such a case, but it definitely is possible. I did it in the SunMoon\SunMoon.ini skin of my Mirage suite.
If interested on how to do it in your skin, please let me know, to assist you.
the1ulike
Posts: 34
Joined: June 13th, 2020, 7:55 pm

Re: Clock face based on the sunset and sunrise

Post by the1ulike »

Working better now and I'm happy with it. I don't like the digital clock in the bottom so I have done another MeasureTime with the format of %p to be used for the meter. Please advise if this is the best way to fix that.

Code: Select all

[Variables]
; geo ID number from time.yandex for Detroit Michigan
;Location=213
; Melbourne AU geo ID = 21265
; Detroit Mi geo ID = 89
; Moscow RU geo ID = 213
; Los Angeles CA geo ID = 200
; Singapore geo ID = 10619

; Location
[MeasureName]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=600
Url="http://time.yandex.com/sync.json?lang=en&geo=#Location#"
;Debug=1
RegExp="(?siU).*"name":"(.*)".*"offset":(.*),"offsetString":"(.*)".*,"isNight":(.*),"
StringIndex=1
DecodeCharacterReference=1
DynamicVariables=1
 
; This returns an offset number for the defined city that tells you the current time UTC+14400000 
[MeasureOffset]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureName]
StringIndex=2
Substitute="":"0"

[MeasureTimeZone]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureName]
StringIndex=3
Substitute="UTC":""

[MeasureIsNight]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureName]
StringIndex=4
Substitute="true":"Night","false":"Day"
IfMatch=(?i)Night
IfMatchAction=[!ShowMeterGroup Night][!HideMeterGroup Day][!ShowMeter MeterSecondsHand][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!HideMeterGroup Night][!ShowMeterGroup Day][!ShowMeter MeterSecondsHand][!UpdateMeter *][!Redraw]
IfConditionMode=1
DynamicVariables=1

; Converts the offset value returned by the webparser to a timezone to determine the time at the defined location
; This is used as the source for the other time related values; year, month, day, etc.

[MeasureTime]
Measure=Time
Timezone=([MeasureOffset]/3600000)
DynamicVariables=1

[MeasureTime2]
Measure=Time
Timezone=([MeasureOffset]/3600000)
DynamicVariables=1
Format=%p

;[MeasureTime3]
;Measure=Time
;Timezone=([MeasureOffset]/3600000)
;DynamicVariables=1
;Format=%R

[MeasureYear]
Measure=Time
TimeStamp=[MeasureTime:]
Format=%Y
DynamicVariables=1

[MeasureSeconds]
Measure=Time
TimeStamp=[MeasureTime:]
Format=%S
DynamicVariables=1

[MeasureMonth]
Measure=Time
TimeStamp=[MeasureTime:]
Format=%d %b
DynamicVariables=1

[MeasureDay]
Measure=Time
Format=%A 
TimeStamp=[MeasureTime:]
DynamicVariables=1

;**********************************************************************************
; METERS
;**********************************************************************************

[MeterClockFaceN]
Group=Night
Hidden=1
Meter=Image
ImageName=#@#Images\N.png
PreserveAspectRatio=1
X=0
Y=0
W=220
H=250

[MeterClockFaceD]
Group=Day
Hidden=1
Meter=Image
ImageName=#@#Images\D.png
PreserveAspectRatio=1
X=0
Y=0
W=220
H=250

;**********************************************************************************


[MeterDigitalTimeN]
Group=Night
Hidden=1
Meter=String
StringStyle=Bold
;StringEffect=Shadow
FontColor=250,250,250
AntiAlias=1
MeasureName=MeasureTime2
StringAlign=CenterCenter
X=110
Y=218
FontSize=11
Text=%1



[MeterDigitalTime]
Group=Day
Hidden=1
Meter=String
StringStyle=Bold
;StringEffect=Shadow
FontColor=10,10,10
AntiAlias=1
MeasureName=MeasureTime2
StringAlign=CenterCenter
X=110
Y=218
FontSize=11
Text=%1 

;**********************************************************************************

;[MeterDigitalClock]
;Meter=String
;StringStyle=Bold
;StringEffect=Shadow
;FontColor=255,0,0,150
;AntiAlias=1
;MeasureName=MeasureTime3
;StringAlign=CenterCenter
;X=110
;Y=180
;FontSize=10
;Text=%1 

;**********************************************************************************

[MeterDigitalDayOfWeekN]
Group=Night
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontFace=Arial
AntiAlias=1
MeasureName=MeasureDay
StringAlign=CenterCenter
X=111
Y=150
FontSize=10
FontColor=255,255,255
Text=%1

[MeterDigitalDayOfWeek]
Group=Day
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontFace=Arial
AntiAlias=1
MeasureName=MeasureDay
StringAlign=CenterCenter
X=111
Y=150
FontSize=10
FontColor=0,0,0
Text=%1

;**********************************************************************************

[MeterDigitalDateN]
Group=Night
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontColor=255,255,255
FontFace=Arial
AntiAlias=1
MeasureName=MeasureMonth
MeasureName2=MeasureYear
StringAlign=CenterCenter
X=111
Y=165
FontSize=10
Text=%1 %2

[MeterDigitalDate]
Group=Day
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontColor=0,0,0
FontFace=Arial
AntiAlias=1
MeasureName=MeasureMonth
MeasureName2=MeasureYear
StringAlign=CenterCenter
X=111
Y=165
FontSize=10
Text=%1 %2

;**********************************************************************************

[MeterTZDisplayN]
Group=Night
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontColor=255,255,255
AntiAlias=1
MeasureName=MeasureName
StringAlign=CenterCenter
X=111
Y=95
FontSize=11


[MeterTZDisplay]
Group=Day
Hidden=1
Meter=String
StringStyle=Bold
StringCase=Upper
FontColor=0,0,0
AntiAlias=1
MeasureName=MeasureName
StringAlign=CenterCenter
X=111
Y=95
FontSize=11

;**********************************************************************************
;************************************Clock Hands *******************************

[MeterHrHandN]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineLength=40
LineColor=240,240,240
LineWidth=11
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200


[MeterHrHand]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineLength=40
LineColor=0,0,0
LineWidth=11
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200

;**********************************************************************************

[MeterHrHand2N]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=43
LineLength=46
LineColor=240,240,240
LineWidth=9
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200


[MeterHrHand2]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=43
LineLength=46
LineColor=0,0,0
LineWidth=9
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200


;**********************************************************************************

[MeterHrHand3N]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart= 49
LineLength=51
lineColor=240,240,240
LineWidth=7
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200


[MeterHrHand3]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart= 49
LineLength=51
lineColor=0,0,0
LineWidth=7
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=43200


;**********************************************************************************

[MeterMinHandN]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=0
LineLength=60
LineColor=240,240,240
LineWidth=9
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

[MeterMinHand]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=0
LineLength=60
LineColor=0,0,0
LineWidth=9
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

;**********************************************************************************

[MeterMinHand2N]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=62
LineLength=65
LineColor=240,240,240
LineWidth=7
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

[MeterMinHand2]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=62
LineLength=65
LineColor=0,0,0
LineWidth=7
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

;**********************************************************************************

[MeterMinHand3N]
Group=Night
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=67
LineLength=69
LineColor=240,240,240
LineWidth=5
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

[MeterMinHand3]
Group=Day
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineStart=67
LineLength=69
LineColor=0,0,0
LineWidth=5
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=3600

;**********************************************************************************

[MeterSecondsHand]
Hidden=1
Meter=ROUNDLINE
MeasureName=MeasureTime
X=0
Y=20
W=220
H=220
LineLength=95
LineColor=255,0,0,150
LineWidth=2
AntiAlias=1
StartAngle=4.7124
RotationAngle=6.2832
ValueRemainder=60

;**********************************************************************************

[CenterN]
Group=Night
Hidden=1
Meter=Image
ImageName=#@#Images\gen_dotN.png
X=0
Y=20
W=220
H=220

[Center]
Group=Day
Hidden=1
Meter=Image
ImageName=#@#Images\gen_dot.png
X=0
Y=20
W=220
H=220

;**********************************************************************************
Then, as a new task, I saw a few years ago when I used to have Yahoo Widget, the face of the clock will be gradually changed between the dark and light face. It was just for around 15 min at the sunrise or sunset time. Any idea?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Clock face based on the sunset and sunrise

Post by eclectic-tech »

the1ulike wrote: June 16th, 2020, 10:11 am Working better now and I'm happy with it. I don't like the digital clock in the bottom so I have done another MeasureTime with the format of %p to be used for the meter. Please advise if this is the best way to fix that.

Then, as a new task, I saw a few years ago when I used to have Yahoo Widget, the face of the clock will be gradually changed between the dark and light face. It was just for around 15 min at the sunrise or sunset time. Any idea?
The change to AM/PM on the digital clock is fine.

To slowly change the brightness to reflect dusk/dawn would require knowing the sunrise/sunset times and creating a formula to slowly change the color. Balala's suggestion may be the way to head. That is more than I would want to get in to.
the1ulike
Posts: 34
Joined: June 13th, 2020, 7:55 pm

Re: Clock face based on the sunset and sunrise

Post by the1ulike »

eclectic-tech wrote: June 16th, 2020, 11:41 am The change to AM/PM on the digital clock is fine.

To slowly change the brightness to reflect dusk/dawn would require knowing the sunrise/sunset times and creating a formula to slowly change the color. Balala's suggestion may be the way to head. That is more than I would want to get in to.
Eclectic-tech, you have done a great job for me. Thank you so much
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Clock face based on the sunset and sunrise

Post by balala »

eclectic-tech wrote: June 16th, 2020, 11:41 am To slowly change the brightness to reflect dusk/dawn would require knowing the sunrise/sunset times and creating a formula to slowly change the color. Balala's suggestion may be the way to head. That is more than I would want to get in to.
I suppose online getting the moment of Sunrise and Sunset is quite good, but as said, local calculations are also possible. My question for the1ulike is which approach do you prefer? Have to work a little bit on it if you'd like my method, but first please confirm you want this one.
the1ulike
Posts: 34
Joined: June 13th, 2020, 7:55 pm

Re: Clock face based on the sunset and sunrise

Post by the1ulike »

balala wrote: June 16th, 2020, 5:21 pm I suppose online getting the moment of Sunrise and Sunset is quite good, but as said, local calculations are also possible. My question for the1ulike is which approach do you prefer? Have to work a little bit on it if you'd like my method, but first please confirm you want this one.
thanks for the response balala, How about getting the online approach first. I think it is easier for me to follow. I assume it will have input Varaites for each city
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Clock face based on the sunset and sunrise

Post by balala »

the1ulike wrote: June 17th, 2020, 12:03 am How about getting the online approach first. I think it is easier for me to follow.
Alright, just let me know if you change your mind.
the1ulike
Posts: 34
Joined: June 13th, 2020, 7:55 pm

Re: Clock face based on the sunset and sunrise

Post by the1ulike »

balala wrote: June 17th, 2020, 5:15 pm Alright, just let me know if you change your mind.
Offline will be better, but how to give the variable input for the cities. How about consuming the CPU as I notice my skins consumes a lot. Which approach will be better in this case.
other than this, I saw the online URL has the sky color available, can we use it for the clock background
thank you
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Clock face based on the sunset and sunrise

Post by balala »

the1ulike wrote: June 18th, 2020, 2:52 am How about consuming the CPU as I notice my skins consumes a lot. Which approach will be better in this case.
I can't say which solution uses less CPU. I suppose (but this definitely is just a supposition!) the offline solution would use less, but I'm not sure I am right at all.
the1ulike wrote: June 18th, 2020, 2:52 am how to give the variable input for the cities.
Actually in the offline solution you don't set up the city, you set up the geographical coordinates (latitude and longitude) and the time zone.
the1ulike wrote: June 18th, 2020, 2:52 am other than this, I saw the online URL has the sky color available, can we use it for the clock background
Alright, but which solution do you prefer finally? Because I'm not sure now at all...
the1ulike
Posts: 34
Joined: June 13th, 2020, 7:55 pm

Re: Clock face based on the sunset and sunrise

Post by the1ulike »

balala wrote: June 18th, 2020, 3:49 pm I can't say which solution uses less CPU. I suppose (but this definitely is just a supposition!) the offline solution would use less, but I'm not sure I am right at all.

Actually in the offline solution you don't set up the city, you set up the geographical coordinates (latitude and longitude) and the time zone.

Alright, but which solution do you prefer finally? Because I'm not sure now at all...
If there is no big difference in CPU consumption, then the online will be the choice