Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using color in Draw string
#27
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
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
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)