Difference between revisions of "love.graphics.setBackgroundColor"

(Updated for 11.0)
m (Added Examples)
Line 13: Line 13:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
=== Example ===
 +
<source lang="lua">
 +
function love.draw()
 +
    -- Set Background Color to #1b8724 (27, 135, 36)
 +
    -- Note: Remember that Love uses 0-1 and not 0-255
 +
    red = 27/255
 +
    green = 135/255
 +
    blue = 36/255
 +
    love.setBackgroundColor( red, green, blue)
 +
end
 +
</source>
 +
 
== Function ==
 
== Function ==
 
{{newin|[[0.8.0]]|080|type=variant}}
 
{{newin|[[0.8.0]]|080|type=variant}}
Line 26: Line 38:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
=== Example ===
 +
<source lang="lua">
 +
function love.draw()
 +
    -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50%
 +
    -- Note: Remember that Love uses 0-1 and not 0-255
 +
    red = 115/255
 +
    green = 27/255
 +
    blue = 135/255
 +
    alpha = 50/100
 +
    love.setBackgroundColor( red, green, blue, alpha)
 +
end
 +
</source>
 +
 
== Function ==
 
== Function ==
 
{{newin|[[0.7.0]]|070|type=variant}}
 
{{newin|[[0.7.0]]|070|type=variant}}
Line 36: Line 61:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
=== Example ===
 +
<source lang="lua">
 +
function love.draw()
 +
    -- Set Background Color to #1b8724 (27, 135, 36)
 +
    -- Note: Remember that Love uses 0-1 and not 0-255
 +
    red = 27/255
 +
    green = 135/255
 +
    blue = 36/255
 +
    color = { red, green, blue}
 +
    love.setBackgroundColor( color)
 +
end
 +
</source>
 +
 
== Function ==
 
== Function ==
 
{{newin|[[0.8.0]]|080|type=variant}}
 
{{newin|[[0.8.0]]|080|type=variant}}
Line 46: Line 84:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
=== Example ===
 +
<source lang="lua">
 +
function love.draw()
 +
    -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50%
 +
    -- Note: Remember that Love uses 0-1 and not 0-255
 +
    red = 115/255
 +
    green = 27/255
 +
    blue = 135/255
 +
    alpha = 50/100
 +
    color = { red, green, blue, alpha}
 +
    love.setBackgroundColor( color)
 +
end
 +
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]

Revision as of 09:43, 11 March 2019

Sets the background color.

In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Function

Synopsis

love.graphics.setBackgroundColor( red, green, blue )

Arguments

number red
The red component (0-1).
number green
The green component (0-1).
number blue
The blue component (0-1).

Returns

Nothing.

Example

function love.draw()
    -- Set Background Color to #1b8724 (27, 135, 36)
    -- Note: Remember that Love uses 0-1 and not 0-255
    red = 27/255
    green = 135/255
    blue = 36/255
    love.setBackgroundColor( red, green, blue)
end

Function

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

Synopsis

love.graphics.setBackgroundColor( red, green, blue, alpha )

Arguments

number red
The red component (0-1).
number green
The green component (0-1).
number blue
The blue component (0-1).
number alpha
The alpha component (0-1).

Returns

Nothing.

Example

function love.draw()
    -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50%
    -- Note: Remember that Love uses 0-1 and not 0-255
    red = 115/255
    green = 27/255
    blue = 135/255
    alpha = 50/100
    love.setBackgroundColor( red, green, blue, alpha)
end

Function

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

Synopsis

love.graphics.setBackgroundColor( rgb )

Arguments

table rgb
A numerical indexed table with the red, green and blue values as numbers.

Returns

Nothing.

Example

function love.draw()
    -- Set Background Color to #1b8724 (27, 135, 36)
    -- Note: Remember that Love uses 0-1 and not 0-255
    red = 27/255
    green = 135/255
    blue = 36/255
    color = { red, green, blue}
    love.setBackgroundColor( color)
end

Function

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

Synopsis

love.graphics.setBackgroundColor( rgba )

Arguments

table rgba
A numerical indexed table with the red, green, blue and alpha values as numbers.

Returns

Nothing.

Example

function love.draw()
    -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50%
    -- Note: Remember that Love uses 0-1 and not 0-255
    red = 115/255
    green = 27/255
    blue = 135/255
    alpha = 50/100
    color = { red, green, blue, alpha}
    love.setBackgroundColor( color)
end

See Also


Other Languages