aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgeremy2015-01-04 12:48:54 -0800
committergeremy2015-01-04 12:48:54 -0800
commit58e1dfb07c35ce00ba11e6cd783a004f7cf2224c (patch)
tree1a115338c950e91f5263226653c54c8ada8d4831
parent4a40d61925a8154e1939ddd24324761401bc876b (diff)
downloadpubnub-python-58e1dfb07c35ce00ba11e6cd783a004f7cf2224c.tar.bz2
adding 1st version of wave viz
-rw-r--r--python/examples/futureHouse/.gitignore2
-rw-r--r--python/examples/futureHouse/waveViz.html21
-rw-r--r--python/examples/futureHouse/waveViz.js128
3 files changed, 151 insertions, 0 deletions
diff --git a/python/examples/futureHouse/.gitignore b/python/examples/futureHouse/.gitignore
new file mode 100644
index 0000000..c38fa4e
--- /dev/null
+++ b/python/examples/futureHouse/.gitignore
@@ -0,0 +1,2 @@
+.idea
+*.iml
diff --git a/python/examples/futureHouse/waveViz.html b/python/examples/futureHouse/waveViz.html
new file mode 100644
index 0000000..b63b638
--- /dev/null
+++ b/python/examples/futureHouse/waveViz.html
@@ -0,0 +1,21 @@
+
+<html>
+<body>
+<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
+<script src="waveViz.js"></script>
+
+<canvas id="canvas"></canvas>
+
+
+<label>maxPulseLength (0-4096)</label>
+<input type="text" name="maxPulseLength">
+<label>minPulseLength (0-4096)</label>
+<input name="minPulseLength">
+<br/>
+<label>waitFloor (0-2, should be less than waitCeiling</label>
+<input name="waitFloor">
+<label>waitCeiling (0-2, should be more than waitFloor)</label>
+<input name="waitCeiling">
+
+</body>
+</html>
diff --git a/python/examples/futureHouse/waveViz.js b/python/examples/futureHouse/waveViz.js
new file mode 100644
index 0000000..9ef0bed
--- /dev/null
+++ b/python/examples/futureHouse/waveViz.js
@@ -0,0 +1,128 @@
+/**
+ * Wave oscillators by Ken Fyrstenberg Nilsen
+ * http://abdiassoftware.com/
+ *
+ * CC-Attribute 3.0 License
+ */
+
+
+ $(function() {
+
+ var ctx = canvas.getContext('2d');
+ var w, h;
+
+ canvas.width = w = window.innerWidth * 0.9;
+ canvas.height = h = window.innerHeight * 0.9;
+
+ var osc1 = new osc(400, 100, 0.05);
+ var horizon = h * 0.2; // the bigger this gets, the lower the wave offsets
+ var count = 100; // 40
+ var step = 10; //Math.ceil(w / count);
+ var buffer = new ArrayBuffer(count * 4);
+ var points = new Float32Array(buffer);
+
+// Change wave amplitude
+//osc1.max = 450;
+//osc1.min = -450;
+
+// Change wait time
+//osc1.speed = 0.2
+
+ function fill() {
+ for (var i = 0; i < count; i++) {
+ points[i] = mixer(osc1);
+ }
+ }
+
+ ctx.lineWidth = 5;
+ ctx.strokeStyle = '#ffffff';
+ ctx.fillStyle = 'rgb(50, 50, 80)';
+
+ function loop() {
+
+ var i;
+
+ /// move points to the left
+ for (i = 0; i < count - 1; i++) {
+ points[i] = points[i + 1];
+ }
+
+ /// get a new point
+ points[count - 1] = mixer(osc1) //, osc2, osc3);
+
+ //ctx.clearRect(0, 0, w, h);
+ ctx.fillRect(0, 0, w, h);
+
+ /// render wave
+ ctx.beginPath();
+ ctx.moveTo(0, points[0]);
+
+ for (i = 1; i < count; i++) {
+ ctx.lineTo(i * step, points[i]);
+ }
+
+ ctx.stroke();
+
+ requestAnimationFrame(loop);
+ }
+
+ loop();
+
+/// oscillator object
+ function osc(maxx, minn, spd) {
+
+ this.max = maxx;
+ this.min = minn;
+ this.speed = spd;
+
+ var me = this,
+ a = 0,
+ max = getMax(),
+ min = getMin();
+
+ this.getAmp = function () {
+
+ a += this.speed;
+
+ if (a >= 2.0) {
+ a = 0;
+ }
+
+ //return max * Math.sin(a * Math.PI);
+ return a < 1 ? max : min;
+ }
+
+ function getMax() {
+ return me.max;
+ }
+
+ function getMin() {
+ return me.min;
+ }
+
+ return this;
+ }
+
+ function mixer(osc) {
+
+ var d = arguments.length,
+ i = d,
+ sum = 0;
+
+ if (d < 1) return 0;
+
+ while (i--) sum += arguments[i].getAmp();
+
+ console.log("1: " + osc.getAmp());
+ console.log("2: " + sum);
+ console.log("3: " + d + horizon);
+ console.log("4: " + horizon);
+
+ // return osc.getAmp() + horizon;
+ return sum / d + horizon;
+ //return arguments[i].getAmp() + horizon;
+
+
+ }
+ }
+) \ No newline at end of file