type: utility
purpose: originally supposed to "buttonize" a texture according to spec, and display resulting buttons. everyone can use more buttons!!!
A lot has happened since my last sample, TxWrap64. But most of it is irrelevant. The code below can be runned with your own small image (100 x 100 is a good size), or my templates found here:
http://i45.tinypic.com/34xp250.jpg ;
http://tinypic.com/r/2jg46lk/6 ;
http://i48.tinypic.com/2up4u4m.jpg (btw, if the things look screwy around the edges, that's because of the lossy compression that site uses, but you'll get the idea)
'summary:
' loads an image converting it into an alpha mask
' using putimage, cutouts can be created out of colored bg or desired graphic
' use put with the omit color attribute set to place cutouts anywhere
bgScreen = _NEWIMAGE(800,600,32)
SCREEN bgScreen
const NiceBlue& = &HFF0044AA
const SweetPink& = &HFFEE8080
const NeonGreen& = &H8800FF00
printline% = 12
'load a (probably grayscale) image with black representing transparent areas
awesome = _LOADIMAGE("Pat01.bmp")
hsize = 128 : vsize = 128
_putimage (0,0), awesome,1
_DEST awesome 'going to clear image rather than delete + load blank
cls
' same as "line ()(),&HFF000000, BF" , gotta re-set the clearcolor...
_clearcolor &HFF000000
for i = 0 to hsize -1
for i2 = 0 to vsize -1
SCREEN bgScreen,, 1,0
colspec&& = point(i,i2)
'let's avg up the visible color components, invert p value
colspec&& = (_RED(colspec&&) + _BLUE(colspec&&) + _GREEN(colspec&&)) \ 3
colspec&& = 255 - colspec&&
'*- if _PUTIMAGE is going to be used rather than PUT then set cb = 0
cb = -1
if cb = 0 then
if colspec&& = 255 then colspec&& = 0
end if
_DEST awesome
pset (i,i2), colspec&& * &H1000000
next i2
next i
SCREEN bgScreen,, 0,0
paint (0,0), NiceBlue&
' [ [ [ demo using _putimage ] ] ]
_putimage (0,0), awesome
' *!* this image would be invisible being placed on all black bg
line (0,200)-(799,599),&HFF000000,bf
_putimage (300,300), awesome
line (0,200)-(799,599),SweetPink&,bf
_putimage (135,135), awesome
sleep
' [ [ [ demo using put ] ] ]
DIM mySprite (50000 + 2 + hsize * vsize) AS LONG
get (0,0)-step(hsize-1,vsize-1), mySprite
put (0,250), mySprite, _CLIP PSET, &HFF000000
put (500,135), mySprite, _CLIP PSET, &HFF000000
sleep
' [ [ [ 2nd demo using put ] ] ]
screen bgScreen,,1,0
cls : paint (0,0),NiceBlue&
' usually you will want to GET from a putimage-ed sample, so:
_putimage (0,0), awesome
get (0,0)-step(hsize-1,vsize-1), mySprite
screen bgScreen,, 0,0
' demo loops :
for i = 1 to 6
put (350, i * 60 - 90), mySprite, _CLIP PSET, &HFF000000
next i
sleep
color NeonGreen&: print "BAM!"
for i = 1 to 6
put (400, i * 60 - 60), mySprite, _CLIP PSET, &HFF000000
next i
sleep
'awesomer = _NEWIMAGE(hsize * 2 - 1,vsize-1,32)
' de-alphatizer
'for dealpha = 0 to 1 + hsize * vsize
' mySprite(dealpha)= mySprite(dealpha) and &HFFFFFF
'next
get (0,0)-step(hsize-1,vsize-1), mySprite
'put (135,320), mySprite, PSET, &HFF000000
' forgetting PSET can cause undesired weirdness
put (135,320), mySprite,, &HFF000000
'_putimage (160,320), awesome
sleep
for i5 = 1 to 5: yy$ = inkey$ : next i5
for fader% = 1 to 30
'_putimage (135,320), awesome
_putimage (135-1+ fader%,320+ fader%), awesome
_DISPLAY
_LIMIT 3
if inkey$ <> "" then exit for
next fader%
_AUTODISPLAY
put (145,330), mySprite, PSET, &HFF000000
'_putimage (300,300), awesome
'_putimage (120,320), awesomer
' - - program end - -