Results 1 to 4 of 4

Thread: VB6 Shape UserControl,API Draw drawing rounded rectangles

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,042

    VB6 Shape UserControl,API Draw drawing rounded rectangles

    Using GDIPLUS, add multiple point array data, or add multiple lines (such as straight lines, arcs, Seebel curves, etc.)
    You can set the color of the border line path, fill the color, and later use images to draw texture tiles..

    I want to use this method to draw any shape, such as drawing a triangle or other shape. It can achieve arbitrary enlargement and drawing.
    Just need to enlarge the corresponding coordinate data to the specified multiple.
    The function is not yet completed, mainly a design concept, and everyone can expand more gameplay on this basis.

    Now draw a polygon based on multiple input points, but this feature has not been successfully tested yet.
    how to fix this code?

    Code:
        GdipCreatePath 2, path '  
        
     
        points(0).X = 50
        points(0).Y = 50
        points(1).X = 100
        points(1).Y = 100
        points(2).X = 150
        points(2).Y = 50
        points(3).X = 200
        points(3).Y = 100
        
     
        GdipAddPathPolygonI path, VarPtr(points(0)), 4     
        GdipCreatePen1 RGB(255, 0, 0), 4, 2, pen  
        GdipDrawPath graphics, pen, path
    ===========
    Code:
    GdipAddPathLine path, x + RoundSize, y, x + width - RoundSize, y
    
    GdipAddPathArcI path, x + width - RoundSize * 2, y, RoundSize * 2, RoundSize * 2, 270, 90
    DrawStart graphics, SBorderWidth, vbRed, vbYellow
    AddLine 50, 50, 350, 50
    AddLine 350, 50, 350, 250
    'AddLine 350, 250, 50, 250
    'AddLine 50, 250, 50, 50

    AddLine 350, 250, 50, 50
    DrawIt

    Name:  ShapeList.jpg
Views: 99
Size:  23.1 KB
    Name:  shape_byapi_demo.jpg
Views: 129
Size:  17.2 KB

    download test:
    Project_shape_byapi_demo.zip
    Last edited by xiaoyao; Feb 8th, 2025 at 04:27 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,042

    Re: VB6 Shape UserControl,API Draw drawing rounded rectangles


  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,042

    Re: VB6 Shape UserControl,API Draw drawing rounded rectangles

    equilateral triangle

    Code:
     DrawStart graphics, SBorderWidth, vbRed, vbYellow
        Dim Point(2) As PointF
        With Point(0)
            .x = 150
            .y = 0
        End With
        With Point(1)
            .x = 300
            .y = 250
        End With
        With Point(2)
            .x = 0
            .y = 250
        End With
        AddLineList Point()
        DrawIt
    
    
    Sub AddLineList(PointArr() As PointF)
    'more than 3 porints
        Dim i As Long
        For i = 1 To UBound(PointArr)
            GdipAddPathLine path, PointArr(i - 1).x, PointArr(i - 1).y, PointArr(i).x, PointArr(i).y
        Next
    End Sub
    Attached Images Attached Images  

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,042

    Re: VB6 Shape UserControl,API Draw drawing rounded rectangles

    Shape enlargement and deformation allow for the specification of the starting position and the size of the drawing range, resulting in a vector like effect that can be widened or narrowed while maintaining image clarity.

    Code:
        DrawStart graphics, SBorderWidth, vbRed, vbYellow
            AddPointList Point()
        DrawIt
        
        DrawStart graphics, SBorderWidth, vbRed, vbYellow
         AddPointListPlus Point(), 400, 500, 300
        DrawIt
        
        DrawStart graphics, SBorderWidth, vbRed, vbYellow
        AddPointListPlus Point(), 500, 250, 500
    
        DrawIt
    Code:
    Sub AddPointListPlus(PointArr() As PointF, WIDTH As Long, Height As Long, Optional Left As Long, Optional Top As Long)
    'more than 3 porints
        Dim i As Long, MaxWIDTH As Long, MaxHeight As Long
        For i = 0 To UBound(PointArr)
             If PointArr(i).x > MaxWIDTH Then MaxWIDTH = PointArr(i).x
             If PointArr(i).y > MaxHeight Then MaxHeight = PointArr(i).y
        Next
        Dim BLX As Single, BlY As Single
        BLX = WIDTH / MaxWIDTH
        BlY = Height / MaxHeight
        
        
         For i = 1 To UBound(PointArr)
            GdipAddPathLine path, Left + (PointArr(i - 1).x * BLX), Top + PointArr(i - 1).y * BlY, Left + PointArr(i).x * BLX, Top + PointArr(i).y * BlY
        Next
    End Sub
    Name:  Shape enlargement and deformation.jpg
Views: 77
Size:  14.0 KB

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