Antialiased text on half-transparent brushes
Posted: Thu Aug 21, 2014 2:08 pm
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"!
Best regards!
George
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()
George