Skip to content

Instantly share code, notes, and snippets.

@gcusso
Forked from anonymous/options.json
Created December 8, 2012 10:23
Show Gist options
  • Save gcusso/4239707 to your computer and use it in GitHub Desktop.
Save gcusso/4239707 to your computer and use it in GitHub Desktop.
{
"libraries": [
"Processing"
],
"mode": "javascript",
"layout": "fullscreen mode (vertical)"
}
pre {
position: absolute;
color: #FFF;
background: #000;
}
<canvas></canvas>
var numberOfIterations = 10000;
// walker prototype
var particle = {
x: null,
y: null,
init: function(startX, startY)
{
this.x = startX;
this.y = startY;
},
display: function(p)
{
p.stroke(0);
p.point(this.x, this.y);
},
step: function(p)
{
this.x += rand() * 2 - 1;
this.y += rand() * 2 - 1;
}
};
function Walker(x, y)
{
function F() {};
F.prototype = particle;
var f = new F();
f.init(x, y);
return f;
}
var x = 520;
var y = 500;
var a = 0;
var tam = 21.5;
// processing sketch
function sketch(p)
{
var walker;
p.setup = function()
{
p.size($(window).width()*0.99, $(window).height()*0.99);
p.background(245);
};
p.draw = function()
{
//p.background(245);
p.fill(30);
p.strokeWeight(0.9);
p.stroke(120,0,120);
x = 300 + p.cos(a) * 100;
y = 300 + p.tan(a) * 100;
a += 0.011;
p.ellipse(x,y,tam,tam);
}
}
var canvas = $('canvas').get(0);
var processingInstance = new Processing(canvas, sketch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment