It is currently February 24th, 2020, 11:10 pm

New Path type added to Shape Meter (and more)

Changes made during the Rainmeter 4.0 beta cycle.
User avatar
jsmorley
Developer
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New Path type added to Shape Meter (and more)

Post by jsmorley »

We have several important changes to the Shape meter as of the r2708 beta release.

https://www.rainmeter.net

First, we have added the new Path shape type to the meter.

https://docs.rainmeter.net/manual-beta/meters/shape/

https://docs.rainmeter.net/manual-beta/meters/shape/#Path

This is really the Big Kahuna of "drawing", and is how you will create most shapes that are not simple rectangles, ellipses or curves. The documentation explains in detail of course, but the long and the short of it is that you simply define a "starting point", and then a series of one or more "segments" that can be LineTo, ArcTo, or CurveTo. Each segment will automatically start where the previous one ended.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterShape]
Meter=Shape
Shape=Path MyPath | StrokeSize 2 | Fill Color 106,227,95,255
MyPath=2,100 | LineTo 50,2 | LineTo 100,100 | LineTo 2,100 | ClosePath 1
1.jpg

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterShape]
Meter=Shape
Shape=Path MyPath | StrokeWidth 2 | Stroke Color 41,4,2,255 | Fill LinearGradient MyGradient
MyPath=20,2 | LineTo 150,2 | LineTo 170,20 | LineTo 170,60 | LineTo 150,80 | LineTo 20,80 | LineTo 2,60 | LineTo 2,20 | LineTo 20,2 | ClosePath 1
MyGradient=180 | 161,49,43 ; 0.0 | 230,99,92 ; 1.0
3.jpg
We have added control over which parts of your path are "stroked", and some control over how angular segments are "joined".

Code: Select all

[MeterRingo]
Meter=Shape
X=50
Y=50
Shape=Path MyPath | StrokeWidth 50 | Stroke Color 41,4,2,255 | Fill Color 255,205,148,255 | StrokeLineJoin Round
MyPath=20,0 | LineTo 150,0 | LineTo 170,20 | LineTo 170,60 | SetNoStroke 1 | LineTo 150,80 | LineTo 20,80 | LineTo 0,60 | SetNoStroke 0 | LineTo 0,20 | ClosePath 1
2.jpg
Path shapes may be "open" or "closed", but do be aware that any path shape used with Combine will automatically be closed before it is combined with any other shapes. You simply can't combine anything that is just a "stroke" and has no real "inside". There is nothing to "combine".

Second, We have made all measurements in pixels that you use in the definitions for your shape use Device Independent Pixels (we call them "pixies"). This means that all these values can be fractional. (i.e. 10.75 or 0.254) This will improve "precision" quite a bit when you are creating complicated shapes. Be aware, this does not change the behavior of underlying integer pixel measurements for "meter" options like W/H/X/Y, but does for all pixel values used in your shapes.

Third, We have changed the default "anchors" for the Scale and Skew transform modifiers to use the center of the shape instead of the top-left. We found that it could be difficult on a complicated shape to manually figure out the center, while top-left and bottom-right are more obvious. So we want Rainmeter to do the hard work...
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Path type added to Shape Meter

Post by jsmorley »

Oh, and one other little "bonus"

We were looking to add "Flip" as a transform modifier for shapes, but discovered that you can already easily do that with the Scale transform modifier:

https://docs.rainmeter.net/manual-beta/meters/shape/#Scale
A shape may be "flipped" or "mirrored" using Scale, by simply scaling it -1.0 on the axis you wish to flip. So Horizontal would be -1.0,1.0, Vertical would be 1.0,-1.0, and Both would be -1.0,-1.0.
User avatar
jsmorley
Developer
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Path type added to Shape Meter (and more)

Post by jsmorley »

Actually it works really, really, really well, since TransformationMatirx is applied at the same time the shape is drawn. So there is a lot more "cooperation" between the TransformationMatrix and the Shape meter than I thought there would be.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
ScaleFactor=5

[MeterLogo]
Meter=Shape
W=(37 * #ScaleFactor#)
H=(57 * #ScaleFactor#)
Shape = Path Path1 | StrokeWidth (4 * #ScaleFactor#) | Stroke Color 42,108,155,255 | Fill Color 0,0,0,1
Path1 = 35, 39.39 | CurveTo 19, 54.28, 35, 47.62, 27.84, 54.28 | CurveTo 3, 39.39, 10.16, 54.28, 3, 47.615 | CurveTo 19, 6.283, 3, 31.16, 19, 6.283 | CurveTo 35, 39.385, 19, 6.283, 35, 31.158 | ClosePath 1

Shape2 = Path Path2 | Fill Color 224,144,40,255| StrokeWidth 0
Path2 = 18.875, 37.66 | CurveTo 7.14, 37.66, 10.22, 31.44, 7.14, 37.66 | CurveTo 7, 38.99, 7.05, 38.15, 7, 38.59 | CurveTo 19, 50.16, 7, 45.16, 12.37, 50.16 | CurveTo 31, 38.99, 25.63, 50.16, 31, 45.16 | CurveTo 30.86, 37.66, 31, 38.59, 30.95, 38.15 | CurveTo 18.88, 37.66, 30.86, 37.66, 27.53, 43.88 | ClosePath 1

TransformationMatrix=#scaleFactor#;0;0;#ScaleFactor#;0;0
DynamicVariables=1
1.jpg
Thanks to theAzack9 for help with the TransformationMatrix!
You do not have the required permissions to view the files attached to this post.