Opaque text
BlitzPlus Forums/BlitzPlus Programming/Opaque text
| ||
Hi, I'm scanning thru the help but find an 'opaque text' method. Does one exist (other than the 'ole print the same thing again in background colour)? |
| ||
Um.... text is opaque by default. Did you mean transparent?? |
| ||
I think he means characters with a solid background...so that when you rewrite text over old lines the old stuff is obscured. If so, the answer is no. Either redraw the old text over in the background color or draw a BG color rect over the old text area...or something similar. |
| ||
Out of interest, does anyone know how do do transparent text? Or transparent anything for that matter? |
| ||
OIC. Well, if you wanted to be REALLY clever about it... You could work out how big the text string is going to be on screen (with StringWidth(), StringHeight()), grab the screen area thats going to be obscured and store it in a temporary image, then when you want to remove the text and write some more, just draw the image at the coordinates from which it was grabbed, and delete the image itself, before printing the new text. Mearrin69's way is a similar thing, but obviously would only work with solid colour backgrounds (which backgrounds invariably aren't!) |
| ||
Yep, buffering the BG is the best way if you've got anything other than a solid color. If you're using text over some sort of pre-drawn interface, you can also just redraw the images before writing the new text. WoeIsMe: AFAIK the only way to do semi-transparent text/images/etc. in 2D mode would be to draw it on using RPF and WPF with your own blending. It's okay if you're only doing small areas of the screen - but too slow for full screen type things. M |
| ||
Also you could create bitmap fonts... ...with a background color of your choice and then just set the image mask to a different color than any of the colors you are using. OR ...and just use the DrawBlock command instead of the DrawImage command. |
| ||
Cheers chaps. Sorted. |
| ||
@WoeIsMe It basically invovles reading the pixel color of the image/txt that wants to transparent, reading the pixel color of the backround directly below where that pixel will be displayed, and mixing the color, depending on how much transparency you want. there are afew routine for it in the code archives. It ain't to fats tho foor larger images or screen areas. it's ok to use if your making say a 20x20 area transparent. :D |