# GETCOLOR (W*S)

Graphics Function: Returns the current graphics color index.

## Module

USE IFQWIN

result = GETCOLOR( )

## Results

The result type is INTEGER(2). The result is the current color index, if successful; otherwise, -1.

GETCOLOR returns the current color index used for graphics over the background color as set with SETCOLOR. The background color index is set with SETBKCOLOR and returned with GETBKCOLOR. The color index of text over the background color is set with SETTEXTCOLOR and returned with GETTEXTCOLOR. These non-RGB color functions use color indexes, not true color values, and limit the user to colors in the palette, at most 256. For access to all system colors, use SETCOLORRGB, SETBKCOLORRGB, and SETTEXTCOLORRGB.

## Example

    !  Program to demonstrate GETCOLOR
     PROGRAM COLORS
     USE IFQWIN
     INTEGER(2) loop, loop1, status, color
     LOGICAL(4) winstat
     REAL rnd1, rnd2, xnum, ynum
     type (windowconfig) wc
     status = SETCOLOR(INT2(0))
    !  Color random pixels with 15 different colors
     DO loop1 = 1, 15
       color = INT2(MOD(GETCOLOR() +1, 16))
       status = SETCOLOR (color) ! Set to next color
       DO loop = 1, 75
    !  Set color of random spot, normalized to be on screen
         CALL RANDOM(rnd1)
         CALL RANDOM(rnd2)
         winstat = GETWINDOWCONFIG(wc)
         xnum = wc%numxpixels
         ynum = wc%numypixels
         status = &
         SETPIXEL(INT2(rnd1*xnum+1),INT2(rnd2*ynum))
         status = &
         SETPIXEL(INT2(rnd1*xnum),INT2(rnd2*ynum+1))
         status = &
         SETPIXEL(INT2(rnd1*xnum-1),INT2( rnd2*ynum))
         status = &
         SETPIXEL(INT2(rnd1*xnum),INT2( rnd2*ynum-1))
       END DO
     END DO
     END

Parent topic: Graphics Library Routines

## See Also

GETCOLORRGB
GETBKCOLOR
GETTEXTCOLOR
SETCOLOR