aboutsummaryrefslogtreecommitdiff
path: root/chuck
diff options
context:
space:
mode:
Diffstat (limited to 'chuck')
-rw-r--r--chuck/OSCGraphics.ck2
-rw-r--r--chuck/OSCGraphicsLayer.ck45
-rw-r--r--chuck/OSCGraphicsPort.ck19
-rw-r--r--chuck/lib.ck1
4 files changed, 53 insertions, 14 deletions
diff --git a/chuck/OSCGraphics.ck b/chuck/OSCGraphics.ck
index 603706f..626c92d 100644
--- a/chuck/OSCGraphics.ck
+++ b/chuck/OSCGraphics.ck
@@ -92,7 +92,7 @@ public class OSCGraphics {
OSCGraphicsBox box;
box.init(osc_send, "box", "iiif", pos, "__box_"+free_id, geo);
- for (0 => int i; i < color.cap(); i++)
+ for (0 => int i; i < 3; i++)
color[i] => osc_send.addInt;
opacity => osc_send.addFloat;
diff --git a/chuck/OSCGraphicsLayer.ck b/chuck/OSCGraphicsLayer.ck
index 2e3ae76..ffd7fe7 100644
--- a/chuck/OSCGraphicsLayer.ck
+++ b/chuck/OSCGraphicsLayer.ck
@@ -15,10 +15,33 @@ public class OSCGraphicsLayer {
osc_send.startMsg("/layer/new/"+type, "isiiii"+osc_types);
pos => osc_send.addInt;
name => osc_send.addString;
- for (0 => int i; i < geo.cap(); i++)
+ for (0 => int i; i < 4; i++)
geo[i] => osc_send.addInt;
}
+ class GeoPort extends OSCGraphicsPort {
+ OSCGraphicsLayer @layer;
+
+ int geo[];
+ int index;
+
+ fun void
+ tick(float in)
+ {
+ in $ int => geo[index];
+ geo => layer.geo;
+ }
+ }
+ fun OSCGraphicsPort @
+ getGeoPort(int geo[], int index)
+ {
+ GeoPort p;
+ this @=> p.layer;
+ geo @=> p.geo;
+ index => p.index;
+
+ return p;
+ }
fun int[]
geo(int geo[])
{
@@ -26,7 +49,7 @@ public class OSCGraphicsLayer {
[0, 0, 0, 0] @=> geo;
osc_send.startMsg("/layer/"+name+"/geo", "iiii");
- for (0 => int i; i < geo.cap(); i++)
+ for (0 => int i; i < 4; i++)
geo[i] => osc_send.addInt;
return geo;
@@ -37,25 +60,21 @@ public class OSCGraphicsLayer {
return geo(null);
}
- class AlphaPort extends Chubgraph {
- inlet => blackhole;
- inlet => outlet;
+ class AlphaPort extends OSCGraphicsPort {
+ OSCGraphicsLayer @layer;
fun void
- poll(OSCGraphicsLayer @layer)
+ tick(float in)
{
- inlet.last() => float prev;
-
- while (50::ms => now)
- if (inlet.last() != prev)
- inlet.last() => layer.alpha => prev;
+ in => layer.alpha;
}
}
- fun UGen @
+ fun OSCGraphicsPort @
getAlphaPort()
{
AlphaPort p;
- spork ~ p.poll(this);
+ this @=> p.layer;
+
return p;
}
fun float
diff --git a/chuck/OSCGraphicsPort.ck b/chuck/OSCGraphicsPort.ck
new file mode 100644
index 0000000..b633aac
--- /dev/null
+++ b/chuck/OSCGraphicsPort.ck
@@ -0,0 +1,19 @@
+public class OSCGraphicsPort extends Chubgraph {
+ inlet => blackhole;
+ inlet => outlet;
+
+ 50::ms => dur poll_interval;
+
+ fun void tick(float in) {}
+
+ fun void
+ poll()
+ {
+ inlet.last() => float prev;
+
+ while (poll_interval => now)
+ if (inlet.last() != prev)
+ inlet.last() => prev => tick;
+ }
+ spork ~ poll();
+}
diff --git a/chuck/lib.ck b/chuck/lib.ck
index a94550e..e73ab98 100644
--- a/chuck/lib.ck
+++ b/chuck/lib.ck
@@ -2,6 +2,7 @@
prefix+"/share/osc-graphics/chuck" => string path;
+path+"/OSCGraphicsPort.ck" => Machine.add;
path+"/OSCGraphicsLayer.ck" => Machine.add;
path+"/OSCGraphicsImage.ck" => Machine.add;
path+"/OSCGraphicsVideo.ck" => Machine.add;