Difference between revisions of "love.graphics.setBlendMode"
m (→Example) |
m |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 3: | Line 3: | ||
== Function == | == Function == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 20: | Line 9: | ||
=== Arguments === | === Arguments === | ||
{{param|BlendMode|mode|The blend mode to use.}} | {{param|BlendMode|mode|The blend mode to use.}} | ||
+ | {{New feature|0.10.0| | ||
{{param|BlendAlphaMode|alphamode ("alphamultiply")|What to do with the alpha of drawn objects when blending.}} | {{param|BlendAlphaMode|alphamode ("alphamultiply")|What to do with the alpha of drawn objects when blending.}} | ||
+ | }} | ||
=== Returns === | === Returns === | ||
Nothing. | Nothing. | ||
Line 26: | Line 17: | ||
The default "alphamultiply" alpha mode should normally be preferred except when drawing content with pre-multiplied alpha. If content is drawn to a [[Canvas]] using the "alphamultiply" mode, the Canvas texture will have pre-multiplied alpha afterwards, so the "premultiplied" alpha mode should generally be used when drawing a Canvas to the screen. | The default "alphamultiply" alpha mode should normally be preferred except when drawing content with pre-multiplied alpha. If content is drawn to a [[Canvas]] using the "alphamultiply" mode, the Canvas texture will have pre-multiplied alpha afterwards, so the "premultiplied" alpha mode should generally be used when drawing a Canvas to the screen. | ||
− | == | + | == Examples == |
<source lang="lua"> | <source lang="lua"> | ||
function love.load() | function love.load() | ||
− | love.graphics.setBackgroundColor( | + | love.graphics.setBackgroundColor(.21, .67, .97) |
end | end | ||
function love.draw() | function love.draw() | ||
− | love.graphics.setBlendMode("alpha") --Default blend mode | + | love.graphics.setBlendMode("alpha") -- Default blend mode. |
− | love.graphics.setColor( | + | love.graphics.setColor(.90, .17, .48) |
− | love.graphics.rectangle("fill", 50, 50, 100, 100) | + | love.graphics.rectangle("fill", 50,50, 100,100) |
− | + | ||
− | love.graphics.setColor( | + | love.graphics.setColor(.04, .39, .90) |
− | love.graphics.setBlendMode("multiply") | + | love.graphics.setBlendMode("multiply", "premultiplied") |
− | love.graphics.rectangle("fill", 75, 75, 125, 125) | + | love.graphics.rectangle("fill", 75,75, 125,125) |
end | end | ||
</source> | </source> |
Latest revision as of 14:40, 5 November 2023
Available since LÖVE 0.2.0 |
This function is not supported in earlier versions. |
Sets the blending mode.
Contents
Function
Synopsis
love.graphics.setBlendMode( mode, alphamode )
Arguments
BlendMode mode
- The blend mode to use.
Available since LÖVE 0.10.0
BlendAlphaMode alphamode ("alphamultiply")
- What to do with the alpha of drawn objects when blending.
Returns
Nothing.
Notes
The default "alphamultiply" alpha mode should normally be preferred except when drawing content with pre-multiplied alpha. If content is drawn to a Canvas using the "alphamultiply" mode, the Canvas texture will have pre-multiplied alpha afterwards, so the "premultiplied" alpha mode should generally be used when drawing a Canvas to the screen.
Examples
function love.load()
love.graphics.setBackgroundColor(.21, .67, .97)
end
function love.draw()
love.graphics.setBlendMode("alpha") -- Default blend mode.
love.graphics.setColor(.90, .17, .48)
love.graphics.rectangle("fill", 50,50, 100,100)
love.graphics.setColor(.04, .39, .90)
love.graphics.setBlendMode("multiply", "premultiplied")
love.graphics.rectangle("fill", 75,75, 125,125)
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info