|
-
Apr 26th, 2001, 02:00 PM
#1
Thread Starter
Addicted Member
Scaled geometry in PictureBox
Hello,
I'm having big trouble with my lil' app.
One of it's modules reads formulas and plotting instructions from a XML file, and then plots the instructions on a PictureBox, and shows the result of the formulas.
The problem is that I can't plot proportionally. Let me put an example.
I have a PB measuring 561x290, and the instructions are to draw a trapezoid, measuring 100x40x70 (B, b, h).
So, I set the scaling properties of the PB to the following:
PB.ScaleWidth = (PB.Width / PB.Height) * h
PB.ScaleHeight = h
This does work, it draws the trapezoid ok, and proportionally. But if I change the measures to 100x40x10, the figure spans off the PB, because ScaleWidth=17.79, and since B=100...
The problem of course, is not with the plotting instructions, because if instead of rescaling the PB, I resize it to match the limits of the figure, the figure looks ok.
I've tested many options and variants, and I'm going nuts now...
Anyone can help me?
-
Apr 26th, 2001, 02:05 PM
#2
Scale both ScaleWidth and ScaleHeight by some value. For example, 100 * (1 / 2), 17.79 * (1 / 2). The figure will still be proportional, but itll be smaller.
Z.
-
Apr 26th, 2001, 02:24 PM
#3
Thread Starter
Addicted Member
Hey, thanks for the quick reply.
I've thought of that too, but how do I calculate "some value"? THAT'S the real problem, since I can have any figure with any size and any PictureBox, with any size too...
-
Apr 26th, 2001, 02:34 PM
#4
Thats pretty easy. If The width is greater than the height, we want to use that. So, FigureWid / ScaleWidth = somevalue. Them its just
a matter of ScaleWidth * somevalue, ScaleHeight * somevalue. If height is greater than width use height / scaleheight.
Z.
-
Apr 26th, 2001, 02:57 PM
#5
Thread Starter
Addicted Member
But how do I divide FigureWid / ScaleWidth? What do you mean by ScaleWidth? the PictureBox ScaleWidth?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|