~npisanti/rsk_tools

b9fb4ebdec59a2ab85f9cae6c14813077081c4c6 — Nicola Pisanti a month ago 5b5e618
improve and uniform arguments for shaders
4 files changed, 60 insertions(+), 23 deletions(-)

M shader/main.lua
M shader_gif/main.lua
M shadercam/main.lua
M shaderdrop/main.lua
M shader/main.lua => shader/main.lua +9 -5
@@ 7,17 7,21 @@ window.title( " " )
if args.count() > 0 then 
    frag.load( args.get(0), "glsl" ) 
end    
  
if args.count() > 1 then 
    window.title( args.get(1) )
end  

local w = 480 
local h = 480

if args.count() > 2 then
	w = tonumber( args.get(1) )
	h = tonumber( args.get(2) )
if args.count() > 3 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
end

if args.count() > 3 then
	local m = tonumber( args.get(3) )
if args.count() > 4 then
	local m = tonumber( args.get(4) )
	window.size( w*m, h*m )
	layer.create( "def", w, h, m )
else

M shader_gif/main.lua => shader_gif/main.lua +7 -8
@@ 2,23 2,22 @@
require "strict"

----------------------------------------------------
window.title( " " )

if args.count() > 0 then 
    frag.load( args.get(0), "glsl" ) 
end    

window.title( args.get(1) )

local w = 480 
local h = 480
local sec = 0
local fps = 0 


if args.count() > 4 then
	w = tonumber( args.get(1) )
	h = tonumber( args.get(2) )
	fps = tonumber( args.get(3) )
	sec = tonumber( args.get(4) )
if args.count() > 5 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
	fps = tonumber( args.get(4) )
	sec = tonumber( args.get(5) )
end

window.size( w, h )

M shadercam/main.lua => shadercam/main.lua +17 -4
@@ 11,13 11,26 @@ local freeze = 0

----------------------------------------------------

window.title( "" )
window.size( camw, camh )
layer.create( "def", camw, camh, 1) 
window.title( "" )  
window.title( args.get(1) )

if args.count() > 3 then
	camw = tonumber( args.get(3) )
	camh = tonumber( args.get(4) )
end

if args.count() > 4 then
	local m = tonumber( args.get(5) )
	window.size( camw*m, camh*m )
	layer.create( "def", camw, camh, m )
else
	window.size( camw, camh )
	layer.create( "def", camw, camh, 1 )
end

frag.load( args.get(0), "glsl" )      

cam.open(args.get(1), camw, camh )
cam.open(args.get(2), camw, camh )

----------------------------------------------------
function loop()

M shaderdrop/main.lua => shaderdrop/main.lua +27 -6
@@ 2,11 2,32 @@
require "strict"

----------------------------------------------------
window.title( "" )
window.size( 480, 480 )
layer.create( "def", 480, 480, 1)
window.title( " " )

frag.load( args.get(0), "glsl" ) 
if args.count() > 0 then 
    frag.load( args.get(0), "glsl" ) 
end    
  
if args.count() > 1 then 
    window.title( args.get(1) )
end  

local w = 480 
local h = 480

if args.count() > 3 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
end

if args.count() > 4 then
	local m = tonumber( args.get(4) )
	window.size( w*m, h*m )
	layer.create( "def", w, h, m )
else
	window.size( w, h )
	layer.create( "def", w, h, 1 )
end

png.align_center()
png.load( "tests" )


@@ 25,14 46,14 @@ function loop()
	    	layer.open()
		        rl.clear( 0, 0, 0, 0 )
		        rl.color( 255, 255, 255, 255 ) 
		        png.draw( window.width()*0.5, window.height()*0.5 )
		        png.draw( w*0.5, h*0.5 )
		        png.next()
		  	layer.close()	
		else 
	    	layer.open()
		        rl.clear( 255, 255, 255, 255 )
		        rl.color( 0, 0, 0, 255 ) 
		        png.draw( window.width()*0.5, window.height()*0.5 )
		        png.draw( w*0.5, h*0.5 )
		        png.next()
		    layer.close()	
		end