Results 1 to 34 of 34

Thread: Simple Graphics problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Unhappy Simple Graphics problem

    Can some one help me with this. on a form I have placed two rounded rectangles Shape1 and Shape2 and 2 lines Line1 and Line2. The two rectangles will allways be side by side and aligned by top. I want the two lines to connect the rectangles top and bottom to produce a simple cross section display of a tube, the dimensions of which vary by varying the rectangles sizes (they are always both the same size)

    The problem I have is that the top line <Line1> always connects perfectley but the bottom line <Line2> will not always align with the bottom of the two rectangles, and instead positions a fraction lower. the code I used to position the lines is this

    Code:
    Line1.Y1 = Shape2.Top
    Line1.Y2 = Shape2.Top
    
    Line1.X1 = Shape1.Left + (Shape1.Width / 2)
    Line1.X2 = Shape3.Left + (Shape2.Width / 2)
    
    Line2.Y1 = Line1.Y1 + Shape2.Height ' this is the problem
    Line2.Y2 = Line1.Y1 + Shape2.Height 
    
    Line2.X1 = Shape1.Left + (Shape1.Width / 2)
    Line2.X2 = Shape3.Left + (Shape2.Width / 2)
    The problem does not always happen, sometimes it gets it smack on, but it depends on the height of Shape2. What am I doing wrong?

    Can anyone help me here as I am starting to go a bit loopy!!

    Many thanks
    Ray

  2. #2
    Stiletto
    Guest
    But why floodin?!
    No1 will answer you this way..

  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    alright delete your posts!
    I don't think anyone will answer your questions if you act like that If you look at this forum you can see that most people got their questions answered fast and without any spamming...

    I would hurry up deleting those posts if you expect any answers.
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    it's not his falt, the server is playing up, been happening a bit all over the forums.
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    I'm Sorry, I had no idea!!

    Sorry folks!!

    I had no idea all my attempts ended up on the board, Ianpbaker is right, I had the devils only job trying to get it to accept the post, and when it did I thought all the other attempts were just lost.

    Please accept my apologies, I'll keep an eye out if it happens again.

    How do you delete posts!! (I'm a bit new at this)

    Ray

  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Normally you'd view your post, click the 'edit' button, then near the top, tick the checkbox on the left, then click delete, on the left.

    But as your posts are a bit wierd, only the admin can do this, as it didn't register your post.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Thanks...what now!!?

    Thanks SLH

    I can only see the one message, so what do I do now?

    (I wish I'd never started this!!! ))

    Ray

  8. #8
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I don't think there's anything you can do
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  9. #9
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276

    Re: Simple Graphics problem

    Originally posted by Ray.T

    Can anyone help me here as I am starting to go a bit loopy!!

    Many thanks
    Ray
    You sure butchered the forum there pal!

    Oh well, not your fault!

    Anyway, have you got the scale mode of the form you're working on set to some custom scale, or is it set to pixels or twips? I always work in pixels as twips tend to do strange things to my applications.

    See if that helps...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  10. #10
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I'm not sure exactly what you want, so here a bit that may help.

    VB Code:
    1. 'The code below gets each corner of a shape.
    2.  
    3. TopLeftX = Shape.Left
    4. TopLeftY = Shape.Top
    5.  
    6. TopRightX = Shape.Left + Shape.Width
    7. TopRightY = Shape.Top
    8.  
    9. BottomLeftX = Shape.Left
    10. BottomLeftY = Shape.Top + Shape.Height
    11.  
    12. BottomRightX = Shape.Left + Shape.Width
    13. BottomRightY = Shape.Top + Shape.Height
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Thanks Chaps

    Thanks Arbiter & SLH

    I'll give these suggestions a go and let you know how I got on

    Thanks for your time guys t'is much appreciated!!

    Once again sorry for making a mess of the place!!

    Ray

  12. #12
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Don't mention it.

    There's no need to apologize, it wasn't your fault.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Pixels makes it worse!

    Arbiter

    I tried to set the forms scalemode to pixels but this just made it worst!!

    Any ideas?

    SLH's solution is tricky because these are rounded rectangles. Maybe I should sent a screen capture to clarify things for you.

    Best

    Ray

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    screen shot to clarify things a bit

    Here is a screen shot of the trial form to clarify things abit.

    The darker shapes dimensions are taken from the left hand set of text boxes and the cyan coloured from the right. As I vary the bottom right hand text box dimensions , Line2 does not always align like Line1 at the top (which incidentley aligns perfectley every time)

    Is it because the top is a control attribute, where as the bottom is always a reference?

    The two rectangles the line references to are the two cyan coloured ones (outer rectangles)

    Can any one help?!

    Ray

    P.S the file has been scanned for viruses using Norton Antivirus 2001 with definitions dated 10/05/2002
    Attached Images Attached Images  

  15. #15
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    It would be better if you could post your code, but I still reckon it's to do with those evil twips!

    I'm guessing the problem is down to something farcical like...

    Each pixel is about 15 twips and the screen can only display pixels so twips are rounded (sort of). Ergo, if something is 14 twips in then it is 0 pixels in. If it's 15 twips in, it's 1 pixel in.

    try the stuff below which I've just invented now off the top of my head.

    Code:
    Line2.Y1 = (int((Line1.Y1 + Shape2.Height)/screen.twipsperpixely)*screen.twipsperpixely)+1
    Line2.y2=line2.y1
    If that fails (which is quite likely) then please post your project for us to have a tinker.
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Unhappy Tinker at will!!

    Thanks Arbiter

    OK here it is (its been scanned as before for viruses). When you run it, increment the bottom right textbox by one each time until the line goes wrong (around 46 in the textbox)

    Thinking about it I had to fiddle with the measurements, as you will see, to get the grey rectangles to line up with the circles (as you will see, its suposed to be a simple 2d cross sectional diagram) by adding and subtracting 20 twips (is this the process of twip rounding, as it makes sense what you said in your last post) and doing this to the line as well. Surely though you should be able to get everything to line up perfectley without mucking around.

    See what you can do, and once again thank you very much for your time!!

    Best
    Ray
    Attached Files Attached Files

  17. #17
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    I've had a quick look and you have a really bizarre problem there.

    As I'm not sure what it's supposed to be doing it's proving a little tricky to debug.

    It's not a large thing, so I'd recommend you recode it from the ground up and use pixels instead of twips. The screens smallest visible element is a pixel, so just forget twips.

    I'll carry on looking at this though but I do have some real work to do as well.....
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Unhappy Can anybody else help me!

    Thanks Arbiter

    It does seem strange doesn't it, I thought maybe when you tried it the problem would not happen, and it would all be down to my graphics card or something. Surely though if you set the forms ScaleMode to pixels (I'm not sure if I'm qualified in VB enough to use the word 'surely') then this would be the same as recoding in pixels. To be honest I dont really know any other way of getting the diagram drawn, other than the Circle Method, and Shape controls. I know you can use RounRectangle API calls but then I wouldn't know how to fill in the rectangles with different shades.

    I will keep badgering at it, and thanks very much for the time and patience you have given me Arbiter, it is well appreciated.

    All the best
    Ray

  19. #19
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    I've not given up on it yet...

    And simply setting the scalemode (although required) is not all there is to it. You have some values of 2700 and you're incrementing values by 20 for some reason. These would need to be adjusted as well.
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Unhappy I know what you mean

    Arbiter

    Yes I tried just changing the ScaleMode to pixels when you first flagged up twips being problematic. Obviously this shifted the rectangles of the form completely (the Circles are based on a ratio of the froms width so they stay OK) so I adjusted the distance from the circles Y position to ba about the same distance in twips, but still the problem was there. The 20 twip adjustment was because, as this is supposed to be a 2D "cross section" drawing of the part (viewed from the top, Circles and view from the side, rectangles) the grey rectangles width should be the same length as the grey circles width (I think Ive explained that right!!) but it originaly came up just short if you state the width to be circle2 radius - circle3 radius, which is most probably a function of the original problem. If you set the rectangles Ypos to be the same as the circles, you can see this when you remove the +20 bit. At least the rectangle width, once you have added the 20 twips, hits the grey circle dimensions each time no matter what dimensions are entered into the text boxes.

    I think I've just blown my cerebral cortex!!!
    I'm off to have a lie down in a dark and quiet room!!!!!!

    Cheers mate

    Ray

  21. #21
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Sod it.

    Forget the VB shapes, they're complete crap!

    Draw them onto the form directly and get rid of those crappy controls. You can draw the boxes using the line method with the 'B' wotsit. (look up line for more info). It won't do them as rounded boxes, but rounded boxes look poo anyway...

    And do it in pixels, you can't go wrong then!

    If you get stuck replacing the shapes with drawing commands then give me a shout...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Talking Like your style!!

    Thats the spirit!!

    I'll give it ago, the only thing I couldn't seem to find any info on using line (or better still the RoundRectangle API whatsit) is how to fill them in as all you seem to get is that it will be filled in with the object that its drawn on's fill style, but how do you get two diferent fills????

    Any one know???????

    Cheers Arbiter

    Ray

  23. #23
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    change the form's fillstyle in-between
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  24. #24

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Talking Thanks SLH

    Thanks SLH

    I'll give that a go and let you all know how I got on (although I can probably guess the outcome of that one!!!)

    Cheers y'all

    P.S did you get a chance to have a look at the prog SLH?

  25. #25
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Nope, but i'll take a look now
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  26. #26
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Not too sure if this is what you want

    In the command3 code, find this

    VB Code:
    1. Line2.Y1 = Line1.Y1 + Shape2.Height - 20
    2. Line2.Y2 = Line1.Y1 + Shape2.Height - 20

    and replace with this

    VB Code:
    1. Line2.Y1 = Shape2.Top + Shape2.Height - 20
    2. Line2.Y2 = Shape2.Top + Shape2.Height - 20
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  27. #27
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Tried that code already SLH during my many tinkerings and it didn't work for me. It's quite a bizarre problem.

    Ray,

    As SLH said, to use different fills:

    set the fill style/colour
    draw the first rectangle
    change the fill stlye/colour
    draw the second rectangle.

    Easy
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  28. #28

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Talking Filling in draw objects

    Thanks Arbiter & SLH

    Yes I realised that I used this filling method to do the circles (bless em, they behaved so well!!!) but it was such a cut and try thing that I forgot about as soon as it worked!!

    Cheers both
    Ray

  29. #29
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    any time
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  30. #30
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    You got it all working then?

    PS - one of my colleagues saw me tinkering with it and wants to know what the hell it does...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Talking No Sir!!!

    No you have got to be joking Arbiter, I wish I had!!!

    The program is not just to make pretty shapes. Its hopefully going to be part of an engineering program, which calculates finished sizes of a toroidal (ring) object. The output represents a cross sectional drawing of the finished articles dimensions. The dark grey area is the toroidal core, and the cyan parts are the buildup of material on that core.

    Hope this clarifies things a bit!!!

    Ray

  32. #32
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Oh yeah, crystal!
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  33. #33

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Cheshire, England
    Posts
    115

    Talking Ha Ha!!

    Arbiter

    I know it does sound a bit weird don't it!!!

    Cheers
    Ray )

  34. #34
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: No Sir!!!

    Originally posted by Ray.T
    No you have got to be joking Arbiter, I wish I had!!!
    If you want more help, just ask
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


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