04-06-2024, 01:29 AM
(04-05-2024, 11:48 PM)PhilOfPerth Wrote:Yep, the examples will start out simple and work up towards these. I like to get the more difficult examples out of the way first.(04-05-2024, 03:53 PM)TerryRitchie Wrote: I'm adding the DRAW statement to Lesson 5 in the tutorial. I'm currently writing a few example programs to go along with it. This is the first example I made and shows how to use _RGB color to change line colors.
Code: (Select All)' Hypno.BAS (you are getting very sleepy)
'
' DRAW statement demo
' by Terry Ritchie 04/05/24
'
DIM angle AS INTEGER ' pen angle
DIM length AS INTEGER ' line length
DIM count AS INTEGER ' line counter
DIM Gray AS INTEGER ' gray color level
DIM Direction AS INTEGER ' gray level direction
SCREEN _NEWIMAGE(800, 600, 32) ' enter a graphics screen
Gray = 0 ' set gray color level
Direction = 1 ' set gray level direction
DO ' begin main program loop
_LIMIT 10 ' 10 times a second should be nice
angle = 0 ' reset pen angle
length = 1 ' reset line length
count = 0 ' reset line counter
DRAW "BM399,299" ' move pen to the center of screen
DO ' begin spiral draw loop
DRAW "C" + STR$(_RGB(Gray, Gray, Gray)) ' change gray level of line color
DRAW "TA" + STR$(angle) ' rotate pen
DRAW "R" + STR$(length) ' draw straight line to right at rotated angle
angle = angle + 15 ' increase angle of rotation
IF angle MOD 180 = 0 THEN length = length + 1 ' increase line length at top and bottom
IF angle = 360 THEN angle = 0 ' reset angle when needed
Gray = Gray + Direction ' increase/decrease gray color level
IF Gray = 255 OR Gray = 0 THEN Direction = -Direction ' reverse gray level direction
count = count + 1 ' increment line counter
LOOP UNTIL count = 1550 ' 1550 lines should do it
_DISPLAY ' update the screen with changes
LOOP UNTIL _KEYDOWN(27) ' leave when ESC pressed
SYSTEM ' return to the operating system
Wow, nice! But you're right about the "warning!
Yes, that makes things clearer for me. I think you need a simpler demo first though - maybe just a colured empty square or circle, then go on to fill it.