Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / BOX with Alpha?

Author
Message
Mr909
11
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 14th Nov 2012 01:16
How is it done? Can it be done? Please tell me it can be done.
:\
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Nov 2012 03:22 Edited at: 14th Nov 2012 03:27
anything you do with box can ben grabbed via get image and turned into a sprite, complete with alpha.

if you want to box with alpha directly "on top" of something that's already on the screen, you'll have to, either, do the above to a separate bitmap or consider a routine involving memblocks.

you'll need to provide more detail of what you're wanting to do for more advice.

Virtual Nomad @ California, USA . DBPro V7.7
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Nov 2012 03:26 Edited at: 14th Nov 2012 03:29
Three words. Advanced 2 D.

DBPRO drawing commands are slow. The only one I use is Paste Sprite, the others are not good for serious use in demanding apps.

However, if speed does not matter, just use a transparent colour with the box command. Make sure you are running in 32bit display mode.

This snippet shows you four solutions that draw semi-transparent white. The last two require Matrix1's 32bit RGB function to get the alpha channel.



Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Nov 2012 03:41 Edited at: 14th Nov 2012 03:42
ack, never knew:
Quote: "box 0,100,100,200,0x70FFFFFF,0x70FFFFFF,0x70FFFFFF,0x70FFFFFF"

was possible (not that i ever needed to know).

i'll have to learn those fancy color codes some day

Virtual Nomad @ California, USA . DBPro V7.7
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Nov 2012 18:00
The box command has 4 additional parameters, each being a color for the corner of a box. In this context, it will use the alpha value of the color.

And if you don't want to use the Matrix1 library, calculate the alpha this way:


"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 15th Nov 2012 10:01
Another two pence; if you want to know what 0xFFFFFFFF is all about; here is one of my articles based on it:



Basically after the 0x; each two characters represent one channel from alpha through red, green and blue; Or just red green and blue. Count from 0 to 15 (base 16 ); 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F; where FF is 255, and 0x80 is 128.

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th Nov 2012 09:55
The code works and yet I don't recall DBP supporting ARGB for basic 2D drawing - not that it matters as I don't use DBP draw command since, as stated before, they're slow. Still, thanks for that Chris, it may come in handy knowing and I like to be up to date with DBP's features.

RP Functions Library v1.0

My signature has not been erased by a mod.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st Nov 2012 21:26
Quote: "And if you don't want to use the Matrix1 library, calculate the alpha this way"

Or this, which supposedly is a bit faster for intense use:



"Why do programmers get Halloween and Christmas mixed up?"
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2012 22:02
I thought bit shifting might be faster, but I think some people tested it and couldn't see any different in performance.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st Nov 2012 23:00
Ah, I was not aware of that.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-04-25 08:29:50
Your offset time is: 2024-04-25 08:29:50