Results 1 to 5 of 5

Thread: Scaled geometry in PictureBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242

    Question 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?

  2. #2
    Zaei
    Guest
    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    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...

  4. #4
    Zaei
    Guest
    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    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
  •  



Click Here to Expand Forum to Full Width