[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1096
  • Last Modified:

How to draw an arc on picturebox

hi all,

          i have one query.

          i have a picturebox and i want to draw an arc on it.

          i have the value of center point , two end points of an arc and radius.

          can anyone help me out?

vishal patel
2 Solutions
Picture1.Circle (500, 500), 500, , -0.01, -1.57, 1.5

(x,y),radius,color,start,end,aspect ratio
As Marv-in has suggested, you can use Picture1.Circle, if you want to create a smooth arc, given certain parameters.

But, be aware that the 'start' and 'end' points are not co-ordinates.  Instead they are angles in radians.  Additionally, the aspect ratio is a radius multiplier.  You should look at the following program for an idea of the logic behind an ellipse:

    Private Sub Command1_Click()
        Const PI As Single = 3.141582
        x = Picture1.ScaleWidth / 2         'x = x-coord of centre
        y = Picture1.ScaleHeight / 2        'y = y-coord of centre
        r = 1000                            'r = radius
        s = PI / 4                          's = start angle
        e = PI / 2                          'e = end angle
        a = 1.5                             'a = aspect ratio
        If a < 1 Then
            w = r                           'w = actual ellipse width
            h = r * a                       'h = actual ellipse height
            h = r
            w = r / a
        End If
        sx = x + (Cos(s) * w)               'sx = actual x-coord of start of arc
        sy = y - (Sin(s) * h)               'sy = actual y-coord of start of arc
        ex = x + (Cos(e) * w)               'ex = actual x-coord of end of arc
        ey = y - (Sin(e) * h)               'ey = actual y-coord of end of arc
        Picture1.Line (x - w, y - h)-(x + w, y + h), RGB(128, 128, 128), B
                                            'box that surrounds ellipse (grey)
        Picture1.Circle (x, y), r, RGB(255, 0, 0), s, e, a
                                            'actual ellipse (red)
        Picture1.Circle (sx, sy), 25, RGB(0, 192, 0), , , 1
                                            'start point marker (green)
        Picture1.Circle (ex, ey), 25, RGB(0, 0, 192), , , 1
                                            'end point marker (blue)
    End Sub

You can change the values of x, y, r, s, e and a to alter the ellipse/arc but you may want to give these values to the Math guys (http://www.experts-exchange.com/Miscellaneous/Math_Science/) to get an actual coordinate derivation...



Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now