Code: Select all
' COLOURAREA.BAS by Stormy (May 29 2005)
' With this routine you can tint a specific area with a colour in a ratio of 1:1
' A little additional feature is, that u can declare the colours the routine
' shouldn't tint (like black colour).
DECLARE SUB ColourArea (MyCol AS LONG, X, Y, X2, Y2)
DECLARE SUB FillScreen
DIM T(2) AS SINGLE ' TIMER
SCREEN 14,16,2,&H1 ' 320x240, 16bit, 2pages, fullscreen
SCREENSET 0,1
RANDOMIZE TIMER
FillScreen
LOCATE 1 : PRINT "Press any key... Theme 1 of 3 [BLUE]": SCREENCOPY: SLEEP
ColourArea (RGB(0,0,255), 0, 0, 320, 240) ' a blue tone
WAIT &h3DA, 8
SCREENCOPY: SLEEP
FillScreen
LOCATE 1 : PRINT "Press any key... Theme 2 of 3 [RED]": SCREENCOPY: SLEEP
ColourArea (RGB(255,0,0), 0, 0, 320, 240) ' an orange tone
WAIT &h3DA, 8
SCREENCOPY: SLEEP
FillScreen
LOCATE 1 : PRINT "Press any key... Theme 3 of 3 [GREEN]": SCREENCOPY: SLEEP
ColourArea (RGB(0,255,0), 0, 0, 320, 240) ' an orange tone
WAIT &h3DA, 8
SCREENCOPY: SLEEP
SUB ColourArea (MyCol AS LONG, X, Y, X2, Y2)
DIM col AS LONG, c(3, 3) AS INTEGER
DIM IgnoreCol(0 TO 2) AS LONG, tmp AS LONG
IgnoreCol(0) = RGB(255,255,255)' text-colour
IgnoreCol(1) = RGB(0,0,0) ' Mask colour of 8bit-screens
IgnoreCol(2) = RGB(255,0,255) ' Mask colour of 16 & 32bit-screens
c(1,1) = (Mycol SHR 16) AND &hFF
c(1,2) = (Mycol SHR 8) AND &hFF
c(1,3) = Mycol AND &hFF
FOR e = X TO X2
FOR i = Y TO Y2
col = POINT(e,i)
c(2,1) = (col SHR 16) AND &hFF
c(2,2) = (col SHR 8) AND &hFF
c(2,3) = col AND &hFF
c(3,1) = INT((c(1,1) + c(2,1)) / 2)
c(3,2) = INT((c(1,2) + c(2,2)) / 2)
c(3,3) = INT((c(1,3) + c(2,3)) / 2)
tmp = RGB(c(3,1),c(3,2),c(3,3))
FOR t = LBOUND(IgnoreCol) TO UBOUND(IgnoreCol)
IF col = IgnoreCol(t) THEN tmp = IgnoreCol(t): EXIT FOR
NEXT t
PSET(e,i), tmp
NEXT i
NEXT e
END SUB
SUB FillScreen ' This sub fills the screen
Circles = 50
FOR i = 1 TO Circles
X = INT(RND * 320) + 1
Y = INT(RND * 240) + 1
Size = INT(RND * 50) + 1
r = INT(RND * 256) + 1
g = INT(RND * 256) + 1
b = INT(RND * 256) + 1
CIRCLE (X, Y), Size, RGB(r,g,b), , , , F
NEXT i
END SUB