[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GSoft BASIC Toolbox Example



This is one of my first tests of calling GSOS toolbox routines from GSoft BASIC. This little program uses several toolbox calls to draw a set of circles centered on the screen while simultaneously cycling through the color palette. Once all the circles are drawn another set of toolbox calls are used to redefine the color palette and cycle through the palette creating a simple animation effect. So far Gsoft has been a great way to explore the toolbox.
 
-John
 
======================================================================
 
! Dimension arrays & variables.
DIM RECT_BOUNDS AS RECT
 
! Start QuickDraw II.
HGR
 
! Draw a set of circles centered on the screen.
COLOR% = 0
FOR RADIUS% = 0 TO 190
  RECT_BOUNDS.H1 = 160 - RADIUS%
  RECT_BOUNDS.H2 = 160 + RADIUS%
  RECT_BOUNDS.V1 = 100 - RADIUS%
  RECT_BOUNDS.V2 = 100 + RADIUS%
  COLOR% = COLOR% + 1
  IF COLOR% = 16 THEN COLOR% = 1
  SET640COLOR (COLOR%)
  FRAMEOVAL (RECT_BOUNDS)
NEXT
 
! Cycle the color palette.
CALL CYCLE_PALETTE
 
! Change the color palette to a gray scale.
FOR COLOR% = 1 TO 15
  RED% = COLOR% * 256
  GREEN% = COLOR% * 16
  BLUE% = COLOR%
  RGB% = RED% + GREEN% + BLUE%
  SETCOLORENTRY (0, COLOR%, RGB%)
NEXT
 
! Cycle the color palette.
CALL CYCLE_PALETTE
 
! Change the color palette to a red scale.
FOR COLOR% = 1 TO 15
  RED% = COLOR% * 256
  GREEN% = 0
  BLUE% = 0
  RGB% = RED% + GREEN% + BLUE%
  SETCOLORENTRY (0, COLOR%, RGB%)
NEXT
 
! Cycle the color palette.
CALL CYCLE_PALETTE
 
! Change the color palette to a green scale.
FOR COLOR% = 1 TO 15
  RED% = 0
  GREEN% = COLOR% * 16
  BLUE% = 0
  RGB% = RED% + GREEN% + BLUE%
  SETCOLORENTRY (0, COLOR%, RGB%)
NEXT
 
! Cycle the color palette.
CALL CYCLE_PALETTE
 
! Change the color palette to a blue scale.
FOR COLOR% = 1 TO 15
  RED% = 0
  GREEN% = 0
  BLUE% = COLOR%
  RGB% = RED% + GREEN% + BLUE%
  SETCOLORENTRY (0, COLOR%, RGB%)
NEXT
 
! Cycle the color palette.
CALL CYCLE_PALETTE
 
! Get any key to end.
GET KEY$
END
 
! +-------------+
! | Subroutines |
! +-------------+
 
! Cycle the color palette.
SUB CYCLE_PALETTE
FOR I% = 1 TO 190
  FIRST% = GETCOLORENTRY (0, 1)
  FOR J% = 1 TO 14
    COLOR% = GETCOLORENTRY (0, J% + 1)
    SETCOLORENTRY (0, J%, COLOR%)
  NEXT
  SETCOLORENTRY (0, 15, FIRST%)
NEXT
END SUB