Skip to content

Instantly share code, notes, and snippets.

@alblaine
Forked from hyounggyu/p5js-redis-example.html
Created December 9, 2015 14:05
Show Gist options
  • Save alblaine/3f8b6126dfbb5f681909 to your computer and use it in GitHub Desktop.
Save alblaine/3f8b6126dfbb5f681909 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<script src="p5.js"></script>
<script>
var img;
function setup() {
createCanvas(600,600);
img = createImage(1372,1332,RGB);
var client = require('redis').createClient();
client.on("error", function (err) {
console.log("error event - " + client.host + ":" + client.port + " - " + err);
});
client.get("test:im:1", function (err, reply) {
img.loadPixels();
data = JSON.parse(reply);
for (var idx = 0; idx < img.pixels.length; idx++) {
img.pixels[idx] = color(data[idx]/20.0,data[idx]/20.0,data[idx]/20.0);
}
console.log(img.pixels[0]);
img.updatePixels();
});
client.quit(function (err, res) {
console.log("Exiting from quit command.");
});
}
function draw() {
image(img, 0, 0);
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment