It is currently March 29th, 2024, 6:55 am

Thread for help with the Shape meter

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

Re: Thread for help with the Shape meter

Post by Yincognito »

balala wrote: October 18th, 2020, 12:16 pm So let's wait for Wyndia's reply...
Let's. :)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Wyndia
Posts: 3
Joined: October 17th, 2020, 2:31 am

Re: Thread for help with the Shape meter

Post by Wyndia »

Sorry for the delay! I ended up getting really frustrated at while working on it and had to walk away for a bit... I did come back to work on it after a break! Here is the skin I'm trying to make resizable/rescaleble with the middle mouse button (right now it's set to refresh because it's quicker when I want to view the changes):

Code: Select all

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1


[Variables]
@includeSettings=#@#CONFIG.inc

bgWidth=210
bgHeight=80

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 0

[MeterShutdown]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
X=7
Y=20
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]

[Sleep]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 35,17,12
Shape3=Combine Shape | Exclude Shape2  
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Combine Shape | XOR Shape2 | Exclude Shape3 
X=50r
Y=20
Shape5=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
For context: after viewing Mii power and looking around, it looks like no one has tried to do a simple power control set up using shapes... and I realize that using ColorPickerPlus can change the color to whatever you wanted, hence the #color1# and #color2# codes (the background meter is just me testing and playing with ColorPickerPlus). I figure making it all resizable is also another benefit of using shapes vs images, since shapes wouldn't get pixelated like a image file.

(I also discovered while poking around ColorPickerPlus that they have a icons.inc file where they have all of the drawn shapes in a separate file that they can reference. I tried to do that too but ran into problems right away; I'm not sure if that still counts under help for the shape meter and also I figure it's better to handle things one step at a time.)
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Thread for help with the Shape meter

Post by Yincognito »

Wyndia wrote: November 7th, 2020, 9:58 pm Sorry for the delay! I ended up getting really frustrated at while working on it and had to walk away for a bit... I did come back to work on it after a break! Here is the skin I'm trying to make resizable/rescaleble with the middle mouse button (right now it's set to refresh because it's quicker when I want to view the changes):

Code: Select all

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1


[Variables]
@includeSettings=#@#CONFIG.inc

bgWidth=210
bgHeight=80

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 0

[MeterShutdown]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
X=7
Y=20
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]

[Sleep]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 35,17,12
Shape3=Combine Shape | Exclude Shape2  
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Combine Shape | XOR Shape2 | Exclude Shape3 
X=50r
Y=20
Shape5=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
For context: after viewing Mii power and looking around, it looks like no one has tried to do a simple power control set up using shapes... and I realize that using ColorPickerPlus can change the color to whatever you wanted, hence the #color1# and #color2# codes (the background meter is just me testing and playing with ColorPickerPlus). I figure making it all resizable is also another benefit of using shapes vs images, since shapes wouldn't get pixelated like a image file.

(I also discovered while poking around ColorPickerPlus that they have a icons.inc file where they have all of the drawn shapes in a separate file that they can reference. I tried to do that too but ran into problems right away; I'm not sure if that still counts under help for the shape meter and also I figure it's better to handle things one step at a time.)
In my opinion, this is a job for you, since you know best how the skin should look like. Don't worry though, it's not so much about Rainmeter or Rainmeter code, as it is about basic math. That being said, I'll tell you how I would do it: the key is expressing all those hardcoded values (like, say, 25, 12, 10, etc.) from your Shape meters as formulas based on an adjustable variable (let's call it "Size").

Normally, for the desired effect, the hardcoded value should be expressed in the form of the adjustable variable (i.e. "Size") multiplied by some factor. For example, if we set Size=12 in the [Variables] section of the skin, then the value 25 from your Shape meters can be expressed as (#Size#*2.083), since 25 = 12 * 2.083. Another variant is to express the hardcoded value as a formula where "Size" multiplied by the appropriate factor is just a part of it, for example 25 being expressed as (#Size#*2+1), since 25 = 12 * 2 + 1. I chose the latter in the sample below, in order to work with integer values instead of fractional ones, but you can do the opposite, it's up to you (bear in mind that formulas in Rainmeter must be enclosed between round brackets, so that the Rainmeter parser knows it's a formula, and also that, since the "Size" variable is changing while the skin is active, all sections where this variable is used should contain a DynamicVariables=1 line, to enable dynamic variables within the said section).

Below, I "converted" the hardcoded values from the first two shapes to variable based formulas, and added the possibility of changing the base variable (i.e. "Size") on mouse scroll over the background shape. Obviously, some values are not converted yet (since as I said, I believe this is a job for you, mostly), for example, the background width and height, the hardcoded values in the last two shapes or the X and Y of the meters (you'll notice the latter when you'll play with the scrolling, as the 50r of the [Sleep] meter's X is still static, leading the shapes to eventually "intersect" or overlap one another).

The code:

Code: Select all

[Variables]
@includeSettings=#@#CONFIG.inc
Size=12
bgWidth=210
bgHeight=80

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 0
MouseScrollUpAction=[!SetVariable Size (Clamp((#Size#+1),5,50))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Size (Clamp((#Size#-1),5,50))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeterShutdown]
Meter=Shape
Shape=Ellipse (#Size#*2+1),(#Size#*2+1),#Size# | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse (#Size#*2+1),(#Size#*2+1),(#Size#-2)
Shape3=Rectangle ((#Size#*2+1)-(#Size#-2)/2),(#Size#-2),(#Size#-2+1),(#Size#-2)
Shape4=Combine Shape | XOR Shape2 | Exclude Shape3 
Shape5=Rectangle (#Size#*2+1),(#Size#-2+1),1,(#Size#-2) | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
X=7
Y=20
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]
DynamicVariables=1

[Sleep]
Meter=Shape
Shape=Ellipse (#Size#*2+1),(#Size#*2+1),#Size# | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse ((#Size#*2+1)+(#Size#-2)),((#Size#*2+1)*(2/3)),#Size#
Shape3=Combine Shape | Exclude Shape2  
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]
DynamicVariables=1

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Combine Shape | XOR Shape2 | Exclude Shape3 
X=50r
Y=20
Shape5=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]
DynamicVariables=1

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]
DynamicVariables=1

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1
DynamicVariables=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1
DynamicVariables=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1
DynamicVariables=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
DynamicVariables=1
Naturally, for increasingly complex shapes, the formulas become equally more complex, so at a certain point using images instead of shapes becomes easier. Simpler shapes make very good candidates for this approach though. It's up to you to decide when and if it's worth the effort to use this approach. ;-)

P.S. I also set an "interval" that the Size variable can fluctuate within, by using the Clamp() function in the mouse scroll actions. You can remove the function and let the bare (#Size#+1) and (#Size#-1) formulas there, if you like.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Thread for help with the Shape meter

Post by Yincognito »

Wyndia wrote: November 7th, 2020, 9:58 pm Sorry for the delay! I ended up getting really frustrated at while working on it and had to walk away for a bit... I did come back to work on it after a break! Here is the skin I'm trying to make resizable/rescaleble with the middle mouse button (right now it's set to refresh because it's quicker when I want to view the changes):

Code: Select all

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1


[Variables]
@includeSettings=#@#CONFIG.inc

bgWidth=210
bgHeight=80

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 0

[MeterShutdown]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
X=7
Y=20
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]

[Sleep]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 35,17,12
Shape3=Combine Shape | Exclude Shape2  
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Combine Shape | XOR Shape2 | Exclude Shape3 
X=50r
Y=20
Shape5=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
X=50r
Y=20
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
For context: after viewing Mii power and looking around, it looks like no one has tried to do a simple power control set up using shapes... and I realize that using ColorPickerPlus can change the color to whatever you wanted, hence the #color1# and #color2# codes (the background meter is just me testing and playing with ColorPickerPlus). I figure making it all resizable is also another benefit of using shapes vs images, since shapes wouldn't get pixelated like a image file.

(I also discovered while poking around ColorPickerPlus that they have a icons.inc file where they have all of the drawn shapes in a separate file that they can reference. I tried to do that too but ran into problems right away; I'm not sure if that still counts under help for the shape meter and also I figure it's better to handle things one step at a time.)
So, I just realized there's a much simpler way to achieve scaling, although it's possible (not sure yet) that this variant has some minor drawbacks as well. Shape meters can use the scale transform modifier for this, and with a little adjustment to the X and Y coordinates of the meters (the scaling and repositioning the String meters will be up to you, since you didn't post the STYLES.inc file where you defined the header2 meter style) the code becomes:

Code: Select all

[Variables]
@includeSettings=#@#CONFIG.inc
Scale=1
Change=0.05
bgWidth=210
bgHeight=80

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 0 | Scale #Scale#,#Scale#,0,0
MouseScrollUpAction=[!SetVariable Scale (Clamp((#Scale#+#Change#),#Change#,5))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale (Clamp((#Scale#-#Change#),#Change#,5))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeterShutdown]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 | Union Shape4 | Scale #Scale#,#Scale#,0,0
X=(7*#Scale#)
Y=(20*#Scale#)
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]
DynamicVariables=1

[Sleep]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 35,17,12
Shape3=Combine Shape | Exclude Shape2 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#)
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]
DynamicVariables=1

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 | Union Shape4 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#)
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]
DynamicVariables=1

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
Shape3=Combine Shape | Union Shape2 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#)
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]
DynamicVariables=1

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
The scale adjustments are still done on mouse scroll as in the previous code example, but this time a variable named "Scale" is used, which is modified by the value of the "Change" variable on scroll.

P.S. Some positional irregularities are visually present on very small or very large values of "Scale" - not sure exactly why that is, as the code and the formulas are correct as far as I can see. Maybe it's the fact that the shapes don't start from the (0,0) point of their meters, or some rounding accumulation on multiplication, but apart from that the process works.

P.S.S. Notice how the scale transform modifier is only added to the combined shape option, when combining shapes. When not combining shapes, the scale transform modifier is added "normally" to each shape option.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Thread for help with the Shape meter

Post by balala »

Yincognito wrote: November 8th, 2020, 4:38 pm (the scaling and repositioning the String meters will be up to you, since you didn't post the STYLES.inc file where you defined the header2 meter style)
Scaling and repositioning of the String meters is extremely simple to be done in this case with a properly written TranfromationMatrix. For instance add the follwing two options to each String meter:

Code: Select all

[ShutdownText]
...
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[SleepText]
...
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[RestartText]
...
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[LockText]
...
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1
Or instead of add these options to each meter one by one, you could probably add them to the [header2] section (probably it lives into the STYLES.inc included file).
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Thread for help with the Shape meter

Post by Yincognito »

balala wrote: November 8th, 2020, 8:33 pmScaling and repositioning of the String meters is extremely simple to be done in this case with a properly written TranfromationMatrix.
You're right - didn't thought of that. Using TransformationMatrix for this doesn't require one to know what font or font size is being used. Very good point. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Thread for help with the Shape meter

Post by balala »

Yincognito wrote: November 8th, 2020, 11:26 pm You're right - didn't thought of that. Using TransformationMatrix for this doesn't require one to know what font or font size is being used. Very good point. :thumbup:
Thanks. However it si so simple just in this case, in other cases it can be much harder. But in this case it is simple, indeed.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Thread for help with the Shape meter

Post by Yincognito »

As I suspected, the positional irregularities when scaling were because of the "empty" space between the (0,0) point of the Shape meter and the "first" opaque pixel(s) in the actual shapes. While using balala's TransformationMatrix on the Shape meters instead of the transform modifiers solved the issue, it produced another, i.e. the by now "classic" problem of mouse detection over a TransformatiionMatrix meter. So, what needed to be done was to add the difference between the scaled "empty space" pixels and the unscaled ones to the scaled position used in the code earlier. In other words, the scaled position used in the code earlier only scaled from where the actual shape "began" visually, and the "empty space" / transparent pixels between the (0,0) point of the meter and the place where the actual shape "began" visually (that technically didn't belong to the combined shape, unless the combine method was Union!) were initially left unscaled.

It's a bit of a strange thing to have to do this, but here is the updated code:

Code: Select all

[Variables]
@includeSettings=#@#CONFIG.inc
Scale=1
Change=0.05
bgWidth=210
bgHeight=80

[Rainmeter]
MiddleMouseUpAction=[!Refresh]
DynamicWindowSize=1
AccurateText=1

[Styles]
@includeStyle=#@#STYLES.inc

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,#bgWidth#,#bgHeight# | Fill Color #colorBG#,100 | StrokeWidth 1 | Scale #Scale#,#Scale#,0,0
MouseScrollUpAction=[!SetVariable Scale (Clamp((#Scale#+#Change#),#Change#,5))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale (Clamp((#Scale#-#Change#),#Change#,5))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeterShutdown]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 | Union Shape4 | Scale #Scale#,#Scale#,0,0
X=(7*#Scale#+13*(#Scale#-1))
Y=(20*#Scale#+11*(#Scale#-1))
LeftMouseUpAction=%systemroot%\system32\shutdown.exe -s -t 00
MouseOverAction=!execute [!ShowMeter ShutdownText][!Redraw]
MouseLeaveAction=!execute [!HideMeter ShutdownText][!Redraw]
DynamicVariables=1

[Sleep]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 35,17,12
Shape3=Combine Shape | Exclude Shape2 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#+13*(#Scale#-1))
MouseOverAction=!execute [!ShowMeter SleepText][!Redraw]
MouseLeaveAction=!execute [!HideMeter SleepText][!Redraw]
DynamicVariables=1

[Restart]
Meter=Shape
Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 10,23,20,5
Shape4=Path MyPath | StrokeWidth 2 | Stroke Color #color1# | Fill Color #color1#
MyPath=12,28 | LineTo 20,28 | LineTo 20,28 | LineTo 12,36,100,100
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 | Union Shape4 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#+13*(#Scale#-1))
MouseOverAction=!execute [!ShowMeter RestartText][!Redraw]
MouseLeaveAction=!execute [!HideMeter RestartText][!Redraw]
DynamicVariables=1

[Lock]
Meter=Shape
Shape=Rectangle 12,21,21,16 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Arc 15,21,30,21 | StrokeWidth 3 | StrokeColor #color1#
Shape3=Combine Shape | Union Shape2 | Scale #Scale#,#Scale#,0,0
X=(50*#Scale#)r
Y=(20*#Scale#+13*(#Scale#-1))
MouseOverAction=!execute [!ShowMeter LockText][!Redraw]
MouseLeaveAction=!execute [!HideMeter LockText][!Redraw]
DynamicVariables=1

[ShutdownText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="shutdown"
Hidden=1
AntiAlias=1
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[SleepText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="sleep"
Hidden=1
AntiAlias=1
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[RestartText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="restart"
Hidden=1
AntiAlias=1
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1

[LockText]
Meter=String
X=105
Y=5
MeterStyle=header2
Text="lock"
Hidden=1
AntiAlias=1
TransformationMatrix=#Scale#;0;0;#Scale#;0;0
DynamicVariables=1
Fortunately, apart from the first Shape meter (which needed both X and Y adjustments), the others only needed Y adjustments, since the X was relatively positoned using the r method (which meant the "empty" horizontal pixels didn't need to be managed again).

So, to better understand things, for the first Shape meter's:

Code: Select all

Shape=Ellipse 25,25,12 | Fill Color #color1# | StrokeWidth 1 | StrokeColor #color1#
Shape2=Ellipse 25,25,10
Shape3=Rectangle 20,10,11,10
Shape4=Rectangle 25,11,1,10 | Fill Color #color1# | StrokeWidth 2 | StrokeColor #color1#
Shape5=Combine Shape | XOR Shape2 | Exclude Shape3 | Union Shape4 | Scale #Scale#,#Scale#,0,0
X=(7*#Scale#+13*(#Scale#-1))
Y=(20*#Scale#+11*(#Scale#-1))
there are 13 "empty" pixels horizontally until the first Union based (i.e. Shape and Shape4) pixels in the combined shape occurs, because 25 (the ellipse center) minus 12 (the ellipse radius) equals 13. Likewise, vertically there are 11 pixels up to where the combined shape "begins" that needed to be scaled, because the Union based Shape and Shape4 had their upmost pixels at 25 (the ellipse center) minus 12 (the ellipse radius), aka 13, and 11 respectively (the Scale4 rectangle's Y coordinate relative to the meter) - thus the minimum between 13 and 11 had to be used.

Another option would have been to insert a "shape background" Shape at the beginning of the meter, i.e.

Code: Select all

Shape=Rectangle 0,0,50,50 ...
of the size of the actual shape including the "left out" / "empty" pixels (and of course, adjust things so it is added to the overall combined shape), but unfortunately I didn't find a way to insert it using the Union method (which is required, since other methods exclude parts of the shape from the combined one) and still keep the visuals intact. If anyone has a better idea, feel free to share it. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Thread for help with the Shape meter

Post by balala »

Yincognito wrote: November 9th, 2020, 7:24 pm While using balala's TransformationMatrix on the Shape meters instead of the transform modifiers solved the issue, it produced another, i.e. the by now "classic" problem of mouse detection over a TransformatiionMatrix meter.
Yep, unfortunately in my view this is the greatest (unsolved) problem of using TransformationMatrix to scale a meter.
zurielseven
Posts: 2
Joined: March 3rd, 2021, 3:23 am

Re: Thread for help with the Shape meter

Post by zurielseven »

Good evening, everybody in the Shape Meter thread!

I'm relatively new to writing Rainmeter Skins, but I've used and loved RainMeter for decades, being a LiteStep user since 1999. My latest skin attempt has a pair of Path shapes which I am trying to Exclude/XOR. I'm not 100% in the docs that this is possible, but wanted to ask you experts for the best advice:

Code: Select all

Meter=Shape
X=90
Y=110
Shape=Path Tray | StrokeWidth 1 | StrokeColor 255,255,255,255 | Fill LinearGradient TrayFillGradient
TrayFillGradient=90 | #Cream#,210 ; 0.0 | #MediumBlue#,80 ; 1.0
Tray=0,0 | LineTo 420,0 | LineTo 420,420 | LineTo 0,420 | LineTo 0,0 | ClosePath 1

Shape2=Path TrayCutoutPathOne | StrokeWidth 1 | StrokeColor #Cream#,255 | Fill 0,0,0,25
X=90
Y=110
TrayCutoutPathOne=52,34 | LineTo 136,34 | CurveTo 148,42,144,34 | CurveTo 160,50,150,50 | LineTo 216,50 | CurveTo 228,60,228,50 | LineTo 228,170 | CurveTo 218,180,228,180 | LineTo 52,180 | CurveTo 42,170,42,180 | LineTo 42,44 | CurveTo 52,34,42,34 | ClosePath 1

Shape4=Combine Shape | Exclude Shape2 
The ideal is to have a square with a folder shaped "hole" as a shape.

1) Did I screw up? If so, where?
2) Is Path-on-Path Combinations supported?
3) Thank you!