Drawing Graphics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    Drawing Graphics

    This article contains the basic syntax to draw graphics of various shapes and sizes in Visual Basic 6.0. Different types of geometrical shapes (rectangle, square, circle, arc, ellipse etc.) can be drawn on the form by using the following syntax.

    Basic syntax (for line, rectangle, square)
    =============== ==============
    [CODE=vb]OBJECT.LINE [STEP] (X1, Y1) [STEP] -(X2, Y2), [COLOR], [B[F]][/CODE]

    STEP -- KEYWORD SPECIFYING THAT THE STARTING POINT COORDINATES ARE RELATIVE TO THE CURRENT GRAPHICS POSITION GIVEN BY THE "CURRENTX" & "CURRRENTY" PROPERTIES.

    X1, Y1 -- SINGLE VALUES INDICATING THE COORDINATES OF THE STARTING POINT FOR THE LINE OR RECTANGLE. IF OMITTED THE LINE BEGINS AT THE POSITION INDICATED BY CURRENTX AND CURRENTY.

    STEP -- KEYWORD SPECIFYING THAT THE END POINT COORDINATES ARE RELATIVE TO THE LINE STARTING POINT.

    X2, Y2--SINGLE VALUES INDICATING THE COORDINATES OF THE END POINT FOR LINE BEING DRAWN.

    COLOR -- INDICATES THE COLOR OF THE LINE. CAN USE RGB() OR QBCOLOR() FUNCTIONS, OR NAMED COLOR CONSTANTS SUCH AS vbGreen.
    IF OMITTED, THE CURRENT VALUE OF THE FORECOLOR PROPERTY IS USED.

    B -- ("BOX") - IF INCLUDED, CAUSES A BOX TO BE DRAWN USING THE COORDINATES TO SPECIFY OPPOSITE CORNERS OF THE BOX.

    F -- ("FILL") - CAN ONLY BE USED WITH "B" OPTION. IF USED, "F" SPECIFIES THAT THE BOX IS TO BE FILLED WITH SAME COLOR USED TO DRAW THE BOX. IF B IS NOT FILLED WITH F(F option is not used), THE BOX IS FILLED WITH CURRENT "FILLCOLOR" AND "FILLSTYLE" . DEFAULT VALUE FOR FILLSTYLE IS TRANSPARENT.

    [CODE=vb]Me.Line Step(7000, 5000)-Step(2000, 4000), QBColor(5), BF[/CODE]

    Basic Syntax (for elliptical shapes - arc, circle, ellipse)
    =============== =============== =============== ===
    [CODE=vb]OBJECT.CIRCLE [STEP] (X, Y), RADIUS, [COLOR, START, END, ASPECT][/CODE]

    STEP -- SPECIFIES THAT THE CENTER OF THE CIRCLE OR ELLIPSE IS RELATIVE TO THE CURRENT COORDINATES GIVEN BY THE "CURRENTX" & "CURRENTY" PROPERTIES.

    X, Y -- COORDINATES INDICATING THE CENTER POINT OF THE CIRCLE OR ELLIPSE.

    RADIUS -- INDICATES THE RADIUS OF THE CIRCLE OR ELLIPSE.

    START, END -- WHEN AN ARC (A PARTIAL CIRCLE) IS TO BE DRAWN, START AND END SPECIFY THE BEGINNING AND THE ENDING POSITION OF THE ARC.
    THE RANGE FOR BOTH IS -2Pi RADIAN TO 2Pi RADIAN. THE DEFAULT VALUE FOR START IS 0 RADIANS AND THAT FOR END IS 2Pi RADIANS. IN OTHER WORDS, THE DEFAULT IS TO DRAW A COMPLETE CIRCLE OR ELLIPSE.

    ASPECT -- INDICATES THE ASPECT RATIO OF THE CIRCLE/ELLIPSE. DEFAULT IS 1.0, WHICH YIELDS A PERFECT CIRCLE ON ANY SCREEN.

    [CODE=vb]Me.Circle (ScaleWidth / 2, ScaleHeight / 2), Switch(ScaleWid th >= ScaleHeight, ScaleHeight / 2, ScaleWidth < ScaleHeight, ScaleWidth / 2), vbRed, 0, 3, 0.8[/CODE]
    Hope it helps the user to draw any basic objects on form or picturebox.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    I've just been doing a bit of editing, to correct a bit of the English and so on. I'm concerned about the text for the BF options on Line. You seem to be contradicting yourself. First you say the box will be filled with "the same color used to draw the box", then you say it's FillColor.

    Which is it? (I can't remember.)

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Originally posted by Killer42
      I've just been doing a bit of editing, to correct a bit of the English and so on. I'm concerned about the text for the BF options on Line. You seem to be contradicting yourself. First you say the box will be filled with "the same color used to draw the box", then you say it's FillColor.

      Which is it? (I can't remember.)
      Thanx for pointing to the error.
      Actually this is a TYPO . I missed the NOT by mistake.
      Any more suggestions are most welcome.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by debasisdas
        Thanx for pointing to the error.
        Actually this is a TYPO . I missed the NOT by mistake.
        Any more suggestions are most welcome.
        Ah. Well, I've learned something there. I didn't know the relationship between the F option and the Fillcolor property. Have drawn boxes plenty of times, and filled them, but it was always trial and error.

        Comment

        • lavanya2284
          New Member
          • Jan 2008
          • 3

          #5
          Thanks a lot .. i got the required output.

          Comment

          Working...