-
Notifications
You must be signed in to change notification settings - Fork 2
/
of.draw.pd
35 lines (35 loc) · 1.85 KB
/
of.draw.pd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#N canvas 512 90 754 688 12;
#X obj 16 701 outlet;
#X obj 16 5 inlet;
#X text 704 698 RI;
#X obj 86 5 inlet;
#X msg 86 26 depth \$1;
#X obj 16 50 ofelia d draw\$0 \; local log = ofLog("ofDraw") \; local
canvas = ofCanvas(this) \; local outlet = ofOutlet(this) \; local order
\, styleAuto \, matrixAuto \, depth \, blend = 1 \, true \, true \,
0 \, 1 \; \; function M.new() \; local args = canvas:getArgs() \; if
#args == 0 then M.float(1 \, 1) \; elseif #args == 1 then M.float(args[1])
\; elseif #args == 2 then \; order \, depth = M.float(args[1]) \, args[2]
\; elseif #args == 3 then \; order \, depth \, blend = M.float(args[1])
\, args[2] \, args[3] \; elseif #args == 4 then \; order \, depth \,
styleAuto \, matrixAuto = M.float(args[1]) \, args[2] ~= 0 \, args[3]
~= 0 \, args[4] ~= 0 \; elseif #args ~= 0 then \; log:error("requires
1 \, 2 or 4 creation arguments") \; end end \; \; function M.float(f)
order = f if order == 0 then ofWindow.removeListener("draw" \, this)
else ofWindow.addListener("draw" \, this \, f) end end \; function
M.styleAuto(b) styleAuto = b ~= 0 end \; function M.matrixAuto(b) matrixAuto
= b ~= 0 end \; \; function M.setAuto(b) \; M.setStyleAuto(b) \; M.setMatrixAuto(b)
end \; function M.depth(f) depth = f end \; function M.blend(f) blend
= f end \; \; function M.free() \; ofWindow.removeListener("draw" \,
this) end \; \; function M.bang() ofPushView() \; _maincamera:beginCamera()
M.draw() ofPopView() _maincamera:endCamera() end \; function M.draw()
\; if depth == 1 then ofSetDepthTest(true) else ofSetDepthTest(false)
end \; if styleAuto then ofPushStyle() end \; if matrixAuto then ofPushMatrix()
end \; ofEnableBlendMode(blend) \; outlet:outletBang(0) if matrixAuto
then ofPopMatrix() end \; if styleAuto then ofPopStyle() ofDisableBlendMode()
\; end end \;;
#X f 101;
#X connect 1 0 5 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 5 0 0 0;