It is currently March 29th, 2024, 8:15 am

Circular Line with Gradient

Tips and Tricks from the Rainmeter Community
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Circular Line with Gradient

Post by fonpaolo »

Just a quick question, I still have to experiment with Shape meter, but, can't you use Rotate with ActionTimer?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Circular Line with Gradient

Post by jsmorley »

fonpaolo wrote:Just a quick question, I still have to experiment with Shape meter, but, can't you use Rotate with ActionTimer?

Sure, just set it as a #VarName# like anything else you are changing with ActionTimer. Just keep adding (clockwise) or subtracting (counter-clockwise) to it, but be sure you have some IfCondition somewhere that changes it back to 0 degrees when it hits 360 degrees if you are adding to it, or that changes it back to 360 degrees when it hits 0 degrees if you are subtracting.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Circular Line with Gradient

Post by jsmorley »

Code: Select all

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

[Variables]
R=0
U=[!UpdateMeasure MeasureRotate][!UpdateMeter MeterShape][!Redraw]

[MeterShape]
Meter=Shape
X=40
Y=40
Shape=Rectangle 0,0,100,20 | Strokewidth 0 | Fill Color 255,0,0,255 | Rotate #R#
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureRotate "Execute 1"]

[MeasureRotate]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Rotate, 5, 360
Rotate=[!SetVariable R "(#R#+1)]#U#
DynamicVariables=1
IfCondition=#R#=360
IfTrueAction=[!SetVariable R "0"]#U#
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Circular Line with Gradient

Post by fonpaolo »

I'm still almost inexperienced with Shape meter, but I'm having fun with ActionTimer.
To rotate something with ActionTimer, I use [!SetVariable Rot1 "((#Rot1#+#Angle#) %360)"]
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Circular Line with Gradient

Post by jsmorley »

fonpaolo wrote:I'm still almost inexperienced with Shape meter, but I'm having fun with ActionTimer.
To rotate something with ActionTimer, I use [!SetVariable Rot1 "((#Rot1#+#Angle#) %360)"]

Using modulus is a good idea...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Circular Line with Gradient

Post by jsmorley »

Code: Select all

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

[Variables]
R=0
U=[!UpdateMeasure MeasureRotate][!UpdateMeter MeterShape][!Redraw]

[MeterShape]
Meter=Shape
X=40
Y=40
Shape=Rectangle 0,0,100,20 | Strokewidth 0 | Fill Color 255,0,0,255 | Rotate #R#
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureRotate "Execute 1"]

[MeasureRotate]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Rotate, 5, 360
Rotate=[!SetVariable R "(#R#+1 %360)]#U#
DynamicVariables=1
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Circular Line with Gradient

Post by kyriakos876 »

Another quick question, can you change the point that the meter rotates around? The default point is obviously the center of the shape, but can I change that and If so, how?

(I know you can but I just haven't cracked the code yet so I'm wondering if anyone has)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Circular Line with Gradient

Post by balala »

kyriakos876 wrote:Oh I thought you meant do it without TransformationMatrix and replace it with actiontimer by changing the variables and adding some more (which I think I preeeeetty hard)... Yea if you keep TransMatrix it's obviously possible :P
Probably there are other ways to do it, too, however (at least for me) the TransformationMtrix solution is far the simplest one.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Circular Line with Gradient

Post by jsmorley »

kyriakos876 wrote:Another quick question, can you change the point that the meter rotates around? The default point is obviously the center of the shape, but can I change that and If so, how?

(I know you can but I just haven't cracked the code yet so I'm wondering if anyone has)
You can specify where you want the anchor of rotation on the Rotate option on a Shape meter.

https://docs.rainmeter.net/manual/meters/shape/#Rotate
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Circular Line with Gradient

Post by balala »

kyriakos876 wrote:Another quick question, can you change the point that the meter rotates around? The default point is obviously the center of the shape, but can I change that and If so, how?

(I know you can but I just haven't cracked the code yet so I'm wondering if anyone has)
Beside jsmorley's approach, if want to keep using the TransformationMatrix, specifying the rotation center is definitely possible, but I don't find it very useful. Rotating the initial Shape meter around any other point than its center, makes it to look extremely weird...
However here is the solution:

Code: Select all

[Rainmeter]
Update=-1
BackgroundMode=2
SolidColor=0,0,0,1
LeftMouseUpAction=[!CommandMeasure "MeasureAngle" "Execute 1"]

[Metadata]
Name=Circle Line Gradient
Author=ChicknwitNoName
Information=Fake it 'til they make it.
Version=1.0
License=Creative Commons Attribution-NonCommercial-ShareAlike 4.0

[Variables]
Angle=0
U=[!UpdateMeasure "MeasureAngle"][!UpdateMeter "Circle"][!Redraw]
RotationCenterX=150
RotationCenterY=100

[MeasureAngle]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Rotate,30,36
Rotate=[!SetVariable Angle "(Clamp((#Angle#+10),0,360))"]#U#
IfCondition=(#Angle#>=360)
IfTrueAction=[!SetVariable Angle "0"][!CommandMeasure "MeasureAngle" "Execute 1"]#U#
DynamicVariables=1

[Circle]
Meter=Shape
X=100
Y=25
Shape =Path Path1 | StrokeWidth 0 | Fill LinearGradient NW
Shape2=Path Path2 | StrokeWidth 0 | Fill LinearGradient NE
Shape3=Path Path3 | StrokeWidth 0 | Fill LinearGradient SE
Shape4=Path Path4 | StrokeWidth 0 | Fill LinearGradient SW
Path1=50,3 | CurveTo 3,50,24.06,3,3,24.06 | LineTo 0,50 | CurveTo 50,0,0,22.404,22.404,0 | LineTo 50,3 | ClosePath 1
Path2=50.323,0.001 | CurveTo 100,50,77.77,0.175,100,22.512 | LineTo 97,50 | CurveTo 50,3,97,24.06,75.94,3 | LineTo 50,0 | LineTo 50.323,0.001 | ClosePath 1
Path3=100,50 | CurveTo 50,100,100,77.596,77.596,100 | LineTo 50,97 | CurveTo 97,50,75.94,97,97,75.94 | LineTo 100,50 | ClosePath 1
Path4=3,50 | CurveTo 50,97,3,75.94,24.06,97 | LineTo 50,100 | CurveTo 0,50,22.404,100,0,77.596 | LineTo 3,50 | ClosePath 1
NW=90 | 255,255,255,200 ; 0.0 | 255,255,255,150 ; 1.0
NE=-90 | 255,255,255,150 ; 0.0 | 255,255,255,100 ; 1.0
SE=0 | 255,255,255,100 ; 0.0 | 255,255,255,50 ; 1.0
SW=0 | 255,255,255,50 ; 0.0 | 255,255,255,0 ; 1.0
TransformationMatrix=(Cos(Rad(#Angle#)));(-Sin(Rad(#Angle#)));(Sin(Rad(#Angle#)));(Cos(Rad(#Angle#)));(#RotationCenterX#-#RotationCenterX#*Cos(Rad(#Angle#))-#RotationCenterY#*Sin(Rad(#Angle#)));(#RotationCenterY#+#RotationCenterX#*Sin(Rad(#Angle#))-#RotationCenterY#*Cos(Rad(#Angle#)))
DynamicVariables=1
The newly added RotationCeneterX and RotationCenterY variables are the coordinates of the rotation center. This point can be placed either inside or outside of the shape.
In the TransformationMatrix option I replaced the ([Circle:X]+[Circle:W]/2) expression with the #RotationCenterX# variable and the ([Circle:Y]+[Circle:H]/2) expression with #RotationCenterY#. ([Circle:X]+[Circle:W]/2) and ([Circle:Y]+[Circle:H]/2) are the coordinates of the center of the shape and this point was initially the rotation center. Now the center of the rotation is represented by the point with the new coordinates (#RotationCenterX# and #RotationCenterY#).
Looks weird, as I said...