Created
September 8, 2017 18:06
-
-
Save Shchvova/068e64f84671a5ab9ee28aedf53c290e to your computer and use it in GitHub Desktop.
Graph Filter Demo
This file contains hidden or 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
display.setStatusBar( display.HiddenStatusBar ) | |
local effect = { | |
language = "glsl", | |
category = "filter", | |
name = "graphDemo", | |
graph = | |
{ | |
nodes = { | |
dotted = { effect="filter.polkaDots", input1="paint1" }, | |
bulged = { effect="filter.bulge", input1="dotted" }, | |
}, | |
output = "bulged", | |
}, | |
} | |
display.loadRemoteImage( "https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png", "GET", function( event ) | |
if ( event.isError ) then | |
print ( "Network error - download failed" ) | |
return | |
end | |
local image = event.target | |
local r = image.width/image.height | |
if display.contentWidth/display.contentHeight > r then | |
image.height = display.contentHeight*0.8 | |
image.width = image.height*r | |
else | |
image.width = display.contentWidth*0.8 | |
image.height = image.width/r | |
end | |
graphics.defineEffect( effect ) | |
image.fill.effect = "filter.custom.graphDemo" | |
image.fill.effect.bulged.intensity = 0.85 | |
image.fill.effect.dotted.numPixels = 8 | |
image.fill.effect.dotted.dotRadius = 1 | |
image.fill.effect.dotted.aspectRatio = ( image.width / image.height ) | |
timer.performWithDelay( 2000, function( ) | |
Runtime:addEventListener( "enterFrame", function( e ) | |
image.fill.effect.bulged.intensity = 0.85 + math.abs(math.sin(e.time*0.001)*0.2) | |
end ) | |
end ) | |
end, "lenna.png", display.contentCenterX, display.contentCenterY ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment