Font transparency

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
shaan1974
Prole
Posts: 11
Joined: Sat Jan 14, 2023 8:26 pm

Font transparency

Post 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
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: Font transparency

Post by BrotSagtMist »

Can you show how it looks? cause this should be working.
obey
shaan1974
Prole
Posts: 11
Joined: Sat Jan 14, 2023 8:26 pm

Re: Font transparency

Post by shaan1974 »

Hello, in fact if i put something else than 1 for opacity for the font it's not changing at all ;)
MrFariator
Party member
Posts: 548
Joined: Wed Oct 05, 2016 11:53 am

Re: Font transparency

Post 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.
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: Font transparency

Post 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)
obey
Rigachupe
Party member
Posts: 100
Joined: Fri Jun 18, 2021 11:21 am

Re: Font transparency

Post 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
shaan1974
Prole
Posts: 11
Joined: Sat Jan 14, 2023 8:26 pm

Re: Font transparency

Post by shaan1974 »

Thanks i'm gonna test it.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 2 guests