My Community
September 07, 2010, 06:17:04 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: QB64 is available for 64-bit Linux!  -  QB64 V0.91 for Windows was released on the 31st of July.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: ButtonBoss64  (Read 448 times)
Muffinman
Newbie
*
Posts: 41


« on: February 06, 2010, 05:46:41 AM »


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)

Code:
'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  - -
Logged
Galleon
Administrator
Hero Member
*******
Posts: 1297


Email
« Reply #1 on: February 06, 2010, 03:20:13 PM »

I loved both your text-word alignment routine and this "buttonize" routine. I'm sure your work will inspire others to experiment with QB64's graphics commands too.

Thanks for sharing,
Galleon
Logged
Muffinman
Newbie
*
Posts: 41


« Reply #2 on: February 08, 2010, 03:51:55 PM »

Of course!  Muffin' to it really!  And I'll have something bran new to share soon.

(God, I hope that's not too corny!)
Logged
Cyperium
Hero Member
*****
Posts: 956


Original QB!


Email
« Reply #3 on: February 10, 2010, 05:44:41 PM »

lol, yeah I liked it too, you made the Wiki text look like a novel Smiley
Logged

The downloads for dqb2qb64 and Venture are currently down, links will be shown at the next release of dqb2qb64. Download my custom editor for QB64 (here (zip)).
Muffinman
Newbie
*
Posts: 41


« Reply #4 on: February 12, 2010, 03:26:26 PM »

lol, yeah I liked it too, you made the Wiki text look like a novel Smiley

I just don't know about that... but thx! :>

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!