|
-
Jul 11th, 2000, 11:01 AM
#1
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?
-
Jul 11th, 2000, 11:17 AM
#2
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
-
Jul 11th, 2000, 01:40 PM
#3
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 ??
-
Jul 11th, 2000, 04:59 PM
#4
what is you ScaleMode-setting? asuming it is twips, try changing it to pixels and see if that helps.
best regards
Sascha
-
Jul 11th, 2000, 05:13 PM
#5
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.
-
Jul 11th, 2000, 05:30 PM
#6
transcendental analytic
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.
-
Jul 11th, 2000, 06:06 PM
#7
Hyperactive Member
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
-
Jul 12th, 2000, 05:10 PM
#8
transcendental analytic
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.
-
Jul 12th, 2000, 05:56 PM
#9
Hyperactive Member
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
-
Jul 13th, 2000, 01:23 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|