It is currently March 28th, 2024, 5:07 pm

Transformation matrix and circle issue

Get help with creating, editing & fixing problems with skins
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Transformation matrix and circle issue

Post by FreeRaider »

Hello all.
I'am working on a clock skin and I have two weird issues.

code:

Code: Select all

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

[Variables]
radius=300

[MeterBG]
Meter=RoundLine
X=(#Radius#*0.0)
Y=(#Radius#*0.0)
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=(#Radius#)
StartAngle=((Rad(270)))
LineColor=1,6,135,255
Solid=1
AntiAlias=1

[MeterDial_5]
Meter=Roundline
RotationAngle=(5/60*(Rad(360)))
X=0
Y=0
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=(#Radius#)
LineStart=(#Radius#*0.50)
LineWidth=(#Radius#*0.01)
StartAngle=((Rad(270)))
LineColor=afafaf
AntiAlias=1
DynamicVariables=1

[MeterSquare]
Meter=string
X=0
Y=0
SolidColor=255,0,0,255
FontFace=Courier New
FontSize=12
AntiAlias=1
Text=T
TransformationMatrix=1;(-SIN(RAD(-60)));(SIN(RAD(-60)));1;(#radius#+(#Radius#*0.80)*COS(RAD(60)));(#radius#-(#Radius#*0.80)*SIN(RAD(60)))
DynamicVariables=1
Image;
circle_issue.PNG


As you can see from the image I think there are two issues: the first (number 1) there is a vertical line but the circle should have a "solid" color, and the second (number two) I think that the issue come from the code of the "TransformationMatrix" option.


For the "TransformationMatrix" option, how do I get the left side of the rectangle aligned with the gray line (it would be 1 hour on the clock)? Currently, the gray line cuts the rectangle at an angle.

Thanks in advance.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

FreeRaider wrote: July 21st, 2021, 4:44 pm the first (number 1) there is a vertical line but the circle should have a "solid" color,
For this you should add a Solid=1 option to the [MeterDial_5] meter.
FreeRaider wrote: July 21st, 2021, 4:44 pm the second (number two) I think that the issue come from the code of the "TransformationMatrix" option.


For the "TransformationMatrix" option, how do I get the left side of the rectangle aligned with the gray line (it would be 1 hour on the clock)?
I'd definitely not recommend you to put the [MeterSquare] meter to X=0 and Y=0. Instead I'd place both, the line (the [MeterDial_5] meter, which doesn't necessary has to be a Roundline, it might be a Shape meter as well) and the string (the [MeterSquare] meter) to the same position and would rotate both with TransformationMatrix. Note that you'll need twelve such line - string pairs, right?
I'm writing an example and will post it soon back here. Stay tuned...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

Finally here is the code I've promised. Take a look, please:

Code: Select all

[RoundlineStyle]
RotationAngle=0
X=0
Y=0
H=(#Radius#*2.0)
W=(#Radius#*2.0)
LineLength=#Radius#
LineStart=(#Radius#*0.50)
LineWidth=(#Radius#*0.01)
StartAngle=((Rad(270)))
LineColor=afafaf
AntiAlias=1
Solid=0

[StringStyle]
X=#Radius#
Y=(#Radius#/3)
SolidColor=255,0,0,255
FontFace=Courier New
FontSize=12
AntiAlias=1
StringAlign=CenterCenter

[MeterDial_12]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))

[MeterSquare12]
Meter=string
MeterStyle=StringStyle
TransformationMatrix=(Cos(12*Rad(-360)/12));(-Sin(12*Rad(-360)/12));(Sin(12*Rad(-360)/12));(Cos(12*Rad(-360)/12));(#Radius#-(#Radius#*Cos(12*Rad(-360)/12))-(#Radius#*Sin(12*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(12*Rad(-360)/12))-(#Radius#*Cos(12*Rad(-360)/12)))
Text=12

[MeterDial_5]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterSquare5]
Meter=string
MeterStyle=StringStyle
Text=1
TransformationMatrix=(Cos(1*Rad(-360)/12));(-Sin(1*Rad(-360)/12));(Sin(1*Rad(-360)/12));(Cos(1*Rad(-360)/12));(#Radius#-(#Radius#*Cos(1*Rad(-360)/12))-(#Radius#*Sin(1*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(1*Rad(-360)/12))-(#Radius#*Cos(1*Rad(-360)/12)))

[MeterDial_10]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterSquare10]
Meter=string
MeterStyle=StringStyle
Text=2
TransformationMatrix=(Cos(2*Rad(-360)/12));(-Sin(2*Rad(-360)/12));(Sin(2*Rad(-360)/12));(Cos(2*Rad(-360)/12));(#Radius#-(#Radius#*Cos(2*Rad(-360)/12))-(#Radius#*Sin(2*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(2*Rad(-360)/12))-(#Radius#*Cos(2*Rad(-360)/12)))

[MeterDial_15]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterSquare15]
Meter=string
MeterStyle=StringStyle
Text=3
TransformationMatrix=(Cos(3*Rad(-360)/12));(-Sin(3*Rad(-360)/12));(Sin(3*Rad(-360)/12));(Cos(3*Rad(-360)/12));(#Radius#-(#Radius#*Cos(3*Rad(-360)/12))-(#Radius#*Sin(3*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(3*Rad(-360)/12))-(#Radius#*Cos(3*Rad(-360)/12)))

[MeterDial_20]
Meter=Roundline
MeterStyle=RoundlineStyle
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))

[MeterSquare20]
Meter=string
MeterStyle=StringStyle
Text=4
TransformationMatrix=(Cos(4*Rad(-360)/12));(-Sin(4*Rad(-360)/12));(Sin(4*Rad(-360)/12));(Cos(4*Rad(-360)/12));(#Radius#-(#Radius#*Cos(4*Rad(-360)/12))-(#Radius#*Sin(4*Rad(-360)/12)));(#Radius#+(#Radius#*Sin(4*Rad(-360)/12))-(#Radius#*Cos(4*Rad(-360)/12)))
Note the followings:
  • As previously said, beside the String meters, I transformed (rotated) the Roundline meters as well.
  • I wrote only the first four pairs. The others are similar and I hope you can figure out how to write them (see the following points as well).
  • I used two style sections ([RoundlineStyle] and [StringStyle]), in order to reduce the length of the Roundline and String meters. In fact the Roundline and the String meters have only the TransformationMatrix options and the String meters the Text options. Everything else are the same for the similar meters.
  • The TransformationMatrix options of the pair meters are the same. In each such TransformationMatrx option you have to replace the "indices" (eight times for each TransformationMatrix), which are the numbers (12, 1, 2, 3 and 4 in the above TransformationMatrix options). Obviously you'll have to use the following numbers (up to 11).
If you don't understand something please let me know what is that, to can assist you.
Is this what you wanted?
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Transformation matrix and circle issue

Post by FreeRaider »

balala wrote: July 21st, 2021, 5:48 pm For this you should add a Solid=1 option to the [MeterDial_5] meter.
Issue is in [MeterBG] and I don't understand why I see a vertical line. It's like the solid option doesn't complete the circle.

balala wrote: July 21st, 2021, 6:26 pm Finally here is the code I've promised. Take a look, please:
I'm working on it. I will let you know.

Thank you very much as always
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

FreeRaider wrote: July 21st, 2021, 7:50 pm Issue is in [MeterBG] and I don't understand why I see a vertical line. It's like the solid option doesn't complete the circle.
Sorry, it seems I misunderstood you.
Yes, you're right, the line is there. Weird is that it can be seen only for the StartAngle=(Rad(270)) value of the StartAngle. If you change it to any other value (except the values which are "complementar", -90 for instance) the line disappears. Don't know what to say.
Maybe a dev would be needed here...
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

FreeRaider wrote: July 21st, 2021, 7:50 pmIssue is in [MeterBG] and I don't understand why I see a vertical line. It's like the solid option doesn't complete the circle.
Removing or commenting out AntiAlias=1 from the meter should fix it, because it's about the rounding errors when it comes to pixels ... but then the circle's contour / edges will not be that smooth, so there is a drawback to it. Why not using the Ellipse shape to draw a full (and either filled or not) circle though?

Code: Select all

[MeterBG]
Meter=Shape
X=(#Radius#*0.0)
Y=(#Radius#*0.0)
Shape=Ellipse #Radius#,#Radius#,#Radius# | Fill Color 1,6,135,255 | StrokeWidth 0
AntiAlias=1
Also, just curious, is there a reason why you use TransformationMatrix for the dials and texts? Do you envision some other transformation, i.e. scaling or skewing for the future maybe? The dials can be drawn very easy just by modifiying the StartAngle option accordingly for each one of them, and Strings can also be rotated directly.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

balala wrote: July 21st, 2021, 8:30 pmWeird is that it can be seen only for the StartAngle=(Rad(270)) value of the StartAngle. If you change it to any other value (except the values which are "complementar", -90 for instance) the line disappears.
No, it doesn't dissapear, it's just that you don't see it because your desktop under that angle is probably darker. Move the skin towards a lighter area of your desktop and you'll see what I mean: the "gap" is always there (basically, it's about 0.00... degrees that are "transparent").
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

Yincognito wrote: July 21st, 2021, 8:41 pm No, it doesn't dissapear, it's just that you don't see it because your desktop under that angle is probably darker. Move the skin towards a lighter area of your desktop and you'll see what I mean: the "gap" is always there (basically, it's about 0.00... degrees that are "transparent").
Yep, you're right. Not sure what to say, may this be a bug?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transformation matrix and circle issue

Post by balala »

Yincognito wrote: July 21st, 2021, 8:35 pm Removing or commenting out AntiAlias=1 from the meter should fix it, because it's about the rounding errors when it comes to pixels ... but then the circle's contour / edges will not be that smooth, so there is a drawback to it.
Sorry, just realized I missed this before posting my previous reply, so no bug.
Yincognito wrote: July 21st, 2021, 8:35 pm Also, just curious, is there a reason why you use TransformationMatrix for the dials and texts? Do you envision some other transformation, i.e. scaling or skewing for the future maybe? The dials can be drawn very easy just by modifiying the StartAngle option accordingly for each one of them, and Strings can also be rotated directly.
You mean by the Angle option? If you do, rotating the String meter with TransformationMatrix is much more precise. You can easily get / change the rotation center.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Transformation matrix and circle issue

Post by Yincognito »

balala wrote: July 21st, 2021, 8:55 pmYou mean by the Angle option? If you do, rotating the String meter with TransformationMatrix is much more precise. You can easily get / change the rotation center.
Yes, that's true, but wouldn't this be eased by setting the StringAlign to CenterCenter? Didn't try it, but it should work in theory, shouldn't it? :???:
If the above is true, it would only leave the angle to be taken care of in that Angle option, and that is just as easy as for the TransformationMatrix, if I'm not mistaken.

P.S. Don't know if it's a bug or not, it depends on the interpretation. Technically, this is logical to happen, but from a user point of view it isn't the expected behavior (especially since the manual mentions a full circle when omitting MeasureName from the meter).
Post Reply