Page 1 of 1

Font transparency

Posted: Sat Jan 14, 2023 8:28 pm
by shaan1974
Hello all,

I'm trying to set opacity on font but it's not working, maybe i'm doing something wrong:)

My code:

-- dedicated function to set hex color to r,g,b
local r,g,b = Utils:hex2rgb( color )

local o = 0.5

love.graphics.setColor(r,g,b,o)
love.graphics.setFont(font)
love.graphics.print( txt, x, y)
love.graphics.setColor(1, 1, 1, 1)

Thanks

Re: Font transparency

Posted: Sat Jan 14, 2023 9:30 pm
by BrotSagtMist
Can you show how it looks? cause this should be working.

Re: Font transparency

Posted: Sun Jan 15, 2023 2:29 pm
by shaan1974
Hello, in fact if i put something else than 1 for opacity for the font it's not changing at all ;)

Re: Font transparency

Posted: Sun Jan 15, 2023 3:05 pm
by MrFariator
A snippet like yours works fine on my end.
Are you sure you don't have anything that might interfere or influence the rendering somehow? An active shader, setting a blend mode, drawing to a canvas but forgetting to flush the canvas contents between frames, or something similar? If in doubt, post your full code.

Re: Font transparency

Posted: Sun Jan 15, 2023 6:18 pm
by BrotSagtMist
99% sure its split up in love.draw and love.load and hes just using locals because some tutorial told to do so.
For the record, using locals inside a function makes them disappear after that function. (unless you define other functions within said function)

Re: Font transparency

Posted: Mon Jan 16, 2023 6:15 am
by Rigachupe
Check it like this:
1. use black background in love.draw and do not do anything else there
2. then draw the text with various alpha color from range 0 to 1 and step 0.1 and you will see if there is difference.

Code: Select all

function love.draw()
  for alpha=0,1,0.1 do
    love.graphics.setColor(1,0,0,alpha)
    love.graphics.print("HELL0 WORLD alpha="..alpha,10,10+alpha*120)
  end
end

Re: Font transparency

Posted: Mon Jan 16, 2023 4:19 pm
by shaan1974
Thanks i'm gonna test it.