﻿﻿ CIRCLE - QB64 Wiki

# CIRCLE

The CIRCLE statement is used in graphics SCREEN modes to create circles, arcs or ellipses.

• Can use STEP for relative coordinate moves from the previous graphic coordinates.
• Coordinates designate the center position of the circle. Can be partially drawn offscreen.
• radius% is an INTEGER value for half of the total circle diameter.
• colour% is any available color attribute in the SCREEN mode used.
• startRadian! and stopRadian! can be any SINGLE value from 0 to 2 * pi to create partial circles or ellipses.
• aspect! SINGLE values of 0 to 1 affect the vertical height and values over 1 affect the horizontal width of an ellipse. Aspect = 1 is a normal circle.

Usage:

• When using aspect! the startRadian! and stopRadian! commas MUST be included even if not used.
• Radians move in a counter clockwise direction from 0 to 2 * Pi. Zero and 2 * Pi are the same circle radian at 3 o'clock.
• Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.
• Commas after the colour% parameter are not required when creating a normal circle. Color can also be omitted.
• The QB64 and QB graphic cursor is set to the center of the program window on program start for STEP relative coordinates.
• CIRCLE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!

Circle.BI Include file or SUB to use when using PAINT with pie charts or arc slices:

Example 1: Finding when the mouse is inside of a circular area:

SCREEN 12 r& = 200 'radius change circle size and position here cx& = 320 'center x horizontal cy& = 240 'center y vertical DO i = _MOUSEINPUT x& = _MOUSEX y& = _MOUSEY xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem IF r& ^ 2 >= xy& THEN CIRCLE (cx&, cy&), r&, 10 ELSE CIRCLE (cx&, cy&), r&, 12 LOOP UNTIL INKEY\$ = CHR\$(27) 'escape key exit

Explanation: The square of the circle radius will be greater than or equal to the sum of the square of the mouse coordinates minus the center position when the pointer is inside of the circle. In this example the circle color will change from red to green.

Example 2: Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.

Circle clock - by Terry Ritchie 11/04/06

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
• Page
• Discussion
• View source
• History