It is currently April 8th, 2020, 3:06 pm

Some parts of the code work properly in loading images, but some don't + Cropped images

Help with creating, editing & fixing problems with skins
LL777
Posts: 2
Joined: March 17th, 2020, 7:39 pm

Some parts of the code work properly in loading images, but some don't + Cropped images

Post by LL777 »

I am using a Persona 5 Calendar skin, which is divided in displaying the date/weather, and displaying the moment of the day (morning, evening). The issue when displaying the moment of the day. It is programmed so that at certain hours of the day, it will display an image (png) that matches with the name of the image. This is splitted into 4 different IfCondition and IfTrueAction. The first 2 work properly displaying the image at the right time. However, on the third one it shows the image but slightly cropped which forces me to manually refresh in order to show the image properly, and in the 4th one, it doesn't work at all and not only I have to manually refresh the skins, but it seems that it will only show wathever it was set in [Variables] TimeName=The name of the image (e.g Daytime). I tested and it doesn't seem to be an issue with the images, since if been changing postitions and all the images are displayed properly. So I am not sure what the cause of these issues could be.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=
Author=
Information=
Version=
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
TimeName=Daytime

TimeNameBaseX=0
TimeNameBaseY=0
TimeNameBaseRotation=0

TimeKanjiBaseX=80
TimeKanjiBaseY=39
TimeKanjiBaseRotation=-20



;-------------------Calculations------------------------
[CurrentHour]
Measure=Time
Format=%#H
UpdateRate=300

[CalculateTimeName]
Measure=Calc
Formula=[CurrentHour]
IfCondition=(CalculateTimeName >= 6) && (CalculateTimeName <= 11) 
IfTrueAction=[!SetVariable TimeName "Morning"]
IfCondition2=(CalculateTimeName >= 12) && (CalculateTimeName <= 16)
IfTrueAction2=[!SetVariable TimeName "Afternoon"]
IfCondition3=(CalculateTimeName >= 17) && (CalculateTimeName <= 19)
IfTrueAction3=[!SetVariable TimeName "Evening"]
IfCondition4=(CalculateTimeName >= 20) && (CalculateTimeName <= 5)
IfTrueAction4=[!SetVariable TimeName "Night"]

DynamicVariables = 1


[DisplayTimeName]
Meter=Image
ImageName=TimeName\[#TimeName].png
X=[#TimeNameBaseX]
Y=[#TimeNameBaseY]
ImageRotate=[#TimeNameBaseRotation]
DynamicVariables=1

;[DisplayTimeKanji]
Meter=Image
ImageName=TimeKanji\[#TimeName].png
X=[#TimeKanjiBaseX]
Y=[#TimeKanjiBaseY]
ImageRotate=[#TimeKanjiBaseRotation]
DynamicVariables=1
Rainmeter 4.3.1.3321 (64-bit)
Language: English (1033)
Build time: 2019-09-22 7:26:11
Commit Hash: 0ba4dfc4
Windows 10 Home 1903 64-bit (build 18362) - Spanish (3082)
Path: C:\Program Files\Rainmeter\
SkinPath: C:\Users\Usuario\Documents\Rainmeter\Skins\
SettingsPath: C:\Users\Usuario\AppData\Roaming\Rainmeter\
IniFile: C:\Users\Usuario\AppData\Roaming\Rainmeter\Rainmeter.ini
You do not have the required permissions to view the files attached to this post.
Last edited by LL777 on March 18th, 2020, 12:14 pm, edited 2 times in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3875
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Some parts of the code work properly in loading images, but some don't

Post by eclectic-tech »

Your fourth conditional test can never be true; the hour can never be greater than or equal to 20 AND less than or equal to 5.

Change the 'test' to OR by using ||:
IfCondition4=(CalculateTimeName >= 20) || (CalculateTimeName <= 5)
IfTrueAction4=[!SetVariable TimeName "Night"]


I would also recommend that when you want to remove a section, comment out every line in the section. Rainmeter will see those as part of the previous section if not commented.

Code: Select all

;[DisplayTimeKanji]
Meter=Image
ImageName=TimeKanji\[#TimeName].png
X=[#TimeKanjiBaseX]
Y=[#TimeKanjiBaseY]
ImageRotate=[#TimeKanjiBaseRotation]
DynamicVariables=1
Should be:

Code: Select all

;[DisplayTimeKanji]
;Meter=Image
;ImageName=TimeKanji\[#TimeName].png
;X=[#TimeKanjiBaseX]
;Y=[#TimeKanjiBaseY]
;ImageRotate=[#TimeKanjiBaseRotation]
;DynamicVariables=1
User avatar
Christopher Robin
Posts: 14
Joined: January 20th, 2020, 3:55 pm

Re: Some parts of the code work properly in loading images, but some don't

Post by Christopher Robin »

Is there a reason for calling all the variables with the nested-variable syntax?

Edit: not being sarcastic, as a newbie I genuinely wonder if there's a value in doing this.
User avatar
Yincognito
Posts: 1152
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Some parts of the code work properly in loading images, but some don't

Post by Yincognito »

eclectic-tech wrote:
March 17th, 2020, 8:36 pm
Your fourth conditional test can never be true; the hour can never be greater than or equal to 20 AND less than or equal to 5.

Change the 'test' to OR by using ||:
IfCondition4=(CalculateTimeName >= 20) || (CalculateTimeName <= 5)
IfTrueAction4=[!SetVariable TimeName "Night"]


I would also recommend that when you want to remove a section, comment out every line in the section. Rainmeter will see those as part of the previous section if not commented.

Code: Select all

;[DisplayTimeKanji]
Meter=Image
ImageName=TimeKanji\[#TimeName].png
X=[#TimeKanjiBaseX]
Y=[#TimeKanjiBaseY]
ImageRotate=[#TimeKanjiBaseRotation]
DynamicVariables=1
Should be:

Code: Select all

;[DisplayTimeKanji]
;Meter=Image
;ImageName=TimeKanji\[#TimeName].png
;X=[#TimeKanjiBaseX]
;Y=[#TimeKanjiBaseY]
;ImageRotate=[#TimeKanjiBaseRotation]
;DynamicVariables=1
Damn, you stole my reply ... :D But what about the 3rd image?

EDIT: Just checked, it doesn't seem to be anything wrong with the 3rd image - no crop or anything like that.
User avatar
balala
Rainmeter Sage
Posts: 10094
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Some parts of the code work properly in loading images, but some don't

Post by balala »

LL777 wrote:
March 17th, 2020, 8:10 pm
However, on the third one it shows the image but slightly cropped which forces me to manually refresh in order to show the image properly,
In addition to eclectic-tech's advice, note that this is caused by the fact that when the hour changes from 16 to 17 and accordingly the image changes from Afternoon to Evening, these two images have different sizes and the second one moves a little bit, having some transparent margins. If you followed eclectic-tech's advice and got working the last (fourth) image as well, you'll see that this one is even more cropped, due to the fact that this one is even more placed to right, on left having a huge transparent margin.
The easiest way to avoid this is by adding a DynamicWindowSize=1 option to the [Rainmeter] section of the code. This way the skin's size is adjusted accordingly to the size of the actually shown image, so you don't get the image cropped.
Christopher Robin wrote:
March 17th, 2020, 8:41 pm
Is there a reason for calling all the variables with the nested-variable syntax?

Edit: not being sarcastic, as a newbie I genuinely wonder if there's a value in doing this.
No, there is not. No need for this. The following syntax works perfectly:

Code: Select all

[DisplayTimeName]
Meter=Image
ImageName=TimeName\#TimeName#.png
X=#TimeNameBaseX#
Y=#TimeNameBaseY#
ImageRotate=#TimeNameBaseRotation#
DynamicVariables=1
User avatar
Yincognito
Posts: 1152
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Some parts of the code work properly in loading images, but some don't

Post by Yincognito »

Christopher Robin wrote:
March 17th, 2020, 8:41 pm
Is there a reason for calling all the variables with the nested-variable syntax?

Edit: not being sarcastic, as a newbie I genuinely wonder if there's a value in doing this.
While in this case, as balala mentioned, there isn't a particular need for the nested variable syntax, there can be a potential value in doing this: if (or when) those variables actually will need to be nested, the already present syntax won't require additional modification to handle nesting. In other words, it can be considered an "insurrance" for potential future nesting.

That being said, I don't know if that was the OP's intention. Personally, I would have adopted this syntax for all variables in my code, if I wouldn't felt more comfortable with the "old" #variable# one (since it makes easier for the eye to differentiate variables from measure / meter section variables). I already do this for strings, for example, always enclosing them between quotes, even though in most cases there is no need for it and Rainmeter ignores them - my thought process is: it doesn't hurt to have them, so let them be there, just in case they are needed in some scenarios.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3875
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Some parts of the code work properly in loading images, but some don't

Post by eclectic-tech »

Yincognito wrote:
March 17th, 2020, 8:44 pm
Damn, you stole my reply ... :D But what about the 3rd image?

EDIT: Just checked, it doesn't seem to be anything wrong with the 3rd image - no crop or anything like that.
I didn't try the attached skin :uhuh:, but balala did and found the issue with different image sizes and a solution. :great:
User avatar
Yincognito
Posts: 1152
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Some parts of the code work properly in loading images, but some don't

Post by Yincognito »

eclectic-tech wrote:
March 17th, 2020, 10:17 pm
I didn't try the attached skin :uhuh:, but balala did and found the issue with different image sizes and a solution. :great:
Yes, I noticed that. ;-)
LL777
Posts: 2
Joined: March 17th, 2020, 7:39 pm

Re: Some parts of the code work properly in loading images, but some don't

Post by LL777 »

Thanks to everyone who replied. Applied all the changes and no more cropping, and the 4th Condition/TrueAction works perfectly. Again, thanks to everyone for the help.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3875
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Some parts of the code work properly in loading images, but some don't

Post by eclectic-tech »

8-)