#N canvas 720 165 701 546 10; #X obj 280 346 ofelia define -k \$0-video; #A __set if type(window) ~= "userdata" then \; window = ofWindow() \; end \; \; local canvas = ofCanvas(this) \; local clock = ofClock(this \, "setup") \; local shaderDir = canvas:getDir() .. "/data/" \; local videoPlayer = ofVideoPlayer() \; local number = 0 \; local frames = {} \; local images = {} \; local N = 50 \; for i = 1 \, N do \; images[i] = ofImage() \; end \; \; function M.new() \; ofWindow.addListener("setup" \, this) \; ofWindow.addListener("update" \, this) \; ofWindow.addListener("draw" \, this) \; ofWindow.addListener("exit" \, this) \; window:setPosition(50 \, 100) \; window:setSize(800 + 40 \, 600 + 40) \; if ofWindow.exists then \; clock:delay(0) \; else \; window:create() \; end \; end \; \; function M.free() \; window:destroy() \; ofWindow.removeListener("setup" \, this) \; ofWindow.removeListener("update" \, this) \; ofWindow.removeListener("draw" \, this) \; ofWindow.removeListener("exit" \, this) \; end \; \; function M.setup() \; ofSetWindowTitle("Video Player") \; ofBackground(0 \, 0 \, 0 \, 255) \; videoPlayer:load(shaderDir .. "fingers.webm") \; videoPlayer:setLoopState(OF_LOOP_NORMAL) \; end \; \; function M.moviefile(path) \; videoPlayer:load(path) \; end \; \; function M.setSpeed(f) \; videoPlayer:setSpeed(f / 100) \; end \; \; function ofelia.play() \; videoPlayer:play() \; end \; \; function ofelia.stop() \; videoPlayer:setFrame(0) \; videoPlayer:setPaused(true) \; end \; \; function M.setPaused(f) \; if f == 1 then pause = true \; else pause = false \; end \; videoPlayer:setPaused(pause) \; end \; \; function M.setFrame(f) \; videoPlayer:setFrame(f) \; end \; \; function M.setPosition(f) \; videoPlayer:setPosition(f) \; end \; \; function M.setVolume(f) \; videoPlayer:setVolume(f / 100) \; end \; \; function M.update() \; videoPlayer:update() \; if videoPlayer:isFrameNew() then \; number = (number + 1) % N \; print(number + 1) \; images[number + 1]:setFromPixels(videoPlayer:getPixels()) \; table.insert(frames \, 1 \, images[number + 1]) \; if #frames > N then \; table.remove(frames) \; end \; end \; end \; \; function M.draw() \; ofSetHexColor(0xFFFFFF) \; if #frames == N then \; for i = 1 \, videoPlayer:getHeight() / M.slit do \; frames[i % N + 1]:drawSubsection(20 \, 20 + (i - 1) * M.slit \, videoPlayer:getWidth() \, M.slit \, 0 \, (i - 1) * M.slit) \; end \; end \; end \; \; function M.exit() \; videoPlayer:close() \; for i = 1 \, N do \; images[i]:clear() \; end \; end \;; #X obj 331 114 openpanel; #X obj 331 94 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 331 135 moviefile \$1; #X msg 280 80 play; #X msg 296 110 stop; #X floatatom 555 138 5 0 0 0 - - -; #X floatatom 191 149 5 0 0 0 - - -; #X msg 555 117 100; #X obj 555 96 loadbang; #X obj 335 160 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 56 119 metro 40; #X obj 56 141 f; #X obj 56 99 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 ; #X msg 464 146 setVolume \$1; #X floatatom 464 126 5 0 100 0 - - -; #X obj 464 84 loadbang; #X obj 283 466 hsl 128 15 0 1 0 0 empty empty getPosition -2 -8 0 10 -257985 -1 -1 0 1; #X msg 56 260 setPosition \$1; #X obj 59 240 hsl 128 15 0 1 0 0 empty empty setPosition -2 -8 0 10 -257985 -1 -1 0 1; #X obj 280 398 unpack f f f; #X floatatom 280 419 5 0 0 3 pos - -; #X floatatom 314 419 5 0 0 3 frame - -; #X floatatom 349 419 8 0 0 0 - - -; #X obj 56 204 /; #X obj 113 79 hsl 128 15 -1000 1000 0 1 empty empty speed -2 -8 0 10 -257985 -1 -1 5800 1; #X obj 83 141 + 100; #X obj 56 162 / 100; #X obj 137 120 * 100; #X obj 122 141 mod; #X obj 349 440 s \$0-tFrameNum; #X obj 71 183 r \$0-tFrameNum; #X obj 137 99 r \$0-tFrameNum; #X msg 555 157 setSpeed \$1; #X msg 335 180 setPaused \$1; #X msg 191 169 setFrame \$1; #X msg 464 105 50; #X obj 252 22 loadbang; #X msg 483 299 slit \$1; #X obj 483 272 nbx 5 14 1 50 0 1 empty empty empty 0 -8 0 10 -257985 -1 -1 12 256; #X obj 264 48 del 20; #X connect 0 0 20 0; #X connect 1 0 3 0; #X connect 2 0 1 0; #X connect 3 0 0 0; #X connect 4 0 0 0; #X connect 5 0 0 0; #X connect 6 0 33 0; #X connect 7 0 35 0; #X connect 9 0 8 0; #X connect 10 0 34 0; #X connect 11 0 12 0; #X connect 12 0 26 0; #X connect 12 0 27 0; #X connect 13 0 11 0; #X connect 14 0 0 0; #X connect 15 0 14 0; #X connect 16 0 36 0; #X connect 18 0 0 0; #X connect 19 0 18 0; #X connect 20 0 21 0; #X connect 20 1 22 0; #X connect 20 2 23 0; #X connect 21 0 17 0; #X connect 23 0 30 0; #X connect 24 0 19 0; #X connect 25 0 26 1; #X connect 26 0 29 0; #X connect 27 0 24 0; #X connect 28 0 29 1; #X connect 29 0 12 1; #X connect 31 0 24 1; #X connect 32 0 28 0; #X connect 33 0 0 0; #X connect 34 0 0 0; #X connect 35 0 0 0; #X connect 37 0 40 0; #X connect 38 0 0 0; #X connect 39 0 38 0; #X connect 40 0 4 0;