Difference between revisions of "love.graphics.setBlendMode"

m
m
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{newin|[[0.2.0]]|020|type=function}}
 
 
Sets the [[BlendMode|blending mode]].
 
Sets the [[BlendMode|blending mode]].
 +
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 10: Line 10:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
 +
== Function ==
 +
{{newin|[[0.10.0]]|100|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
love.graphics.setBlendMode( mode, alphamode )
 +
</source>
 +
=== Arguments ===
 +
{{param|BlendMode|mode|The blend mode to use.}}
 +
{{param|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.
 +
 
==Example==
 
==Example==
 
<source lang="lua">
 
<source lang="lua">
Line 22: Line 37:
 
 
 
love.graphics.setColor(12, 100, 230)
 
love.graphics.setColor(12, 100, 230)
love.graphics.setBlendMode("multiplicative")
+
love.graphics.setBlendMode("multiply")
 
love.graphics.rectangle("fill", 75, 75, 125, 125)
 
love.graphics.rectangle("fill", 75, 75, 125, 125)
 
end
 
end
 
</source>
 
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]
Line 33: Line 49:
 
{{#set:Description=Sets the blending mode.}}
 
{{#set:Description=Sets the blending mode.}}
 
{{#set:Sub-Category=State}}
 
{{#set:Sub-Category=State}}
 +
{{#set:Since=020}}
 +
{{#set:PrettySince=[[0.2.0]]}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics.setBlendMode}}
 
{{i18n|love.graphics.setBlendMode}}

Revision as of 19:21, 27 December 2015

Sets the blending mode.

Function

Synopsis

love.graphics.setBlendMode( mode )

Arguments

BlendMode mode
The blend mode to use.

Returns

Nothing.

Function

Available since LÖVE 0.10.0
This variant is not supported in earlier versions.

Synopsis

love.graphics.setBlendMode( mode, alphamode )

Arguments

BlendMode mode
The blend mode to use.
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.

Example

function love.load()
	love.graphics.setBackgroundColor(54, 172, 248)
end

function love.draw()
	love.graphics.setBlendMode("alpha") --Default blend mode
	love.graphics.setColor(230, 44, 123)
	love.graphics.rectangle("fill", 50, 50, 100, 100)
	
	love.graphics.setColor(12, 100, 230)
	love.graphics.setBlendMode("multiply")
	love.graphics.rectangle("fill", 75, 75, 125, 125)
end

See Also



Other Languages