It is currently September 8th, 2024, 12:11 am

Round the edges of a roundline

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

Re: Round the edges of a roundline

Post by Yincognito »

ÞeSheepMan wrote: July 15th, 2024, 9:03 pm This was what I was looking for, but is there anyway to start it at an angle, one the same as what 0 speed on a speedometer would be? An angle at the lower left?
Here's a general sample that will make an arc of a Shape meter (red color) behave exactly like a Roundline meter (blue color) - no transformation matrix needed:

Code: Select all

[Variables]
EllipseFillColor=0,0,0,255
EllipseStrokeColor=255,255,255,255
EllipseStrokeWidth=2
RoundlineColor=0,0,255,255

ArcStrokeColor=255,0,0,255
ArcStrokeWidth=16
ArcCenterX=90
ArcCenterY=90
ArcRadiusX=80
ArcRadiusY=80
ArcStartAngle=330
ArcDirectionAngle=-260
ArcRotationAngle=0
ArcShapeEnding=0

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

---Measures---

[Percent]
Measure=Calc
Formula=((Percent+1)%100)
MinValue=0
MaxValue=100

---Meters---

[Ellipse]
Meter=Shape
Shape=Ellipse (#ArcCenterX#),(#ArcCenterY#),(#ArcRadiusX#+#ArcStrokeWidth#/2+#EllipseStrokeWidth#/2),(#ArcRadiusY#+#ArcStrokeWidth#/2+#EllipseStrokeWidth#/2) | Fill Color #EllipseFillColor# | StrokeWidth #EllipseStrokeWidth# | Stroke Color #EllipseStrokeColor#
DynamicVariables=1

[Arc]
Meter=Shape
Shape=Arc (#ArcCenterX#+#ArcRadiusX#*Cos(Rad(#ArcStartAngle#))),(#ArcCenterY#+#ArcRadiusY#*Sin(Rad(#ArcStartAngle#))),(#ArcCenterX#+#ArcRadiusX#*Cos(Rad(#ArcStartAngle#+#ArcDirectionAngle#*[Percent:]/[Percent:MaxValue]))),(#ArcCenterY#+#ArcRadiusY#*Sin(Rad(#ArcStartAngle#+#ArcDirectionAngle#*[Percent:]/[Percent:MaxValue]))),#ArcRadiusX#,#ArcRadiusY#,#ArcRotationAngle#,(#ArcDirectionAngle#<0?1:0),(Abs(#ArcDirectionAngle#*[Percent:]/[Percent:MaxValue])<180?0:1),#ArcShapeEnding# | StrokeWidth #ArcStrokeWidth# | Stroke Color #ArcStrokeColor#
DynamicVariables=1

[Roundline]
Meter=Roundline
X=(#EllipseStrokeWidth#)
Y=(#EllipseStrokeWidth#)
W=(#ArcRadiusX#*2+#ArcStrokeWidth#)
H=(#ArcRadiusX#*2+#ArcStrokeWidth#)
LineColor=#RoundlineColor#
StartAngle=(Rad(#ArcStartAngle#))
RotationAngle=(Rad(#ArcDirectionAngle#))
LineStart=(#ArcRadiusX#)
LineLength=(#ArcRadiusX#+#ArcStrokeWidth#/2)
Solid=1
MeasureName=Percent
DynamicVariables=1
Feel free to adapt it to your needs, e.g. remove the Ellipse and the Roundline stuff that are there for demonstration purposes, use your CPUUsage measure instead of the Percent measure, get rid of the [Rainmeter] section if you already have one in your skin, add back whatever shape modifiers and round stroke caps you had in your code as per the earlier instructions by balala, and obviously adjust the Arc... variables to replicate the desired speedometer / gauge figure. In case it's not obvious, ArcStartAngle and ArcDirectionAngle are the exact equivalents for the values of the StartAngle and RotationAngle options in a Roundline meter, so that's how you set up where your gauge starts and ends.

References:
- https://docs.rainmeter.net/manual/meters/shape/#Arc (to know what each parameter of the Arc shape means)
- https://docs.rainmeter.net/manual/meters/roundline/ (to know how to adjust the ArcStartAngle and ArcDirectionAngle variables / values)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16499
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round the edges of a roundline

Post by balala »

ÞeSheepMan wrote: July 15th, 2024, 9:36 pm How could I prevent it from moving?
Try using the following TransformationMatrix on the [CPUUsageGraph] meter (instead of the previously posted one): TransformationMatrix=(Cos(Rad(#RotationAngle#)));(-1*Sin(Rad(#RotationAngle#)));(Sin(Rad(#RotationAngle#)));(Cos(Rad(#RotationAngle#)));(430-(430*Cos(Rad(#RotationAngle#)))-(173*Sin(Rad(#RotationAngle#))));(173+(430*Sin(Rad(#RotationAngle#)))-(173*Cos(Rad(#RotationAngle#)))).

Note a disadvantage of this approach: since in your meter you've used some constant values, added as numbers (I'm referring here to the values 430 and 173, used into the Shape and Shape2 options), I had to use the same values into the above TransformationMatrix option, added same way, as numbers. If you move your meter, or even worse the shapes into the meter itself, the TransformationMatrix will have to be rewritten. I'd use those numbers better as variables, added to the [Variables] section. This approach would let us to can make the meter to be same way rotated, no matter where do you place it.
If you are absolutely positive you'll never move the meter, your approach is a good one, but can you be absolutely positive on this?
ÞeSheepMan
Posts: 9
Joined: July 15th, 2024, 12:22 am

Re: Round the edges of a roundline

Post by ÞeSheepMan »

Yincognito wrote: July 16th, 2024, 7:58 pm Feel free to adapt it to your needs, e.g. remove the Ellipse and the Roundline stuff that are there for demonstration purposes, use your CPUUsage measure instead of the Percent measure, get rid of the [Rainmeter] section if you already have one in your skin, add back whatever shape modifiers and round stroke caps you had in your code as per the earlier instructions by balala, and obviously adjust the Arc... variables to replicate the desired speedometer / gauge figure. In case it's not obvious, ArcStartAngle and ArcDirectionAngle are the exact equivalents for the values of the StartAngle and RotationAngle options in a Roundline meter, so that's how you set up where your gauge starts and ends.
For future reference both of these strategies did indeed work. The roundline meter was what I was trying to use at first until I found this thread. So thank you for showing me this to solve an old issue I was having.
balala wrote: July 16th, 2024, 8:29 pm Note a disadvantage of this approach: since in your meter you've used some constant values, added as numbers (I'm referring here to the values 430 and 173, used into the Shape and Shape2 options), I had to use the same values into the above TransformationMatrix option, added same way, as numbers. If you move your meter, or even worse the shapes into the meter itself, the TransformationMatrix will have to be rewritten. I'd use those numbers better as variables, added to the [Variables] section. This approach would let us to can make the meter to be same way rotated, no matter where do you place it.
If you are absolutely positive you'll never move the meter, your approach is a good one, but can you be absolutely positive on this?
Like I said previously, this also worked, and in hindsight, the variables are a much better idea and I can't remember at this point why I didn't use them in the first place. I have since converted most of my values in the final product to variables to account for this.

Thank you very much for the support both of yall! Final result somewhere around here (not sure if itll show above or below and still a work in progress)
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Round the edges of a roundline

Post by Yincognito »

ÞeSheepMan wrote: July 16th, 2024, 9:11 pm For future reference both of these strategies did indeed work.
Excellent - just use whatever you're most comfortable with, we're always glad to help! :great:

I hope you don't mind that I intentionally didn't set those angles to the values that you needed, in order to let you change them yourself and understand the idea behind it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ÞeSheepMan
Posts: 9
Joined: July 15th, 2024, 12:22 am

Re: Round the edges of a roundline

Post by ÞeSheepMan »

Yincognito wrote: July 16th, 2024, 9:36 pm Excellent - just use whatever you're most comfortable with, we're always glad to help! :great:

I hope you don't mind that I intentionally didn't set those angles to the values that you needed, in order to let you change them yourself and understand the idea behind it. ;-)
Its all good, I appreciate you letting me learn my way through it :thumbup:
ÞeSheepMan
Posts: 9
Joined: July 15th, 2024, 12:22 am

Re: Round the edges of a roundline

Post by ÞeSheepMan »

I do actually have one more issue. I flipped it around for the GPU as well, but it results in the right hand side getting cut off as shown in the image. Increasing the thickness of the inner purple circle or the more outer gray circle seems to fix it but it seems weird that its dependent on those two circles. How could I prevent this?

(Gray)

Code: Select all

[GPUUsageGraphLineCircle]
Meter=Shape
Shape=Ellipse #CenterXGPU#, #CenterYGPU#, 91 | Fill Color 0, 0, 0, 0 | StrokeWidth 10 | Stroke Color 95, 96, 98, 255
(Purple)

Code: Select all

[GPUUsageGraphInnerCircle]
Meter=Shape
Shape=Ellipse #CenterXGPU#, #CenterYGPU#, 79 | Fill Color 0, 0, 0, 0 | StrokeWidth 15 | Stroke Color 132, 119, 183, 255
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Round the edges of a roundline

Post by Yincognito »

ÞeSheepMan wrote: July 16th, 2024, 10:33 pm I do actually have one more issue. I flipped it around for the GPU as well, but it results in the right hand side getting cut off as shown in the image. Increasing the thickness of the inner purple circle or the more outer gray circle seems to fix it but it seems weird that its dependent on those two circles. How could I prevent this?

(Gray)

Code: Select all

[GPUUsageGraphLineCircle]
Meter=Shape
Shape=Ellipse #CenterXGPU#, #CenterYGPU#, 91 | Fill Color 0, 0, 0, 0 | StrokeWidth 10 | Stroke Color 95, 96, 98, 255
(Purple)

Code: Select all

[GPUUsageGraphInnerCircle]
Meter=Shape
Shape=Ellipse #CenterXGPU#, #CenterYGPU#, 79 | Fill Color 0, 0, 0, 0 | StrokeWidth 15 | Stroke Color 132, 119, 183, 255
A bit difficult to put the finger on what the problem is without having an idea of what other relevant parts of the code look like, but unless you're limiting your skin's size via SkinWidth and SkinHeight instead of using DynamicWindowSize to make it adapt to its contents, one thing I can think of as a cause for this is that you're maybe not taking into account the fact that the stroke in a shape is "half in and half out" the coordinates of the said shape, like explained in the notes on StrokeWidth... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ÞeSheepMan
Posts: 9
Joined: July 15th, 2024, 12:22 am

Re: Round the edges of a roundline

Post by ÞeSheepMan »

Thank you very much, I got it working! (:
User avatar
sl23
Posts: 1600
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Round the edges of a roundline

Post by sl23 »

I had the same issue years ago with shapes, I had to specify the square size of the shape so it wouldn't cut off that bit.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Round the edges of a roundline

Post by Yincognito »

I had the opposite problem recently, where a 0,0,0,0 colored shape would still take space and enlarge the skin's size, despite the fact that it normally shouldn't have, given that it was fully transparent.

Specifying the size of the meter seems to be more of a Roundline thing than a Shape one since the latter sets the size of its meter based on the containing shapes and doesn't even need a W and H on it... :confused:

Anyway, I'm glad you got it working, that's the spirit! :great:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth