' Draw four circles at the center of the screen SCREEN 12 ' LET CENTERX = 640 / 2 LET CENTERY = 480 / 2 LET RADIUS = 10 ' COLOR 4 CIRCLE (CENTERX, CENTERY), RADIUS ' COLOR 8 CIRCLE (CENTERX, CENTERY), RADIUS * 2 ' COLOR 9 CIRCLE (CENTERX, CENTERY), RADIUS * 3 ' COLOR 10 CIRCLE (CENTERX, CENTERY), RADIUS * 4 ENDBy changing the number in the variable RADIUS to 10, all the circles are affected. Using variables is more flexible than typing in numbers.
Variables are useful when you want to draw several similar figures. Here is a program that draws three red circles of radius 20 on the screen. Every circle has its center in the same row (Y=100), but has its center in a different column.
' Draw three circles in the same row SCREEN 12 COLOR 4 ' LET ROW = 100 LET RADIUS = 20 ' LET COLUMN = 50 CIRCLE (COLUMN, ROW), RADIUS ' LET COLUMN = 100 CIRCLE (COLUMN, ROW), RADIUS ' LET COLUMN = 150 CIRCLE (COLUMN, ROW), RADIUS ' ENDUsing names for the numbers used in the graphics statements makes it easier to organize the program.
Say that you have just run the above program and decide you would like the picture better if all the circles were in row 200. How could you change the program?