Results 1 to 3 of 3

Thread: simple question on rectangles

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Posts
    28

    simple question on rectangles

    I have a Rectangle with R.X,R.Y,R.Width,R.Height .
    My question If it always adds the R.Width and R.Height in only one direction.How can I get Four rectangles that have the same Dimensions with and the Same start point ? What I am looking for is a PLUS sign made of the 4 rectangles....so How can this be done using the same R.X and R.Y ? It obviously doesn't let me put negative values for R.Width and R.Height...
    Thank you.
    Regards --
    Vujjeni

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    You could multiply a value by -1... Whoops I can't read, you tried that. Hmm.

  3. #3
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Okay how's this:
    Code:
            Dim R As New Rectangle()
            R.X = 140
            R.Y = 70
            R.Height = 20
            R.Width = 34
    
            Dim myPen As New Pen(Color.Black, 3)
            Dim g As Graphics
            g = Me.CreateGraphics
    
            'Draw rect 1
            g.DrawRectangle(myPen, R.X, R.Y, R.Width, R.Height)
    
            'Draw rect 2
            g.DrawRectangle(myPen, R.X - R.Width, R.Y, R.Width, R.Height)
    
            'Draw rect 3
            g.DrawRectangle(myPen, R.X, R.Y - R.Height, R.Width, R.Height)
    
            'Draw rect 4
            g.DrawRectangle(myPen, R.X - R.Width, R.Y - R.Height, R.Width, R.Height)
    For rect 1 I could have used the rect structure I defined but I decided to use the same overload as the other three. Does it make sense why this works?

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