Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1428

Help: Rainmeter Skins • Re: Scaling shapes with paths that can't be combined.

$
0
0
I have a shape meter that has 8 shapes, I want to scale all shapes together so they all follow the background size. I have 2 problems:

1.- I can't combine the shapes because they all have different attribute modifiers (colors) that are lost when combined.

2.- Using ([#W]/[&[#CurrentSection]:W]) and ([#H]/[&[#CurrentSection]:H]) on the Scale modifier is not scaling them properly.

So I'm looking for a way to scale them all together, so they all follow the background's W and H, and keep their positions and modifiers.

Example skin:
[...]
It is loggin Formula: Division by 0: (180/0) and Formula: Division by 0: (320/0). If you change W or H variables then it starts flickering from scale to default.
First, using the [#CURRENTSECTION#:W] and [#CURRENTSECTION#:H] values is not correct, for 2 reasons:
- they would always be one update behind the real values (and 0 at skin load), being based on the previous update of the meter (none at skin load)
- they are volatile and change based on scaling, so if scaling were to work like you wanted, (#W#/[#CURRENTSECTION#:W]) would always give 1
Secondly, since the shapes are not combined (yep, I don't like color theft on combining either), common scaling is not correct, for 2 reasons:
- default scaling is done from the shape's center, but since the skin size is changed at bottom right, the scaling anchor must be the 0,0 of the meter
- the shapes have different coordinates within the Shape meter, while the scaling anchor is based on the top left corner of each individual shape
Basically, what you're looking for is the way TransformationMatrix works, relative to the 0,0 of the skin (which is the 0,0 of the meter too, here).

Here is the "fun" part though: since your individual shapes are irregular and don't extend (not even near transparently) to the 0,0 of their meter, you'd have to know their top left coordinates in the meter, so you can make their scaling's AnchorX and AnchorY always indicate the 0,0 of the meter, but in relation to each individual shape's top left corner:
https://docs.rainmeter.net/manual/meters/shape/#Scale

As a result of the above, here's one way of writing your code (use scrolling to change the scaling and see the result):

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1[Variables]W=320H=180S=1[BG]Meter=ShapeShape=Rectangle 0,0,(#W#*#S#),(#H#*#S#) | Fill Color 091,091,091 | StrokeWidth 0MouseScrollUpAction=[!SetVariable S (Clamp((#S#+0.1),0.5,5))][!UpdateMeter *][!Redraw]MouseScrollDownAction=[!SetVariable S (Clamp((#S#-0.1),0.5,5))][!UpdateMeter *][!Redraw]DynamicVariables=1[Shapes]Meter=ShapeX=0Y=0Shape = Path Path1 | fill color 43, 43, 43 | StrokeWidth 0 | Scale #S#,#S#,(0),(-125.5)Shape2 = Path Path2 | fill color 58, 58, 58 | StrokeWidth 0 | Scale #S#,#S#,(0),(-76.5)Shape3 = Path Path3 | fill color 76, 76, 77 | StrokeWidth 0 | Scale #S#,#S#,(0),(-40)Path1 = 320, 141.4 | LineTo 320, 180 | LineTo 0, 180 | LineTo 0, 125.5 | CurveTo 40, 128, 8.2, 125.8, 19.5, 127.2 | CurveTo 130, 153, 92, 130, 87, 146 | CurveTo 258, 134, 173, 160, 184, 138 | CurveTo 320, 141.4, 282.5, 132.7, 303.2, 136.2 | ClosePath 1Path2 = 320, 101.6 | LineTo 320, 141.4 | CurveTo 258, 134, 303.2, 136.2, 282.5, 132.7 | CurveTo 130, 153, 184, 138, 173, 160 | CurveTo 40, 128, 87, 146, 92, 130 | CurveTo 0, 125.5, 19.5, 127.2, 8.2, 125.8 | LineTo 0, 96.3 | CurveTo 59.5, 76.5, 12.3, 87.8, 34.2, 75.8 | CurveTo 135.5, 107.5, 98.5, 77.5, 101.5, 107.5 | CurveTo 211.5, 79.5, 169.5, 107.5, 181.5, 90.5 | CurveTo 320, 101.6, 233.5, 71.5, 287, 84.8 | ClosePath 1Path3 = 320, 80 | LineTo 320, 101.6 | CurveTo 211.5, 79.5, 287, 84.8, 233.5, 71.5 | CurveTo 135.5, 107.5, 181.5, 90.5, 169.5, 107.5 | CurveTo 59.5, 76.5, 101.5, 107.5, 98.5, 77.5 | CurveTo 0, 96.3, 34.2, 75.8, 12.3, 87.8 | LineTo 0, 40 | CurveTo 103, 71, 27.2, 44.8, 64.7, 60.7 | CurveTo 166, 52, 166, 88, 148, 64 | CurveTo 251, 55, 184, 40, 227, 40 | CurveTo 320, 80, 267.8, 65.5, 292.4, 71.1 | ClosePath 1DynamicVariables=1
I used a S variable to indicate the scaling value, then I used my (unreleased and obviously using my custom tooltip skin) Screen Ruler skin to find out the top left of each individual shape in the meter (which I double checked and adjusted if required by briefly looking at your Path options):
Screen Ruler.jpg
Then, I set the AnchorX and AnchorY of each individual shape to the "opposite" of that shape's coordinate in the Shape meter, so I can always indicate the top left corner of the meter as a reference point for scaling.

P.S. Obviously, if the shapes were to extend, even with a 0,0,0,1 color, to the 0,0 of the Shape meter, a 0,0 anchor could have been used in the scale modifier.

Similar code handling in the same way rotation instead of scaling, in my rotated visualizer here (the anchor pointing to the center of the blue rectangle):
https://forum.rainmeter.net/viewtopic.php?t=44722#p229080

Statistics: Posted by Yincognito — Yesterday, 6:14 pm



Viewing all articles
Browse latest Browse all 1428

Trending Articles