It is currently April 26th, 2024, 3:39 am

Shape Meter - Scaling not centered/offset correctly for combined shapes.

Get help with creating, editing & fixing problems with skins
JHB101101
Posts: 10
Joined: June 24th, 2021, 8:58 am

Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by JHB101101 »

Hi

My first post here... Hope it comes out correctly. :welcome:

I have an alphabet made from shapes. So I add each letter as a shape with an inline offset. It looks something like the following pseudo "code":

Code: Select all

	Shape=Path TitleGlyph1|Extend SharedModifiers
	Shape2=Path TitleGlyph2|Offset 42,0|Extend SharedModifiers
	Shape3=Path TitleGlyph3|Offset (42*2),0|Extend SharedModifiers
Now if I scale each individual letter shape smaller they nicely shrink to their own center as indicated in the help documentation, but that is not what I need:

Code: Select all

	Shape=Path TitleGlyph1|Scale 0.2,0.2|Extend SharedModifiers
	Shape2=Path TitleGlyph2|Offset 42,0|Scale 0.2,0.2|Extend SharedModifiers
	Shape3=Path TitleGlyph3|Offset (42*2),0|Scale 0.2,0.2|Extend SharedModifiers

Thus my next plan of action. I combine them and then perform the scale:

Code: Select all

	Shape=Path TitleGlyph1|Extend SharedModifiers
	Shape2=Path TitleGlyph2|Offset 42,0|Extend SharedModifiers
	Shape3=Path TitleGlyph3|Offset (42*2),0|Extend SharedModifiers
	Shape4=Combine Shape|Union Shape2|Union Shape3|Scale 0.2,0.2
However, now they shrink correctly and keep their distance from each other proportionally, but the entire word jump 450 pixels to the left. Is this correct behavior or am I missing something.

My best guess so far is that this is what usually happens when I scale in OpenGL since it calculates the scale against all numbers and you have to bring it back afterwards. In the unlikely event that this is the case I think there should at least be a mention in the documentation that combined shapes do not comply with the center/offset rules of the Scale inline option.

Kind Regards,

Jayson
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by death.crafter »

JHB101101 wrote: June 24th, 2021, 9:39 am My best guess so far is that this is what usually happens when I scale in OpenGL since it calculates the scale against all numbers and you have to bring it back afterwards. In the unlikely event that this is the case I think there should at least be a mention in the documentation that combined shapes do not comply with the center/offset rules of the Scale inline option.
Though I can understand what you are trying to do here and what is wrong, an attached skin (rmskin or zip of the config folder) would have been better. To better understand the situation.

But my guess is when the shape is shrank due to scaling, though the anchors are in the center, it's position is adjusted so that it starts from the top left corner of the whole shape meter.
from the Realm of Death
JHB101101
Posts: 10
Joined: June 24th, 2021, 8:58 am

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by JHB101101 »

Hi @death.crafter

There is no code like this anymore. I deleted it as a final act of defiance. I guess I can type something up, but time is not on my side right now. I will take 3 rectangles later when it is not so busy and do this to them. If they work, the error becomes more strange.

Kind Regards,

Jayson
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by balala »

In such cases, as you saw I think, the scaling is going on by the center of the shape. But where that center is and generally how the shapes are behaving, depends extremely much on how the Paths are looking. Probably no one will be able to say something meaningful without knowing at least the code of the whole Shape meter(s). As death.crafter said, a complete code or even better a packed config would be needed. Please help us to can help you whenever are you asking for help.
User avatar
Yincognito
Rainmeter Sage
Posts: 7164
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by Yincognito »

JHB101101 wrote: June 24th, 2021, 9:39 amHowever, now they shrink correctly and keep their distance from each other proportionally, but the entire word jump 450 pixels to the left. Is this correct behavior or am I missing something.
You're doing everything correctly, per your pseudo-code, and your approach - as far as I can tell - should center things without any problem, like below:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
LeftMouseUpAction=[!ToggleMeter Help_OriginalSize][!Redraw]

---Meters---

[Help_OriginalSize]
Meter=Shape
; X=100
; Y=50
; W=230
; H=100
Shape=Path HPath | Extend SharedModifiers | Offset (60*0),0
HPath=0,0 | LineTo 0,100 | LineTo 10,100 | LineTo 10,55 | LineTo 40,55 | LineTo 40,100 | LineTo 50,100 | LineTo 50,0 | LineTo 40,0 | LineTo 40,45 | LineTo 10,45 | LineTo 10,0 | ClosePath 1
Shape2=Path EPath | Extend SharedModifiers | Offset (60*1),0
EPath=0,0 | LineTo 0,100 | LineTo 50,100 | LineTo 50,90 | LineTo 10,90 | LineTo 10,55 | LineTo 50,55 | LineTo 50,45 | LineTo 10,45 | LineTo 10,10 | LineTo 50,10 | LineTo 50,0 | ClosePath 1
Shape3=Path LPath | Extend SharedModifiers | Offset (60*2),0
LPath=0,0 | LineTo 0,100 | LineTo 50,100 | LineTo 50,90 | LineTo 10,90 | LineTo 10,0 | ClosePath 1
Shape4=Path PPath | Extend SharedModifiers | Offset (60*3),0
PPath=0,0 | LineTo 0,100 | LineTo 10,100 | LineTo 10,10 | LineTo 23,10 | ArcTo 23,45,*,*,*,*,* | LineTo 10,45 | LineTo 10,55 | LineTo 23,55 | ArcTo 23,0,*,*,*,1,* | ClosePath 1
SharedModifiers=StrokeWidth 1 | Stroke Color 255,0,0,128 | Fill Color 255,255,255,128
Shape5=Combine Shape | Union Shape2 | Union Shape3 | Union Shape4
DynamicVariables=1

[Help_Scaled]
Meter=Shape
; X=100
; Y=50
; W=230
; H=100
Shape=Path HPath | Extend SharedModifiers | Offset (60*0),0
HPath=0,0 | LineTo 0,100 | LineTo 10,100 | LineTo 10,55 | LineTo 40,55 | LineTo 40,100 | LineTo 50,100 | LineTo 50,0 | LineTo 40,0 | LineTo 40,45 | LineTo 10,45 | LineTo 10,0 | ClosePath 1
Shape2=Path EPath | Extend SharedModifiers | Offset (60*1),0
EPath=0,0 | LineTo 0,100 | LineTo 50,100 | LineTo 50,90 | LineTo 10,90 | LineTo 10,55 | LineTo 50,55 | LineTo 50,45 | LineTo 10,45 | LineTo 10,10 | LineTo 50,10 | LineTo 50,0 | ClosePath 1
Shape3=Path LPath | Extend SharedModifiers | Offset (60*2),0
LPath=0,0 | LineTo 0,100 | LineTo 50,100 | LineTo 50,90 | LineTo 10,90 | LineTo 10,0 | ClosePath 1
Shape4=Path PPath | Extend SharedModifiers | Offset (60*3),0
PPath=0,0 | LineTo 0,100 | LineTo 10,100 | LineTo 10,10 | LineTo 23,10 | ArcTo 23,45,*,*,*,*,* | LineTo 10,45 | LineTo 10,55 | LineTo 23,55 | ArcTo 23,0,*,*,*,1,* | ClosePath 1
SharedModifiers=StrokeWidth 1 | Stroke Color 255,0,0,255 | Fill Color 255,255,255,255
Shape5=Combine Shape | Union Shape2 | Union Shape3 | Union Shape4 | Scale 0.2,0.2
DynamicVariables=1
Char Shapes.jpg
Click on the skin to toggle the hidden state of the [Help_OriginalSize] meter, and see for yourself. Uncommenting the X, Y, W or H coordinates doesn't produce any unwanted movement, setting the W and H actually makes things a bit better.
JHB101101 wrote: June 24th, 2021, 11:03 amThere is no code like this anymore. I deleted it as a final act of defiance.
I'm not sure what was the problem, but that was not a wise decision. You don't overcome challenges by giving up or let your anger take over your brain. You have to stick to it till you get to the bottom of it, and sometimes pauses (so that your mind is fresh and has new and better ideas) are a good trick to finally overcome the challenge. Persistence (or insistence, if you like) is key. Sure, too much of that is detrimental as well, since it will take time from other issues, but that's another story. As always, striking the right balance between persistence and knowing when to let it go and mind something else is the best option.

P.S. And yes, the starting and ending points of the inner and outer arcs in the P letter are specifically set so that those arcs are perfect half-circles (thus the * default values used for the rest of the arc parameters). Original letters are 50 x 100 px each, the "weight" of the letter is 10 px and the path direction is LeftTop to LeftBottom to RightBottom to RightTop for each letter, if anyone is interested.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by CodeCode »

Yincognito wrote: June 24th, 2021, 10:43 pm I'm not sure what was the problem, but that was not a wise decision. You don't overcome challenges by giving up or let your anger take over your brain. You have to stick to it till you get to the bottom of it, and sometimes pauses (so that your mind is fresh and has new and better ideas) are a good trick to finally overcome the challenge. Persistence (or insistence, if you like) is key. Sure, too much of that is detrimental as well, since it will take time from other issues, but that's another story. As always, striking the right balance between persistence and knowing when to let it go and mind something else is the best option.

P.S. And yes, the starting and ending points of the inner and outer arcs in the P letter are specifically set so that those arcs are perfect half-circles (thus the * default values used for the rest of the arc parameters). Original letters are 50 x 100 px each, the "weight" of the letter is 10 px and the path direction is LeftTop to LeftBottom to RightBottom to RightTop for each letter, if anyone is interested.
Perhaps the OP can recover their code from the recycle bin, when they have more time, as that seemed to be the issue more than lack of progress.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by death.crafter »

CodeCode wrote: June 25th, 2021, 3:05 am Perhaps the OP can recover their code from the recycle bin, when they have more time, as that seemed to be the issue more than lack of progress.
How can you retrieve deleted text from recycle bin lol.
from the Realm of Death
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by CodeCode »

death.crafter wrote: June 25th, 2021, 4:47 am How can you retrieve deleted text from recycle bin lol.
The files the code were contained in, ofc. Deleting code seems moot since an empty file would still remain.

Also, as a side note - sublimetext3 has an undo cache even if the file was closed then reopened, so those who end up in a dead end can still undo. However I have tested it and did not ascertain what the number of ctrl-z's there are but its likely around 15 or so.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7164
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by Yincognito »

CodeCode wrote: June 25th, 2021, 3:05 am Perhaps the OP can recover their code from the recycle bin, when they have more time, as that seemed to be the issue more than lack of progress.
Well, he said he "deleted it as a final act of defiance", hence my reply.

Yeah, if he deleted the files and he uses Recycle Bin, he can recover them for sure. I don't use the bin, but I can recover stuff using more powerful software (unless there has been physical hard drive writing in those sectors afterwards), so it certainly is possible. That being said, from what he wrote here, his code is based on the same principle as mine (which is centered, no problem), so this may help him start fresh with a code that behaves as expected. He can, of course, change the paths and all that, but the idea is that here the scaled shape is already centered.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
JHB101101
Posts: 10
Joined: June 24th, 2021, 8:58 am

Re: Shape Meter - Scaling not centered/offset correctly for combined shapes.

Post by JHB101101 »

Hi

@CodeCode: Thanks for the suggestion, but I just deleted the text. My bad.

@Yincognito: Your code looks a lot like mine accept I did something like this for right aligned text on a full screen skin (this is not pseudo code but I did type it up in here only, so it may need some inspection):

Code: Select all


Topmenu_Title_Text="AAA"

[Topmenu.Frame]
	DynamicVariables=1
	SharedModifiers=StrokeWidth 0|Fill Color 0,0,0
	Shape=Path TitleGlyph1|Offset ([&[#CURRENTSECTION]:W]-100-([&Font.[&Title.Character1].Advance]+[&Font.[&Title.Character2].Advance]+[&Font.[&Title.Character3].Advance])),0|Extend SharedModifiers
	Shape2=Path TitleGlyph2|Offset ([&[#CURRENTSECTION]:W]-100-([&Font.[&Title.Character2].Advance]+[&Font.[&Title.Character3].Advance])),0|Extend SharedModifiers
	Shape3=Path TitleGlyph3|Offset ([&[#CURRENTSECTION]:W]-100-([&Font.[&Title.Character3].Advance])),0|Extend SharedModifiers

[TopmenuFrame]
	Meter=Shape
	MeterStyle=Topmenu.Frame
	DynamicVariables=1
	X=0
	Y=0
	W=[#WORKAREAWIDTH]
	H=[#WORKAREAHEIGHT]

[Font.A.Glyph]
	Measure=String
	String="0,16|ArcTo 16,0,16|LineTo 26,0|ArcTo 42,16,16|LineTo 42,100|LineTo 26,100|LineTo 26,58|LineTo 16,58|LineTo 16,42|LineTo 26,42|LineTo 26,21|ArcTo 16,21,5,*,*,1|LineTo 16,100|LineTo 0,100|ClosePath 1"
[Font.A.Advance]
	Measure=String
	String=47

[Title.Characters]
	Measure=String
	DynamicVariables=1
	RegExpSubstitute=1
	String=[#Topmenu_Title_Text]
	Substitute="[^ a-zA-Z0-9]":""
	OnUpdateAction=[!UpdateMeasure Title.Character1][!UpdateMeasure Title.Character2][!UpdateMeasure Title.Character3][!UpdateMeter TopmenuFrame][!Redraw]

[Title.Character1]
	Measure=String
	DynamicVariables=1
	RegExpSubstitute=1
	IfMatchMode=1
	String=[&Title.Characters]
	Substitute="^(.).*$":"\1"," ":"Space","":"None"

[Title.Character2]
	Measure=String
	Group=TitleCharacters
	DynamicVariables=1
	RegExpSubstitute=1
	IfMatchMode=1
	String=[&Title.Characters]
	Substitute="^.{1}(.).*$":"\1","[&Title.Characters]":""," ":"Space","":"None"

[Title.Character3]
	Measure=String
	DynamicVariables=1
	RegExpSubstitute=1
	IfMatchMode=1
	String=[&Title.Characters]
	Substitute="^.{2}(.).*$":"\1","[&Title.Characters]":""," ":"Space","":"None"

Note: The reason I add the advances by adding them together at the top is because of variable width characters.

Kind Regards

Jayson