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.

DarkBASIC Professional Discussion / Drawing semi transparent pixels...

Author
Message
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 19th Sep 2003 17:18
I can get alpha blending with my sprites, but can I just draw semi transparent pixels, like with the box command? I would like to dim certain parts of the screen, and this would be a good way to do that, but I don't want to load images just for the purpose... I don't see how this can be done since rgb() doesn't take an alpha value...

Tony

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Sep 2003 17:44
You could draw the image to a hidden bitmap then grab it with the get image command, that'd save you having to load the file.

If you have a background image, you can have sorta translucent 2D, you just make a sprite with the background on it then set the alpha down a bit, then any 2D operation lies underneath the background and appears translucent. Works best with strong, bright colours.


Van-B

My cats breath smells of cat food.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 19th Sep 2003 19:58
Take the RGB on the pixel before you draw and then of the colour you're going to draw with, then take the average between the two.

That might blend them together. You just need do make your own functions to draw things like boxes etc.

c:/dos
c:/dos run
run dos run
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 19th Sep 2003 20:19 Edited at: 19th Sep 2003 20:26
It is possible to write your own RGBA() function using memblocks, however, the INK and/or BOX commands just ignore the alpha value (Although it does work with vertex colours so you can set vertex alpha).

iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 19th Sep 2003 21:12
I sort of got around the issue.

I didn't want to load a whole 640x480 sprite just to dim the screen... The solution I got working this morning was to create a 2x2 .png with 50% transparency, then when I need to dim the screen I scale it up to 640x480..

Tony

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Sep 2003 22:02
You don't even need to use external media. I did a transition effect for someone that was totally self-contained.

It basically works the same way as yours (1x1 pixel expanded to screen size) but uses the SET SPRITE ALPHA command to do the actual fading. The higher the alpha, the darker things get
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 20th Sep 2003 00:24
Cool... That is better...

Are these the steps?

- Create a 1x1 bitmap with a 1 black pixel in it.
- somehow Get this into an image (I dont have my DB manuals with me)
- Set the transparency of the sprite
- resize the sprite

That is load better...

Tony

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Sep 2003 00:45
That's basically it. The only part that needed thinking about was increasing the alpha value to make things darker.

Login to post a reply

Server time is: 2026-07-25 07:00:52
Your offset time is: 2026-07-25 07:00:52