High level utils + addon echosystems
import { create } from 'diffyjs';
const diffy = create({
resolution: { x: 15, y: 10 },
sensitivity: 0.2,
threshold: 25,
debug: true,
containerClassName: 'my-diffy-container',
sourceDimensions: { w: 130, h: 100 },
onFrame: (matrix) => { /* good things */ }
});
compare(frame1, frame2) {
const data1 = frame1.data;
const data2 = frame2.data;
const length = data1.length;
const buffer = new ArrayBuffer(length);
this.worker.postMessage({
buffer,
data1,
data2,
sensitivity: this.sensitivity,
threshold: this.threshold,
width: this.sourceWidth,
height: this.sourceHeight
});
}
drawBlendImageFromBuffer(buffer) {
this.blendImageData
.data
.set(
new Uint8ClampedArray(buffer)
);
this.blendCanvasCtx.putImageData(this.blendImageData, 0, 0);
this.previousImageData = this.currentImageData;
}
// bitwise Math.round
export const round = (number) => (number + .5) >> 0;
// butwise Math.abs
export const abs = (value) => (value ^ (value >> 31)) - (value >> 31);
import Diffy from 'diffy-react'
<Diffy
resolution = {{ x: 15, y: 10 }}
sensitivity = { 0.2 },
threshold = { 25 },
debug = {true },
containerClassName = "my-diffy-container"
sourceDimensions = {{ w: 130, h: 100 }}
onFrame = { (matrix) => { /* good things */}} />
// Creates a WebMonkeys object
const monkeys = require("WebMonkeys")(); // on the browser, call WebMonkeys() instead
// Sends an array of numbers to the GPU
monkeys.set("nums", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
// Employs 16 monkeys to work in parallel on the task of squaring each number
monkeys.work(16, "nums(i) := nums(i) * nums(i);");
// Receives the result back
console.log(monkeys.get("nums"));
// output: [ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256 ]
Code is only half the work.
Documentation is what makes or breaks good software.
So I got to work.
An interactive WebVR narrative about the future
of surveillance and privacy
A collaboration with Caroline Sinders
We hypothesized the future of
the regulated Web and interconnected life
Thank you!
Mani Nilchiani, March 2017
mani.io