Resolved Control.Scale() and Control.UnScale()

diogenes

Member
Joined
Dec 23, 2020
Messages
6
Programming Experience
3-5
I have a panel where I draw some squares, simulating street objects on a map. I use Scale (float f1, float f2) to enlarge the panel and the paintings. I have a ComboBox with 50%, 75%, 100%, 125%, 150%, and 200% items. The user can go from 50% to 200%, and return to 50%, if necessary. I need to know how to do this, if Scale () doesn't allow me to return to the previous position.
 
Solution
If you keep track of current scale you can revert to 100% by 1/current, and multiply that by new value to scale just once. Examples:
current scale is 25% and new scale is 125%: 1/0.25*1.25= factor 5
current scale is 200% and new scale is 25%: 1/2*0.25= factor 0.125
What have you tried so far? I would assume to scale to 50% you pass in 0.5, and to scale to 200% you pass in 2.0. Presumably passing in 0.5 will scale you to 50% again.
 
What have you tried so far? I would assume to scale to 50% you pass in 0.5, and to scale to 200% you pass in 2.0. Presumably passing in 0.5 will scale you to 50% again.

That's right. But the problem is that when I use the 50% (0.5) scale, it assumes that scale as 100%. So much so that if I use the Scale (0.5,0.5) again it will be 0.25 of the original size. I need that when I use 50% it should be the original size, and when I put 200% it should be the original size. This is to make a zoom effect, in the drawings made on the panel.
 
If you keep track of current scale you can revert to 100% by 1/current, and multiply that by new value to scale just once. Examples:
current scale is 25% and new scale is 125%: 1/0.25*1.25= factor 5
current scale is 200% and new scale is 25%: 1/2*0.25= factor 0.125
 
Solution
If you keep track of current scale you can revert to 100% by 1/current, and multiply that by new value to scale just once. Examples:
current scale is 25% and new scale is 125%: 1/0.25*1.25= factor 5
current scale is 200% and new scale is 25%: 1/2*0.25= factor 0.125

It stayed the way I wanted, wow. It was fantastic. It really helped. I am very happy. Really. Thank you very much
 
Back
Top Bottom