PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Drawing a circle point by point
Drawing a circle point by point
The following code is used to draw a circle made of several points in an Image control (IMG_ImageDrawing). The coordinates of the center and the radius are entered by the user in edit controls (EDT_PosCenterH, EDT_PosCenterV and EDT_Radius). The color of the center point and the color of the circle are selected by the end user via two radio buttons (RADIO_SelectPointColor and RADIO_SelectCircleColor).
// Declare the variables
PointColor is int
CircleColor is int
Subscript is int
X, Y are int

// Declare the drawing in the "IMG_ImageDrawing" control
dStartDrawing(IMG_ImageDrawing)

// Retrieve the color of the center point
SWITCH RADIO_SelectPointColor
CASE 1: PointColor = LightRed
CASE 2: PointColor = LightBlue
CASE 3: PointColor = LightGreen
CASE 4: PointColor = LightYellow
END

// Retrieve the color of the circle
SWITCH RADIO_SelectCircleColor
CASE 1: CircleColor = LightRed
CASE 2: CircleColor = LightBlue
CASE 3: CircleColor = LightGreen
CASE 4: CircleColor = LightYellow
END

// Draw the circle
FOR Subscript = 0 TO 360
 X = EDT_PosCenterH + EDT_Radius * Cos(Subscript)
 Y = EDT_PosCenterV + EDT_Radius * Sin(Subscript)
 dPoint(X, Y, CircleColor)
END

// Draw the center point
dPoint(EDT_PosCenterH, EDT_PosCenterV, PointColor)
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment