Results 1 to 10 of 10

Thread: Correct positioning of figures/shapes

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I'm drawing lines and shapes in a picturebox. Why can't I position those exactly on a desired spot.
    For example: I want to draw a circle and a vertical line just over the middle of the circle. I'm using the correct values relative to each other (Line.X = Circle.Left+0.5*Circle.width) to position both figures, but the result is a line which is just a bit off the middle, why?
    By the way, I'm using a User Scalemode, is that the problem?

  2. #2
    Guest
    You should position them relative to the PictureBox. Also, remember to subtract half the width and height so it's even on both sides.

    Code:
    'Position the Circle
    MyCircle.Move (Picture1.ScaleWidth / 2) - (MyCircle.Width / 2), (Picture1.ScaleHeight / 2) - (MyCircle.Width / 2)
    
    'Position the Line
    With MyLine
        .X1 = Picture1.ScaleWidth / 2
        .X2 = Picture1.ScaleWidth / 2
        .Y1 = 0
        .Y2 = Picture1.ScaleHeight
    End With

  3. #3

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Thanks Meg'
    but I'm using all the correct(hopefully(:-)) values, the problem comes when I'm using small values of scale For example a circle of with a radius of 1 (width and height =2) is not printed correctly around a cross at the position X=circle.left+circle.width/2 and y=circle.top-Circle.height/2.
    What kind of variables are X and Y? Integer, Single, Long ??

  4. #4
    Guest
    what is you ScaleMode-setting? asuming it is twips, try changing it to pixels and see if that helps.

    best regards

    Sascha

  5. #5

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I'm using the "User ScaleMode", and I need it.
    I'm working on a chart (Lat/Long conversion) and on a measurement tool with changing scales ( Scalewidth from 5 to 1000 changed during runtime).
    So I would like to stay with that, otherwise the recalculations will drive me nuts.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    All coordinates in both circle and line are single.
    It's a floating point which could cause malcalculations with some extreme values, but i wouldn't suggest that's the possible problem
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    lines and shapes

    I have looked into this quickly just now, and I can tell that if you make a cross inside the circle instead it pinpoints the centre prefectly. If you make a "plus" is it out by a small % EVERY time no matter how big or small the circle is.

    I would hazard a guess and say that this is due to something very basic we are missing OR something very complex about pixel density and the fact that a vertical line has to consist of pixels directly above/below each other whereas a diagonal line "skips" pixles givin the illusion of being accurate.

    Both of my methods pinpoint the same place mathematically, however they are definitely rendered differently.

    Can you chance to a X in your circle without major problems?

    Regards
    Paul Lewis

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm sure youre right Paul, and I think the problem lays in th shape control, so I guess it wouldn't be easier but a lot more accurate with drawing lines and shapes directly on the form, and also it's not consuming any resoruces at all
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    lines/shapes/controls

    I was actually using lines and circles rather than shapes.

    I also tried shapes and these were no better. On my monitor, vertical lines always appear thicker than horizontal or diagonal lines. I am sure a techie will know why

    Cheers
    Paul Lewis



  10. #10

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Thank's
    I think the problem is as Paul has discribed it, since each line must have a dimension it can't be "exactly" on the spot.
    For me that's OK, 'cause it does not affect my application in general. It just looks a bit strange to see a cross in a circle that should be in the middle and it isn't if your in the wrong scale (the cross has a size independant of scale, the circle goes with the scale). Try it with a cross that fills a small circle.
    Anyway thanks, I continue on other problemspot of my app.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

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