Lua Code {3}: es.matrix.lua
Description: Patch and lua code for
importing images in matrices with jit.gl.lua
-- lua code (())_n
autogarbage = 1
autowatch = 1
gc = 1
vmatrix = {}
vmatrixnum = 0
current = 0
function bang()
current = current + 1
if (current > vmatrixnum) then
current = 1
end
if (vmatrixnum > 0) then
outlet(0, "jit_matrix", vmatrix[current].name)
end
end
function play(i)
if (i <= vmatrixnum) then
outlet(0, "jit_matrix", vmatrix[i].name)
end
end
function read(a)
local temp = vmatrixnum + 1
vmatrix[temp] = jit.matrix(4, "char", 320, 240)
vmatrix[temp].adapt = 1
vmatrix[temp]:importmovie(a)
vmatrixnum = temp
end
function path(b)
vmatrixnum = 0
current = 0
vmatrix = {}
vpath = b
end
function readfolder(c)
local temp = vmatrixnum + 1
vmatrix[temp] = jit.matrix(4, "char", 320, 240)
vmatrix[temp].adapt = 1
vmatrix[temp]:importmovie(vpath..c)
vmatrixnum = temp
end
function clear()
vmatrixnum = 0
current = 0
vmatrix = {}
end
Lua Code {2}: es.play.lua
Description: Patch and lua code for
playing movies with jit.gl.lua
-- lua code (())_n
autogarbage = 1
autowatch = 1
gc = 1
function script_load()
vmovie = jit.new("jit.qt.movie")
vmovie.colormode = "uyvy"
vmovie.adapt = 1
vplane = jit.new("jit.gl.videoplane", this.drawto)
vplane.colormode = "uyvy"
vplane.automatic = 0
vplane.scale = {1.333, 1., 1.}
vframe = jit.matrix(4, "char", 320, 240)
vframe.adapt = 1
end
function read(a)
vmovie:read(a)
end
function bang()
if (vmovie.framecount > 0) then
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end
end
function draw()
if (vmovie.framecount > 0) then
vmovie:matrixcalc(vframe.name, vframe.name)
vplane:jit_matrix(vframe.name)
vplane:draw()
end
end
Lua Code {1}: es.gencoord.lua
Description: Patch and lua code for
generating matrix of coordinates with jit.gl.lua
-- lua code (())_n
autogarbage = 1
autowatch = 1
gc = 1
points = 50
function bang()
makepoints()
end
-- generate points
function makepoints()
local vpoint = jit.matrix(2, "float32", points, points)
local vexpr = jit.new("jit.expr")
vexpr.expr = {"norm[0]", "norm[1]"}
vexpr.inputs = 1
vexpr.type = "float32"
vexpr:matrixcalc(vpoint.name, vpoint.name)
outlet(0, "jit_matrix", vpoint.name)
end
-- set the dimensions of the matrix
function dim(x)
points = x
end