Skip to content

Instantly share code, notes, and snippets.

@jimmybot
Created August 31, 2015 20:38
Show Gist options
  • Save jimmybot/b6519946899e0871f01b to your computer and use it in GitHub Desktop.
Save jimmybot/b6519946899e0871f01b to your computer and use it in GitHub Desktop.
void setup() {
size(600, 600);
smooth();
background(255);
fill(255);
stroke(100, 100);
PFont fontA = loadFont("courier");
textFont(fontA, 14);
noLoop();
}
float t = 0;
void drawRandom(t) {
float x = map(t % 1, 0, 1, 0, width);
float y = random(0, height);
stroke(#00FF00, 100);
ellipse(x, y, 16, 16);
}
void drawPerlin(t) {
float x = map(t % 1, 0, 1, 0, width);
float y = map(noise(t), 0, 1, 0, height);
stroke(100, 100);
ellipse(x, y, 16, 16);
}
var top = 600;
var p_min = top;
var p_max = 0;
void draw() {
//drawRandom(t);
//drawPerlin(t);
for (var i=0; i<1000000; i++) {
float y = map(noise(t), 0, 1, 0, top);
if (y < p_min) {
p_min = y;
} else if (y > p_max) {
p_max = y;
}
t += 0.01;
}
console.log("width: "+ width);
console.log("height: "+ height);
console.log("max: "+p_max);
console.log("min: "+p_min);
}
/*
function random_array(end) {
var numbers = [];
var randomized = [];
var r;
for (var i = 0; i < end; i++) {
numbers.push(i);
}
for (var i = 0; i < end - 1; i++) {
var j = end - i - 1;
r = int(random(j));
randomized.push(numbers[r]);
numbers[r] = numbers[j];
}
randomized.push(numbers[0]);
return randomized;
}
void draw() {
var starts = random_array(width);
var last_x1 = 0;
var last_x2 = 0;
for (int i = 0; i < width; i++) {
int r = int(random(128) + i/width*128);
int x2 = int(random(0, width));
if (x2 > starts[i]) {
stroke(color(96,r,96), 60);
} else {
stroke(color(96,96,r), 60);
}
stroke(color(48, 255-i/width*255, i/width*255), 10);
x1 = (last_x1*9 + starts[i]) / 10;
x2 = (last_x2*9 + x2) / 10;
last_x1 = x1;
last_x2 = x2;
line(x1, 0, x2, height);
}
}
void draw() {
int x;
float r;
for (int i = 0; i < width*2; i++) {
stroke(color(i/width*255), 10);
r = noise(i * 0.005 + 10000.0);
x = map(r, 0, 1, 0, width);
line(x, 0, x, height);
console.log(i * 0.005 + 10000.0, r);
}
}*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment