Created
February 17, 2015 03:44
-
-
Save micaiahparker/e0d8548011506b631b53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function love.load() | |
image = love.graphics.newImage('images//image.png') | |
love.window.setTitle("Red/Green Inverse") | |
newHeight = 300 | |
newWidth = (newHeight * image:getWidth())/image:getHeight() | |
love.window.setMode(newWidth, newHeight*2) | |
factor = (newHeight/newWidth)*(newWidth/newHeight) | |
myShader = love.graphics.newShader[[ | |
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){ | |
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color | |
number r = pixel.r; | |
pixel.r = pixel.g; | |
pixel.g = r; | |
return pixel; | |
} | |
]] | |
end | |
function love.update(dt) | |
if love.keyboard.isDown('up') then | |
factor = factor +.001 | |
end | |
if love.keyboard.isDown('down') then | |
factor = factor -.001 | |
end | |
end | |
function love.draw() | |
love.graphics.setShader() --draw something here | |
love.graphics.draw(image, 0, 0, 0, factor, factor) | |
love.graphics.print("Factor: "..factor, 10, 5) | |
love.graphics.print("WH: "..newWidth/newHeight, 10, 15) | |
love.graphics.print("WH/HW: "..(newWidth/newHeight)/(newHeight/newWidth), 10, 25) | |
love.graphics.print("HW: "..newHeight/newWidth, 10, 35) | |
love.graphics.print("HW/WH: "..(newHeight/newWidth)/(newWidth/newHeight), 10, 45) | |
love.graphics.print("Width: "..newWidth, 10, 55) | |
love.graphics.print("Height: "..newHeight, 10, 65) | |
love.graphics.setShader(myShader) | |
love.graphics.draw(image, 0, newHeight, 0, factor, factor) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment