It is currently April 19th, 2024, 11:39 pm

Help: Switching wallpapers with a button

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help: Switching wallpapers with a button

Post by Yincognito »

balala wrote: April 27th, 2020, 8:32 pm Photoshop definitely is much better, however if you simply want to get the frames, I recommend the first link I posted.
Yeah, much better idea using such sites, especially when you need such a service only rarely.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Yincognito wrote: April 27th, 2020, 8:51 pm Yeah, much better idea using such sites, especially when you need such a service only rarely.
Yeah and much easier.
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Ok, it's working.

My next step is to add a black background behind the [MeterImage] displaying the .gif.
The .gif is pretty smal with a bit of black around it already, but I want the black background to be screen size (1920x1080)

Here is the code I came up with for the background, but it doesn't work:
The Black Backgound.png is solid black image of 1920x1080

Code: Select all

[Rainmeter]
Update=100
BackgroundMode=0
BackgroundImage=#@#\Images\Mainframe Boot\Black Background.png

[Metadata]
Name=SHIELD Module Mainframe Boot
Author= Mino
Information=Displays the SHIELD Module Mainframe Boot
Version=1
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
@include=#@#\Config.inc

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 43

[ImageMeter]
Meter=Image
ImageName=#@#\Images\Mainframe Boot\Frame-[ImageNumberCalc].png
Hidden=0
AntiAlias=1
DynamicVariables=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help: Switching wallpapers with a button

Post by Yincognito »

Mino_el_Nukenin wrote: April 27th, 2020, 9:20 pm Ok, it's working.

My next step is to add a black background behind the [MeterImage] displaying the .gif.
The .gif is pretty smal with a bit of black as it's background, but I want the black background to be screen size (1920x1080)
I think I need to use the SolidColor option, but not sure where and how.
Here is the code :

Code: Select all

[Variables]
@include=#@#\Config.inc

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 43

[ImageMeter]
Meter=Image
ImageName=#@#\Images\Mainframe Boot\Frame-[ImageNumberCalc].png
AntiAlias=1
DynamicVariables=1
Simple: measures and meters are executed (in the case of measures) and displayed (in the case of meters) in the order in which they are written in the code (unless you interfere in their update order by using bangs such as !UpdateMeasure or !UpdateMeter / !Redraw, that is). So, to have meter A "behind" meter B, you only need to place meter A before meter B in the code - and the reverse is true if you want the opposite, of course.

Thus, add:

Code: Select all

[BackgroundMeter]
Meter=Image
SolidColor=0,0,0,255
W=#SCREENAREAWIDTH#
H=#SCREENAREAHEIGHT#
DynamicVariables=1
before your [ImageMeter] in the code you posted, and that should be it. Also, take care that if you have other meters in the code, or you want to add other meters in the future, order is important - so normally the background meter should always be if not the first, at least among the first meters in your code at any time.

As you suspected, the solid color does the job, but apart from that, to set the meter to the size of the screen it's recommended to use the built-in Rainmeter variables here, like in the code above. The reason is simple: assuming that the DynamicVariables=1 line exists in the meter (since, as said in the link I posted, these variables are dynamic, i.e. ever changing during run-time), when your resolution changes, the meter's dimensions will change accordingly, adapting. If you used hardcoded values (like W=1920 and H=1080), then the meter wouldn't adapt its dimensions in such situations, leading to possibly unwanted behavior.

That being said, there is another alternative to the above (but again, this one is non-adaptive, since the variables are static in the [Rainmeter] section), which is to add this after the [Variables] section (or if you already have a [Rainmeter] section in your code, simply add the code starting with the 2nd line below):

Code: Select all

[Rainmeter]
SkinWidth=#SCREENAREAWIDTH#
SkinHeight=#SCREENAREAHEIGHT#
BackgroundMode=2
SolidColor=0,0,0,255
What this does is constrain the skin's width and height to #SCREENAREAWIDTH# and #SCREENAREAHEIGHT#, while setting a black background for the entire skin (so not just for a particular meter, like the previous code). As said, the screen area variables in the [Rainmeter] section are always static, meaning that the first code posted above is still the better choice, as it's adaptive to resolution changes (however rare they might be). For more info on the possibilities in the [Rainmeter] section, take a look here.

EDIT: One other thing, which became evident while actually testing the first code, is that you'd probably have to set [ImageMeter]'s X and Y after this, similarly to how balala set the padding below, for the simple reason that [ImageMeter] will by default position itself in the top left corner of the [BackgroundMeter], if not set otherwise. Or, you can go straight for his solution right away, as by its nature, adding that padding basically sets both the dimensions of the background and the position of the image at the same time.
Last edited by Yincognito on April 28th, 2020, 8:19 am, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Mino_el_Nukenin wrote: April 27th, 2020, 9:20 pm My next step is to add a black background behind the [MeterImage] displaying the .gif.
The .gif is pretty smal with a bit of black around it already, but I want the black background to be screen size (1920x1080)

Here is the code I came up with for the background, but it doesn't work:
The Black Backgound.png is solid black image of 1920x1080
An additional method, beside Yincognito's one, is to add a properly set Padding option to the Image meter ([ImageMeter]), which properly extends the size of the Image meter. The simplest possible way to do this is when you precisely know the size of the Images (Frame-X.png) used by the Image meter and the sizes of all those images are the same.
If you wanna give it a try, here is the solution: you have to add the following Padding option to the [ImageMeter] meter: Padding=((#SCREENAREAWIDTH#-#WidthOfImages#)/2),((#SCREENAREAHEIGHT#-#HeightOfImages#)/2),((#SCREENAREAWIDTH#-#WidthOfImages#)/2),((#SCREENAREAHEIGHT#-#HeightOfImages#)/2).
To get a black background, you have to add a SolidColor=0,0,0,255 option to the same [ImageMeter] meter as well.
This solution doesn't use the Black Background.png image as background, but adds a solid color. This is supposed to be used only if you don't insist to use the Black Background.png image, but a solid color is also well.
If the sizes of the used frames vary or it is not known, you have to use the ImageSize plugin, in order to get the size of the current image (but I doubt this worth).
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help: Switching wallpapers with a button

Post by Yincognito »

balala wrote: April 28th, 2020, 7:27 am An additional method, beside Yincognito's one, is to add a properly set Padding option to the Image meter ([ImageMeter]), which properly extends the size of the Image meter. The simplest possible way to do this is when you precisely know the size of the Images (Frame-X.png) used by the Image meter and the sizes of all those images are the same.
If you wanna give it a try, here is the solution: you have to add the following Padding option to the [ImageMeter] meter: Padding=((#SCREENAREAWIDTH#-#WidthOfImages#)/2),((#SCREENAREAHEIGHT#-#HeightOfImages#)/2),((#SCREENAREAWIDTH#-#WidthOfImages#)/2),((#SCREENAREAHEIGHT#-#HeightOfImages#)/2).
To get a black background, you have to add a SolidColor=0,0,0,255 option to the same [ImageMeter] meter as well.
This solution doesn't use the Black Background.png image as background, but adds a solid color. This is supposed to be used only if you don't insist to use the Black Background.png image, but a solid color is also well.
If the sizes of the used frames vary or it is not known, you have to use the ImageSize plugin, in order to get the size of the current image (but I doubt this worth).
Yeah, I think your padding solution is better, as it also handles the image positioning on the background, without additional options / meters involved - see the edit in my previous post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Yincognito wrote: April 28th, 2020, 8:22 am Yeah, I think your padding solution is better, as it also handles the image positioning on the background, without additional options / meters involved - see the edit in my previous post.
Yeah, which solution is better, depends on many things. Now I think Mino_el_Nukenin has a few options to choose from. Let's see what is his opinion.
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Wow, thanks you both really !
After trying both solutions of Yincognito and as you both said I have one need :
- The [ImageMeter] displaying the images (Frame-X.png) has to be in the middle of the black screen; so I think i'll go with Balala code, since I can find the exact size of the (Frame-X.png) with Photoshop.

My next step will be to trigger this skin with the button you helped me with already, with a short duration (basically the initial duration of the .gif), so not sure which command to use : [!Show] then [!Hide] command with a [!Duration] in between ??
Last edited by Mino_el_Nukenin on April 28th, 2020, 2:45 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Mino_el_Nukenin wrote: April 28th, 2020, 2:23 pm After trying the both solutions of Yincognito and as you both said I have one need :
- The [ImageMeter] displaying the images (Frame-X.png) has to be in the middle of the black screen; so I think i'll go with Balala code, since I can find the exact size of the (Frame-X.png) with Photoshop.
Obviously you can choose any solution you prefere more.
Mino_el_Nukenin wrote: April 28th, 2020, 2:23 pm My next step will be to trigger this skin with the button you helped me with already, with a short duration (basically the initial duration of the .gif), so not sure which command to use : [!Show] then [!Hide] command with a [!Duration] in between ??
Not sure what you mean by "trigger this skin". You wanna show it, keep it a few seconds on the screen, then hide it? Have I understood well your desire?
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Code: Select all

[ImageMeter]
Meter=Image
ImageName=#@#\Images\Mainframe Boot\Frame-[ImageNumberCalc].png
Padding=((#SCREENAREAWIDTH#-314)/2)((#SCREENAREAHEIGHT#-332)/2),((#SCREENAREAWIDTH#-314)/2),((#SCREENAREAHEIGHT#-332)/2)
SolidColor=0,0,0,255
Hidden=0
AntiAlias=1
DynamicVariables=1
I'm doing something wrong with the padding, but can't understand where.. Teh padding doesn't cover the whole screen... I tried with and without # for the sizes and without the /2.
Not sure what you mean by "trigger this skin". You wanna show it, keep it a few seconds on the screen, then hide it? Have I understood well your desire?
Yes exactly!