Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using color in Draw string
#30
(04-06-2024, 01:29 AM)TerryRitchie Wrote:
(04-05-2024, 11:48 PM)PhilOfPerth Wrote:
(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.
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.

Go Terry!!!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Messages In This Thread
Using color in Draw string - by PhilOfPerth - 04-04-2024, 05:49 AM
RE: Using color in Draw string - by SMcNeill - 04-04-2024, 06:00 AM
RE: Using color in Draw string - by PhilOfPerth - 04-04-2024, 06:07 AM
RE: Using color in Draw string - by PhilOfPerth - 04-04-2024, 08:55 AM
RE: Using color in Draw string - by SMcNeill - 04-04-2024, 09:02 AM
RE: Using color in Draw string - by PhilOfPerth - 04-04-2024, 09:19 AM
RE: Using color in Draw string - by TerryRitchie - 04-04-2024, 02:52 PM
RE: Using color in Draw string - by Pete - 04-04-2024, 10:31 AM
RE: Using color in Draw string - by Dimster - 04-04-2024, 05:42 PM
RE: Using color in Draw string - by TerryRitchie - 04-04-2024, 07:20 PM
RE: Using color in Draw string - by Pete - 04-04-2024, 05:58 PM
RE: Using color in Draw string - by Dimster - 04-04-2024, 08:18 PM
RE: Using color in Draw string - by TerryRitchie - 04-04-2024, 08:48 PM
RE: Using color in Draw string - by Pete - 04-04-2024, 09:29 PM
RE: Using color in Draw string - by SMcNeill - 04-04-2024, 10:14 PM
RE: Using color in Draw string - by PhilOfPerth - 04-04-2024, 10:22 PM
RE: Using color in Draw string - by TDarcos - 04-05-2024, 01:05 AM
RE: Using color in Draw string - by PhilOfPerth - 04-05-2024, 02:09 AM
RE: Using color in Draw string - by SMcNeill - 04-04-2024, 10:28 PM
RE: Using color in Draw string - by Pete - 04-04-2024, 10:45 PM
RE: Using color in Draw string - by Pete - 04-05-2024, 02:23 AM
RE: Using color in Draw string - by PhilOfPerth - 04-05-2024, 02:34 AM
RE: Using color in Draw string - by Pete - 04-05-2024, 02:36 AM
RE: Using color in Draw string - by TerryRitchie - 04-05-2024, 03:53 PM
RE: Using color in Draw string - by PhilOfPerth - 04-05-2024, 11:48 PM
RE: Using color in Draw string - by TerryRitchie - 04-06-2024, 01:29 AM
RE: Using color in Draw string - by PhilOfPerth - 04-06-2024, 02:27 AM
RE: Using color in Draw string - by NakedApe - 04-05-2024, 07:11 PM
RE: Using color in Draw string - by TerryRitchie - 04-05-2024, 09:25 PM
RE: Using color in Draw string - by TerryRitchie - 04-05-2024, 09:39 PM
RE: Using color in Draw string - by TerryRitchie - 04-09-2024, 09:52 PM



Users browsing this thread: 1 Guest(s)