~npisanti/scriptools

85ce300fda9b77b08b24dbde2a07ad7746f117c6 — Nicola Pisanti a month ago ce65c32
refactoring and tweaks
9 files changed, 90 insertions(+), 93 deletions(-)

M README.md
R shader/{main.lua => in.lua}
R shadercam/{main.lua => ain.lua}
R shaderdrop/{main.lua => ain.lua}
R shaderdrop/tests/{.gitkeep => gitkeep}
R shaderdrop/tests/{frame_002.png => rame_002.png}
R shaderdrop/tests/{frame_003.png => rame_003.png}
R shaderdrop/tests/{frame_004.png => rame_004.png}
R shader_gif/{main.lua => in.lua}
M README.md => README.md +4 -4
@@ 5,10 5,10 @@ Collection of scripted tools made with [raylyeh](https://git.sr.ht/~npisanti/ray
* `cereal`: process the `input` folder with `process.frag`
* `eye`: monochrome webcam viewer
* `framescan` : tools to acquire stop motion drawing using the webcam
* `shader` : minimum lua script to livecode a shader passed as cli argument
* `shader_gif` : as `shader`, but renders to a gif with some given arguments
* `shadercam` : as `shader`, but with webcam input 
* `shaderdrop` : as `shader`, but with test png frames drawn upon the layer 
* `glsl` : minimum lua script to livecode a shader passed as cli argument
* `glsl_gif` : as `glsl`, but renders to a gif with some given arguments
* `glsl_cam` : as `glsl`, but with webcam input 
* `glsl_drop` : as `glsl`, but with test png frames drawn upon the layer 
 
## license 
Nicola Pisanti MIT License 2020

R shader/main.lua => glsl/main.lua +18 -27
@@ 2,50 2,41 @@
require "strict"

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

window.title( " " )

if args.count() > 0 then 
	-- TODO: compare arg to ".frag" here 
    frag.load( args.get(0), "glsl" ) 
	title =  args.get(1)
    window.title( title )
else
	window.quit()
end
  
if args.count() > 1 then 
	title =  args.get(1)
    window.title( title )
end  

local w = 480 
local h = 480

if args.count() > 3 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
local w = args.get_number( "-w", 480) 
local h = args.get_number( "-h", 480)
local m = args.get_number( "-m", 1)
local o = m
if m < 1 then m = 1 end
window.size( w*m, h*m )
layer.create( "def", w, h, o )

local px = args.get_number( "-x", -1)
local py = args.get_number( "-y", -1)

if px >= 0 and py >= 0 then 
	window.move( px, py )
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

if args.count() > 6 then
	window.move( tonumber(args.get(5)), tonumber(args.get(6)) )
end 
window.background( 0, 0, 0, 255 )

----------------------------------------------------
function loop()
	-- activate to know fps 
	--window.title( window.get_framerate().."f | "..title )

    layer.open()
        rl.clear(0,0,0,0)
    layer.close() 

	layer.select("def")
    frag.apply( "glsl" )

	if key.pressed( key.s ) then 

R shadercam/main.lua => glsl_cam/main.lua +27 -24
@@ 1,40 1,43 @@

require "strict"

-- settings ---------
local camw = 640
local camh = 480 

-- variables --------
local numsaved = 0
local freeze = 0

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

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 )
if args.count() > 0 then 
	-- TODO: compare arg to ".frag" here 
    frag.load( args.get(0), "glsl" ) 
	title =  args.get(1)
    window.title( title )
else
	window.size( camw, camh )
	layer.create( "def", camw, camh, 1 )
	window.quit()
end
  
local w = args.get_number( "-w", 640) 
local h = args.get_number( "-h", 480)
local m = args.get_number( "-m", 1)
local o = m
if m < 1 then m = 1 end
window.size( w*m, h*m )
layer.create( "def", w, h, o )

local px = args.get_number( "-x", -1)
local py = args.get_number( "-y", -1)

if px >= 0 and py >= 0 then 
	window.move( px, py )
end

if args.count() > 7 then
	window.move( tonumber(args.get(6)), tonumber(args.get(7)) )
end 
local dev = args.get_string( "-d", "/dev/video0" )

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

cam.open(args.get(2), camw, camh )
cam.open( dev, w, h )

-- variables --------
local numsaved = 0
local freeze = 0

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

R shaderdrop/main.lua => glsl_drop/main.lua +19 -18
@@ 5,28 5,27 @@ require "strict"
window.title( " " )

if args.count() > 0 then 
	-- TODO: compare arg to ".frag" here 
    frag.load( args.get(0), "glsl" ) 
end    
	title =  args.get(1)
    window.title( title )
else
	window.quit()
end
  
if args.count() > 1 then 
    window.title( args.get(1) )
end  

local w = 480 
local h = 480
local w = args.get_number( "-w", 480) 
local h = args.get_number( "-h", 480)
local m = args.get_number( "-m", 1)
local o = m
if m < 1 then m = 1 end
window.size( w*m, h*m )
layer.create( "def", w, h, o )

if args.count() > 3 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
end
local px = args.get_number( "-x", -1)
local py = args.get_number( "-y", -1)

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 )
if px >= 0 and py >= 0 then 
	window.move( px, py )
end

png.align_center()


@@ 35,6 34,8 @@ png.load( "tests" )
local blackground = true
local clock = 60

window.background( 0, 0, 0, 255 )

----------------------------------------------------
function loop()
    frag.apply( "glsl" )

R shaderdrop/tests/.gitkeep => glsl_drop/tests/.gitkeep +0 -0

R shaderdrop/tests/frame_002.png => glsl_drop/tests/frame_002.png +0 -0

R shaderdrop/tests/frame_003.png => glsl_drop/tests/frame_003.png +0 -0

R shaderdrop/tests/frame_004.png => glsl_drop/tests/frame_004.png +0 -0

R shader_gif/main.lua => glsl_gif/main.lua +22 -20
@@ 3,25 3,31 @@ require "strict"

----------------------------------------------------
if args.count() > 0 then 
	-- TODO: compare arg to ".frag" here 
    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() > 5 then
	w = tonumber( args.get(2) )
	h = tonumber( args.get(3) )
	fps = tonumber( args.get(4) )
	sec = tonumber( args.get(5) )
	title =  args.get(1)
    window.title( title )
else
	window.quit()
end
  
local w = args.get_number( "-w", 480) 
local h = args.get_number( "-h", 480)
local m = args.get_number( "-m", 1)
local o = m
if m < 1 then m = 1 end
window.size( w*m, h*m )
layer.create( "def", w, h, o )

local px = args.get_number( "-x", -1)
local py = args.get_number( "-y", -1)

if px >= 0 and py >= 0 then 
	window.move( px, py )
end

window.size( w, h )
layer.create( "def", w, h, 1 )
local fps =  args.get_number( "-f", 60)
local sec =  args.get_number( "-s", 2)

local count = 0
local step = 1.0 / fps


@@ 32,10 38,6 @@ function loop()
	local t = count * step 
	clock.set( t ) 	

    layer.open()
        rl.clear(0,0,0,0)
    layer.close() 

    frag.apply( "glsl" )

	if count < frames then