Page 1 of 1

Antialiased text on half-transparent brushes

Posted: Thu Aug 21, 2014 2:08 pm
by evil
Hello!
In my project I have brushes with variable transparencies. Iwant to write some antialiased text on these brushes.

In this example I create a brush, set its alphaintensity to 128 using cls.
Next I give it a pink color using cls($ff00ff)
Next I want to draw some antialiased text on it.
So first i write the text to the alphachannel with intensity 255, next I write the same text to the brushcolor.

When I now display the brush,you can see the pink background with an alphaintensity of 255 in the rounded parts of the letters.
Of course the pink parts are visible, because I previously set those parts to intensity 255, and because antialiased text uses different transparencies for those pixels...

Actually I think to work around this with layers (one for the backdrop, one for the text), but that would slow down some processes, because:
In my project a "field" would contain a header with text, and a mainfield with text. And these parts need to be moveable. So i would have to move 4 layers per field... And the user should be able to move several fields at the same time. This would slowdown the usage a lot.

Is there any other solution or workaround for this problem??

Her an example code:
Look precise to the rounded parts of the word "Test"!

Code: Select all

setfillstyle(#fillcolor)
SetFont(#SANS,100) SetFontStyle(#antialias)
createbrush (1,400,400) 
selectalphachannel(1) setalphaintensity(128) cls() endselect()
selectbrush (1) cls($ff00ff) endselect()
selectalphachannel(1) setalphaintensity(255) textout(#center,#center,"Test") EndSelect()
SelectBrush(1) textout(#center,#center,"Test") EndSelect()
displaybrush (1,0,0)
waitleftmouse()
Best regards!

George

Re: Antialiased text on half-transparent brushes

Posted: Wed Aug 27, 2014 7:49 pm
by airsoftsoftwair
This is the old problem when trying to render alpha-transparent images to another alpha-transparent image. This has already been asked several times here and the next Hollywood update will feature a new mode for #SELMODE_COMBO which will allow you to do what you want. So currently, it's not easily possible though I remember that Allanon had some workaround but it definitely will be supported by the next Hollywood version.

Re: Antialiased text on half-transparent brushes

Posted: Thu Aug 28, 2014 7:45 am
by Allanon
Yes, the workaround partially resolves the problem but costs in terms of cpu time.

1. Setup the brush A you wish to render the text to with your background.
2. Setup another empty brush B with alpha channel enabled and render the text into it.
3. Use Mixbrush(A, B, level) function to obtain the desired result.
4. Free brush B because no more needed.

Actually this solution have the fallback that the text rendered into the brush B get (partially) the alpha level of the brush A but it is the only solution I've found that works for these kind of drawings.

Re: Antialiased text on half-transparent brushes

Posted: Sun Aug 31, 2014 11:06 am
by evil
Thanks for your workaround.
I solved the problem by using Layers for each part of the field.
Means, one layer for the Text and another one for the halftransparent brush.
This way everything looks like it should, but it slows down moving them a little bit.
But as I used the movelist for moving the fields, moving speed is absolutley ok.

By the way:
Andreas, can you say anything about the release-date of the next hollywood-version?

Thanks and best regards

George

Re: Antialiased text on half-transparent brushes

Posted: Tue Sep 02, 2014 1:38 am
by airsoftsoftwair
Sorry, can't predict anything about the release date at this time... when it's done :)