Skip to content

CIRCLE

Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgCircle Last revised: 2024-12-06

Graphics statement to draw an ellipse or a circle.

Syntax

Circle [target ,] [STEP] (x, y), radius [, [color] [, [start] [, [end] [, [aspect] [, F]]]]]

Parameters

  • target — Optional; specifies the image buffer to draw on (from ImageCreate or Get (Graphics)). Defaults to screen's current work page.
  • STEP — Indicates that coordinates are relative to the current graphics cursor position.
  • (x, y) — Coordinates of the center of the ellipse/circle.
  • radius — The radius of the circle; for an ellipse, the semi-major axis (longest radius).
  • color — Color attribute. If omitted, uses current foreground color.
  • start — Starting angle (in radians, range -2π to 2π). If negative, a line is drawn from center to that point.
  • end — Ending angle. Can be less than start. Defaults to 2π if start is specified.
  • aspect — Aspect ratio (height/width ratio). Default: 1.0 for ScreenRes modes; auto-calculated for Screen modes to produce a perfect circle.
  • F — Fill flag. If specified, fills the circle/ellipse with the selected color.

Description

Circle draws a circle, ellipse, or arc based on the given parameters.

Aspect ratio rules:

  • If aspect < 1.0: radius is the x radius.
  • If aspect >= 1.0: radius is the y radius.

The aspect ratio formula: ratio = (y_radius / x_radius) * pixel_aspect_ratio

Custom coordinate systems set by Window and/or View (Graphics) affect the drawing. When Circle finishes, the current graphics cursor position is set to the supplied center.

Note: Curves drawn with Circle can cause pixels to be overdrawn at some locations.

Examples

vb
' Set 640x480 mode, 256 colors
Screen 18
' Draws a circle in the center
Circle (320, 240), 200, 15
' Draws a filled ellipse
Circle (320, 240), 200, 2, , , 0.2, F
' Draws a small arc
Circle (320, 240), 200, 4, 0.83, 1.67, 3
Sleep

Differences from QB

  • target is new to FreeBASIC.
  • FreeBASIC uses a different algorithm, so results may differ per pixel.
  • The F flag for filled circles/ellipses is new to FreeBASIC.

See Also

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft