Difference between revisions of "love.graphics.setPixelEffect"
(Created page with "{{newin|0.8.0|080|type=function}} Sets or resets a PixelEffect as the current pixel shader. All drawing operations until the next ''love.graphics.setPixelEffect'' will b...") |
(Adding example) |
||
Line 1: | Line 1: | ||
{{newin|[[0.8.0]]|080|type=function}} | {{newin|[[0.8.0]]|080|type=function}} | ||
− | Sets or resets a [[PixelEffect]] as the current pixel | + | Sets or resets a [[PixelEffect]] as the current pixel effect. All drawing operations until the next ''love.graphics.setPixelEffect'' will be drawn using the [[PixelEffect]] object specified. |
== Function == | == Function == | ||
Line 26: | Line 26: | ||
=== Notes === | === Notes === | ||
Disables pixel effects, allowing unfiltered drawing operations. | Disables pixel effects, allowing unfiltered drawing operations. | ||
+ | |||
+ | == Examples == | ||
+ | === Drawing a rectangle using a pixel effect === | ||
+ | <source lang="lua"> | ||
+ | function love.load() | ||
+ | effect = love.graphics.newPixelEffect [[ | ||
+ | extern number time; | ||
+ | vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) | ||
+ | { | ||
+ | return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0); | ||
+ | } | ||
+ | ]] | ||
+ | end | ||
+ | |||
+ | function love.draw() | ||
+ | -- boring white | ||
+ | love.graphics.setPixelEffect() | ||
+ | love.graphics.rectangle('fill', 10,10,790,285) | ||
+ | |||
+ | -- LOOK AT THE PRETTY COLORS! | ||
+ | love.graphics.setPixelEffect(effect) | ||
+ | love.graphics.rectangle('fill', 10,305,790,285) | ||
+ | end | ||
+ | |||
+ | local t = 0 | ||
+ | function love.update(dt) | ||
+ | t = t + dt | ||
+ | effect:send("time", t) | ||
+ | end | ||
+ | </source> | ||
== See Also == | == See Also == |
Revision as of 02:27, 16 August 2011
Available since LÖVE 0.8.0 |
This function is not supported in earlier versions. |
Sets or resets a PixelEffect as the current pixel effect. All drawing operations until the next love.graphics.setPixelEffect will be drawn using the PixelEffect object specified.
Contents
Function
Synopsis
love.graphics.setPixelEffect( pixeleffect )
Arguments
PixelEffect pixeleffect
- The new pixel effect.
Returns
Nothing.
Notes
Sets the current pixel shader to a specified PixelEffect. All drawing operations until the next love.graphics.setPixelEffect will be drawn using the PixelEffect object specified.
Function
Synopsis
love.graphics.setPixelEffect( )
Arguments
None.
Returns
Nothing.
Notes
Disables pixel effects, allowing unfiltered drawing operations.
Examples
Drawing a rectangle using a pixel effect
function love.load()
effect = love.graphics.newPixelEffect [[
extern number time;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0);
}
]]
end
function love.draw()
-- boring white
love.graphics.setPixelEffect()
love.graphics.rectangle('fill', 10,10,790,285)
-- LOOK AT THE PRETTY COLORS!
love.graphics.setPixelEffect(effect)
love.graphics.rectangle('fill', 10,305,790,285)
end
local t = 0
function love.update(dt)
t = t + dt
effect:send("time", t)
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