PDA

Click to See Complete Forum and Search --> : Scaled geometry in PictureBox


gxpark
Apr 26th, 2001, 02:00 PM
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?
:confused: :confused: :confused:

Zaei
Apr 26th, 2001, 02:05 PM
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.

gxpark
Apr 26th, 2001, 02:24 PM
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...

Zaei
Apr 26th, 2001, 02:34 PM
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.

gxpark
Apr 26th, 2001, 02:57 PM
But how do I divide FigureWid / ScaleWidth? What do you mean by ScaleWidth? the PictureBox ScaleWidth?