StrokeWidth : Part 1
Taking StrokeWidth into account in your designs really is something you are always going to have to do, but it really isn't that hard, and is something I think you can get used to. Well, something you really will just have to get used to in order to use this meter in any "accurate" way.
You are "drawing" a shape of some defined size. Think of it as drawing a rectangle on a piece of paper with a pencil. So to draw a rectangle 100 x 100, you put your pencil down on the paper at exactly the point that defines 100, and draw the rectangle. So far so good.
But wait. The tip of the pencil has some "width" doesn't it? Doesn't matter how much you sharpen it, it still has some width. The drawing line on the paper (the "stroke") is "centered" on exactly 100, with half of the width of the stroke outside of the point that defines 100, and half inside.
So the "drawing" you end up with isn't really 100 x 100 is it... Its width is 100 + the width of the pencil tip. While what is "added" by the width of the pencil tip is only half "outside" the point that defines 100, it is both half on the left and half on the right, for a total change in width of the width of the pencil tip. The stroke. Same for the height, the top and bottom.
So you will always need to consider the size of the StrokeWidth you use on a shape. "How big is my pencil?" You will need to consider (StrokeWidth / 2) for the "position" of the shape in your skin, the X and Y, and the entire StrokeWidth for the "size" of the shape in your skin, the W and H.
Let's look at an example:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[MeterShape]
Meter=Shape
Shape=Rectangle 5,5,200,200 | Fill Color 0,0,0,255 | StrokeWidth 10 | Stroke Color 255,0,0,90
Shape2=Rectangle 215,5,200,200 | Fill Color 0,0,0,255 | StrokeWidth 10 | Stroke Color 255,0,0,90
1.jpg
If we disassemble this a bit, I'll explain what is going on.
First, note that we have an X and Y position of the first shape within the overall meter of
Rectangle=5,5. Why are we doing that? Well, since the meter is at 0,0 in the skin, no X and Y for the meter is defined, if we put our pencil down at 0,0 and start drawing, half of the width of the pencil tip is going to end up outside the entire skin on the left and top, and won't be drawn. Half of the stroke is going to be truncated. We need to move the shape in by (StrokeWidth / 2) to make room for it.
Then we define a rectangle that is
200,200 with
StrokeWidth 10.
The result is that box on the left. Is it really 200 X 200? Nope. The "center" of the stroke defines 200, and the overall width and height of the shape is 210 X 210.
So to have a second shape that is the same size, and is exactly to the right of the first one, we need to define what X and Y position it should have in the meter.
So we set
Rectangle 215,5 on the second shape. it needs to be positioned just to the right of the ACTUAL width of the first shape and its stroke, which is 210, and then allow for half of its own StrokeWidth being "outside" as well. So that is how we end up with 215 for the "position" of the second shape.
In order to have a shape that has a StrokeWidth of 10, and the entire shape, including the stroke, MUST be exactly 200 wide, you can certainly do that. You just have to define the "size" of the shape with a value that is (200 - (StrokeWidth/2)). So the shape will have a width of 190, half the StrokeWidth will be added to the left, and half to the right, and the resulting meter will be exactly 200 wide.
This won't be a concern if you have two shapes that are in two entirely separate meters, since the meter "container" automatically created by the first shape will be 210 wide, and using
X=0R on a second meter will in fact properly position them without any need to figure it out for yourself. If however, you have two shapes in the same meter, you will need to account for StrokeWidth in your design.