QB64 Phoenix Edition
Using color in Draw string - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Using color in Draw string (/showthread.php?tid=2573)

Pages: 1 2 3 4


RE: Using color in Draw string - Pete - 04-05-2024

What, more editing? I'll get it write, eventually!

Pete Big Grin


RE: Using color in Draw string - PhilOfPerth - 04-05-2024

(04-05-2024, 02:23 AM)Pete Wrote: What, more editing? I'll get it write, eventually!

Pete Big Grin

Of curse you will; Pete. Have you noticed to, another fing peeple offen get rong is pucturation.


RE: Using color in Draw string - Pete - 04-05-2024

Well house about now, varmint!

Pete Big Grin


RE: Using color in Draw string - TerryRitchie - 04-05-2024

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



RE: Using color in Draw string - NakedApe - 04-05-2024

Gee, thanks, Terry. I've been staring at my screen in a daze for the last 20 minutes. Nice demo - cool, little program.  Shy


RE: Using color in Draw string - TerryRitchie - 04-05-2024

(04-05-2024, 07:11 PM)NakedApe Wrote: Gee, thanks, Terry. I've been staring at my screen in a daze for the last 20 minutes. Nice demo - cool, little program.  Shy
Yikes, it should have come with a warning! Smile


RE: Using color in Draw string - TerryRitchie - 04-05-2024

Here's another one to stare at.

Code: (Select All)
' DrawBoxes.BAS
'
' DRAW example using paint feature
' by Terry Ritchie 04/05/24

' Using the paint feature in DRAW can be very taxing on the CPU.
' Change boxsize to 20 below and see the result.

CONST BOXSIZE = 100 '      side length of rotating squares

DIM Angle AS INTEGER '     pen rotation angle
DIM Gray AS INTEGER '      paint color
DIM Direction AS INTEGER ' paint color direction
DIM s AS STRING '          side length of square in string format
DIM s2 AS STRING '         1/2 side length of square in string format
DIM Box AS STRING '        string used to draw a square
DIM White AS STRING '      color white in string format
DIM Black AS STRING '      color black in string format

SCREEN _NEWIMAGE(800, 600, 32) '                                    enter a graphics screen
White = STR$(_RGB(255, 255, 255)) '                                 create white string
Black = STR$(_RGB(0, 0, 0)) '                                       create black string
s = STR$(BOXSIZE) '                                                 create side length string
s2 = STR$(BOXSIZE \ 2) '                                            create 1/2 side length string
Box = "D" + s2 + "L" + s + "U" + s + "R" + s + "D" + s2 '           create string to draw a square
Direction = 1 '                                                     set paint color direction
Gray = 0 '                                                          set paint color
DO '                                                                begin main program loop
    CLS '                                                           clear the screen
    _LIMIT 60 '                                                     no faster than 60 FPS
    FOR y = BOXSIZE \ 2 TO 600 - BOXSIZE \ 2 STEP BOXSIZE '         cycle square x center points
        FOR x = BOXSIZE \ 2 TO 800 - BOXSIZE \ 2 STEP BOXSIZE '     cycle square y center points
            DRAW "BM" + STR$(x) + "," + STR$(y) '                   move pen to square center point
            DRAW "TA" + STR$(Angle) '                               rotate pen
            DRAW "C" + Black '                                      make pen color black
            DRAW "R" + s2 '                                         move pen to square border
            DRAW "C" + White '                                      make pen color white
            DRAW Box '                                              draw a square
            DRAW "BM" + STR$(x) + "," + STR$(y) '                   move pen back to center of square
            DRAW "P" + STR$(_RGB(Gray, Gray, Gray)) + "," + White ' paint inside the square
        NEXT x
    NEXT y
    _DISPLAY '                                                      update the screen with changes
    Gray = Gray + Direction '                                       increase/decrease gray color level
    IF Gray = 255 OR Gray = 0 THEN Direction = -Direction '         reverse gray level direction
    Angle = Angle + 1 '                                             increase pen angle
    IF Angle = 360 THEN Angle = 0 '                                 reset angle when needed
LOOP UNTIL _KEYDOWN(27) '                                           leave when ESC key pressed
SYSTEM '                                                            return to operating system



RE: Using color in Draw string - PhilOfPerth - 04-05-2024

(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.


RE: Using color in Draw string - TerryRitchie - 04-06-2024

(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.


RE: Using color in Draw string - PhilOfPerth - 04-06-2024

(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!!!