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.

Code Snippets / [DBP] Pure DBP + Alpha

Author
Message
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 2nd Sep 2007 06:16
Hello all. I made a simple alpha function (rgba) which will make an alpha based color.


And here's an example using that:


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 2nd Sep 2007 15:03
Thats awesome! Cloggy's dll can obviously do that but its nice to see how it works. I must admit I am somewhat stumped as to how that line actually works. I've never seen anything like it.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 2nd Sep 2007 22:04
It's simply a few bitwise operators. Colors are stored like this in DBP and DirectX:

0xAARRGGBB

For example, 0xFFFF0000 is pure red. This: 0xFF00FF00 is pure green, and 0xFF0000FF is pure blue. Now, the alpha value is stored at the left, the very first FF part. Changing that part would give an alpha value, 0x77FF0000. That's now an alpha of red. With the rgba function I provided, you wouldn't have to memorize this, or you could just change a specific value, for testing.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 3rd Sep 2007 01:33
OK. I sort of understood I was just thrown out by the use of '<<', 'and' + 'or' in an equals equation. Thanks!

Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 3rd Sep 2007 01:51
This is very cool.
Presuming that the values specified for a,r,g,b are 0-255, presumably the "and" statements aren't necessary? I should check this out myself.
Also, is "and" the same as "&&" ?

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 3rd Sep 2007 06:49
Mr Tank:
and is the same as && from what I understand, but I decided to make it the AND command because it would look more basic, and easy to understand. I believe the AND statements are indeed necessary, but I could be wrong..

TEH_CODERER:
Well, those all allow for placing within the bits of the output DWORD value. Bitwise operators you know.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 3rd Sep 2007 12:55
Ok, cool. I've just never worked with that before. Now I know! Thanks for the lesson!

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 3rd Sep 2007 23:28
No problem.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 4th Sep 2007 12:09 Edited at: 4th Sep 2007 12:10
Just a thought, wont this kind of thread get deleted because it dosent have the db version on it?
I wouldnt know really


EDIT: jsut realised that the name of the thread itself says 'Pure DBP'


Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 5th Sep 2007 04:05
If a mod would like to edit to make it more clear, then that'd be fine.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 5th Sep 2007 09:29
Excuse the double post, but I would also like to state I do plan on allowing an actual window image for this thing, however, I can't think of a speedy way to do what I need... Without coding a plugin. I mean, DirectX has the raw ability to do this exactly, in a speedy manner! Unfortunately DBP doesn't allow that control natively, I wish it did. DBP is a fine language (With some issues to work out, but fine none the less).



Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 5th Sep 2007 23:43
Thanks for posting this, I've never really understood how to use << and >> until now

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 6th Sep 2007 05:26
Thanks.

Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 14th Nov 2007 17:33
Very clever use of those logic operators. I would have used something like:

c as dword
c = (a*16777216)+(r*65536)+(g*256)+b

However, yours seems more elegant, and I'm surprised to see that DB can accept anything other than a boolean in AND/OR logic.

Your signature has been erased by a hyper-intelligent pan-dimensional being (a mod)
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 14th Nov 2007 23:13
Thanks. Your way is probably quicker for DBP considering DBP has to call a dll for each of it's basic operations (Such as the AND/OR, Multiply, Add, etc). :/

Cheers,

-naota

"I'd newbie slap here, but I've no idea how far I'd need slap before they'd come back with a clue." - VanB
Aex.Uni forums
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 16th Nov 2007 04:00
so i saw this and started to ponder how it worked.
2 days later, im thinking d--n! How did you think of that?

alus.portbb.com go there.
[quote]A book. I hate books. book is stupid. I know that I need codes but I dont know the codes.[/quote} -zenicanin14 the stupidest user in the world.
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 16th Nov 2007 04:04
Bitwise operations on variable to place in AARRGGBB manner, where as each "double" is 1 byte, so 1 byte to alpha, 1 to red, 1 to green, and 1 to blue.

Cheers,

-naota

"I'd newbie slap here, but I've no idea how far I'd need slap before they'd come back with a clue." - VanB
Aex.Uni forums

Login to post a reply

Server time is: 2024-11-22 13:32:24
Your offset time is: 2024-11-22 13:32:24