It is currently August 11th, 2020, 7:24 pm

shapes and average

Help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 11199
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: shapes and average

Post by balala »

mak_kawa wrote: December 6th, 2019, 11:53 am No, I have a feeling that I am still a noob in Rainmeter world.
I am always stumbling on RegExp, IfCondition, Substitute, !EnableMeasure...every day, every time I write/modify Rainmeter code.
"Why, why doesn't this code work?!"
"Where does this error come from?"
"I can't figure out!!"
I suppose everyone of us is experimenting such feelings sometimes, but I definitely doesn1t consider you being a noob. Just keep working...
User avatar
balala
Rainmeter Sage
Posts: 11199
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: shapes and average

Post by balala »

jsmorley wrote: December 6th, 2019, 4:15 pm TransformationMatrix is the devil's work... ;-)
No, it's not at all. It's pure mathematics. And math is my (our?) friend.
User avatar
Mor3bane
Posts: 884
Joined: May 7th, 2016, 7:32 am

Re: shapes and average

Post by Mor3bane »

I for one, welcome our transformationmatrix overlord.
5ySD02A.gif
You do not have the required permissions to view the files attached to this post.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that is requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 11199
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: shapes and average

Post by balala »

balala wrote: December 6th, 2019, 4:14 pm but a little bit later I'll post an example you to see what am I talking about.
Stay tuned, if interested...
And here is the promised example. The following skin has an initially not rotated yellow rectangle. You can set the coordinates of the center of rotation, through the CenterX and CenterY variables. Take care these coordinates are relative to the position of the [MeterTransformationMatrix] meter. For instance for CenterX=0 and CenterY=0 you'll get the meter rotated around its upper left corner.
You also have to set the rotation angle. Note that a positive angle means anticlockwise rotation, while a negative angle means clockwise rotation.
If you click the yellow rectangle, you get it rotated.
The code:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,100
SkinWidth=450
SkinHeight=350

[Variables]
Angle=-30
CenterX=125
CenterY=75
Rotate=0

[MeterTransformationMatrix]
Meter=Image
SolidColor=255,240,0
X=100
Y=100
W=250
H=150
TransformationMatrix=(Cos(Rad(#Angle#*#Rotate#)));(-Sin(Rad(#Angle#*#Rotate#)));(Sin(Rad(#Angle#*#Rotate#)));(Cos(Rad(#Angle#*#Rotate#)));((#CenterX#+[MeterTransformationMatrix:X])-((#CenterX#+[MeterTransformationMatrix:X])*Cos(Rad(#Angle#*#Rotate#)))-((#CenterY#+[MeterTransformationMatrix:Y])*Sin(Rad(#Angle#*#Rotate#))));((#CenterY#+[MeterTransformationMatrix:Y])+((#CenterX#+[MeterTransformationMatrix:X])*Sin(Rad(#Angle#*#Rotate#)))-((#CenterY#+[MeterTransformationMatrix:Y])*Cos(Rad(#Angle#*#Rotate#))))
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Rotate "(1-#Rotate#)"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Don't be afraid of the above code, it's not so complicated as it seems at a first look. Feel free to ask if you can't figure out something related to the code.
ItsJustRyan
Posts: 40
Joined: October 25th, 2019, 1:20 am

Re: shapes and average

Post by ItsJustRyan »

balala wrote: December 6th, 2019, 9:11 pm And here is the promised example. The following skin has an initially not rotated yellow rectangle. You can set the coordinates of the center of rotation, through the CenterX and CenterY variables. Take care these coordinates are relative to the position of the [MeterTransformationMatrix] meter. For instance for CenterX=0 and CenterY=0 you'll get the meter rotated around its upper left corner.
You also have to set the rotation angle. Note that a positive angle means anticlockwise rotation, while a negative angle means clockwise rotation.
If you click the yellow rectangle, you get it rotated.
The code:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,100
SkinWidth=450
SkinHeight=350

[Variables]
Angle=-30
CenterX=125
CenterY=75
Rotate=0

[MeterTransformationMatrix]
Meter=Image
SolidColor=255,240,0
X=100
Y=100
W=250
H=150
TransformationMatrix=(Cos(Rad(#Angle#*#Rotate#)));(-Sin(Rad(#Angle#*#Rotate#)));(Sin(Rad(#Angle#*#Rotate#)));(Cos(Rad(#Angle#*#Rotate#)));((#CenterX#+[MeterTransformationMatrix:X])-((#CenterX#+[MeterTransformationMatrix:X])*Cos(Rad(#Angle#*#Rotate#)))-((#CenterY#+[MeterTransformationMatrix:Y])*Sin(Rad(#Angle#*#Rotate#))));((#CenterY#+[MeterTransformationMatrix:Y])+((#CenterX#+[MeterTransformationMatrix:X])*Sin(Rad(#Angle#*#Rotate#)))-((#CenterY#+[MeterTransformationMatrix:Y])*Cos(Rad(#Angle#*#Rotate#))))
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Rotate "(1-#Rotate#)"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Don't be afraid of the above code, it's not so complicated as it seems at a first look. Feel free to ask if you can't figure out something related to the code.
:thumbup:
User avatar
balala
Rainmeter Sage
Posts: 11199
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: shapes and average

Post by balala »

ItsJustRyan wrote: December 8th, 2019, 3:00 am :thumbup:
Do you find it complicated? Because it's not too much...
ItsJustRyan
Posts: 40
Joined: October 25th, 2019, 1:20 am

Re: shapes and average

Post by ItsJustRyan »

Its working perfectly :)
User avatar
balala
Rainmeter Sage
Posts: 11199
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: shapes and average

Post by balala »

ItsJustRyan wrote: December 9th, 2019, 9:49 am Its working perfectly :)
I'm glad. :thumbup: