It is currently May 1st, 2024, 1:35 am

Sunsetting skin

Get help with creating, editing & fixing problems with skins
Canayon9
Posts: 10
Joined: September 3rd, 2012, 12:55 pm

Sunsetting skin

Post by Canayon9 »

This probably very noobish quesiton, but please bear with me on my first skin.

I'm trying to make a sun that goes up and down based on the hour by plotting the image. However, the image of the sun keeps on getting distorted and the y coordinate, which I replaced with a variable, has a set value for some reason that I didn't assign. If somebody could please help me with the code:

[GetTime]
Measure=Time
DynamicVariables=1
Format=%#I
suny=Format
IfAboveValue=0
IfAboveAction=!SetValue suny (#suny# * 50)

[PlotSun]
Meter=Image
ImageName=Sun.png
MeasureName=GetTime
w=300
h=300
x=1100
y=suny

Thanks in advance.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Sunsetting skin

Post by MerlinTheRed »

There are some thins amiss in your code, but I'd like to know first what exactly it is you're trying to accomplish. Do you want an image to move over the screen, or do you want to change what image is displayed based on the time?

The biggest issue is that you can't just define a variable like "suny" anywhere. You have to define it in the [Variables] section. When you use it, you must enclose it in "#". Also, IfAboveAction is only executed once, when the value"crosses the line" and is bigger than IfAboveValue for the first time. After that, it will only trigger again after the value has gone below IfAboveValue.

What I'd do is make the Y value dependent on the Time measure directly. You can use [GetTime] in a formula in the Y value to accomplish this.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Canayon9
Posts: 10
Joined: September 3rd, 2012, 12:55 pm

Re: Sunsetting skin

Post by Canayon9 »

Basically I want to move the iamge up and down the screen based on the time. I took out the IfAction and enclosed suny with #. Could I do something like:

Measure=Time
DynamicVariables=1
Format=%#I
suny=%#I

Also formulas seem to be confusing me a lot. When you do "Formula=" how is that changing the value of the variable? The image of sun keeps on coming out distorted, and I don't have the faintest idea why.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Sunsetting skin

Post by MerlinTheRed »

As I said, you can't just put suny=... anywhere and then expect it to use the values. The only place where you can put it is the [Variables] section.
Also, to use a formula for the Y value, you don't use Formula=, but you just enter the formula as the Y value.

The skin might look something like this:

Code: Select all

[Rainmeter]
Author=MerlinTheRed
Update=1000
MiddleMouseUpAction=!Refresh #CURRENTCONFIG#
DynamicWindowSize=1

; get the hour in 24h format
[MeasureTime]
Measure=Time
Format="%#H"

; Convert hours to a "height" between 1 and -1.
; Will rise from 0 to 1 between 0600 and 1200 and 
; fall from 1 to 0 between 1200 and 1800.
; Will fall from 0 to -1 between 1800 and 0000
; and rise from -1 to 0 between 0000 and 0600
[MeasureSunHeight]
Measure=Calc
Formula=MeasureTime < 6 ? (MeasureTime/6-1) : (MeasureTime < 12 ? ((MeasureTime-6)/6) : (MeasureTime < 18 ? (1-(MeasureTime-12)/6) : -(MeasureTime-18)/6))
	

; Display the sun image so it rises at the bottom 
; edge of the screen at 0600, then rises until it 
; reaches the top at 1200. After that, it falls again
; until it disappears at the bottom edge of the 
; screen at 1800
[MeterImage]
Meter=Image
ImageName=sun.png
X=0
Y=(#SCREENAREAHEIGHT#*(1-[MeasureSunHeight]))
DynamicVariables=1

If you want a smooth animation you likely have to use some more math to figure out the current hour from the "raw" value of a time measure without a format string.

EDIT: here is a version of the skin with a smooth animation:

Code: Select all

[Rainmeter]
 Author=MerlinTheRed
 Update=1000
 MiddleMouseUpAction=!Refresh #CURRENTCONFIG#
 DynamicWindowSize=1
 
[Variables]

; get the time in seconds
[MeasureTime]
 Measure=Time

; convert the time to a floating-point value between 0 and 24
[MeasureHour]
 Measure=Calc
 Formula=(MeasureTime%(3600*24))/3600

; Convert hours to a "height" between 1 and -1.
; Will rise from 0 to 1 between 0600 and 1200 and 
; fall from 1 to 0 between 1200 and 1800.
; Will fall from 0 to -1 between 1800 and 0000
; and rise from -1 to 0 between 0000 and 0600
[MeasureSunHeight]
 Measure=Calc
 Formula=MeasureHour < 6 ? (MeasureHour/6-1) : (MeasureHour < 12 ? ((MeasureHour-6)/6) : (MeasureHour < 18 ? (1-(MeasureHour-12)/6) : -(MeasureHour-18)/6))
 
; Display the sun image so it rises at the bottom 
; edge of the screen at 0600, then rises until it 
; reaches the top at 1200. After that, it falls again
; until it disappears at the bottom edge of the 
; screen at 1800
[MeterImage]
 Meter=Image
 ImageName=sun.png
 X=0
 Y=(#SCREENAREAHEIGHT#*(1-[MeasureSunHeight]))
 DynamicVariables=1

Last edited by MerlinTheRed on September 3rd, 2012, 2:40 pm, edited 1 time in total.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Canayon9
Posts: 10
Joined: September 3rd, 2012, 12:55 pm

Re: Sunsetting skin

Post by Canayon9 »

Thank you so much. I understand it now and it works.