Skip to content

Instantly share code, notes, and snippets.

@erikjms
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikjms/7cd635d0c90eac7895b4 to your computer and use it in GitHub Desktop.
Save erikjms/7cd635d0c90eac7895b4 to your computer and use it in GitHub Desktop.
Example for using Iterator class from Iterator.pde
// ok let's see what happens
// this is my default color block
// not all colors may be used in any particular sketch
color nearBlack = color(11,11,18,255);
color darkBGray = color(43,49,55,255);
color lightBGray = color(143,149,165,255);
color skyBlue = color(38,178,238,45);
color vViolet = color(155,74,237,95);
color vYellow = color(255, 255, 0, 255);
// until I figure out how to change values inside a color object
// noisy variation will have to be done directly on rgb values
// which are then reassembled in the Iterator.noiseColor() method
// and returned as a color
// so this is skyBlue in the raw:
/*
int red = 38;
int green = 178;
int blue = 238;
int alpha = 45;
*/
int red = int(random(45,255));
int green = int(random(45,255));
int blue = int(random(45,255));
int alpha = 31;
color pointColor = color(red, green, blue, alpha);
// for label font
//PFont font;
Iterator iter;
// number of points to iterate over per draw() loop
// will be chosen randomly from range (c0-cn, x0-xn)
// this number increments relatively quickly
//int generations = 5000;
int generations = 20000;
// how many times to iterate f(x) before graphing (c, x)
int iterations = 600;
//int iterations = 300;
// int iterations = 200;
// int iterations = 100;
// // these are too low for more than testing for most functions
//int iterations = 50;
//int iterations = 25;
// range for konstant
float k0 = -0.1;
float kn = 2.751;
float expn = random(-2.1, 2.1);
// ranges for x and c
// large starting pool to survey results
// float x0 = -2.85;
// float c0 = -2.85;
// float xn = 2.85;
// float cn = 2.85;
// // values to mess with
float x0 = -0.51;
float c0 = -11.5;
float xn = 0.52;
float cn = 0.1;
/*
// shows whole of interesting part of x -> x^2 + c
float x0 = -2.0;
float c0 = -2.25;
float xn = 2.25;
float cn = 0.5;
*/
int count = 0;
int totalPoints = 0;
/*// debug draw
int pw = 2;
int ph = 2;
*/
String path = "~/Dropbox/programming/seehear/_images/iteratefx02/";
void setup(){
size(1910, 1030);
background(nearBlack);
//slower framerate in setup() for more time to see.
//frameRate(30);
iter = new Iterator(generations, iterations, expn, x0, xn, c0, cn, k0, kn);
// iter.initExp(n0, nn, true);
iter.startNoise();
// uncomment for graph lines through origin (0,0)
// stroke(darkBGray);
// iter.drawGraph();
// font for label
//font = loadFont("SquareShooterMono48.vlw");
}
void draw(){
smooth();
/* debug */
// stroke(vYellow);
// point(width/pw, height/2);
// point(width/2, height/ph);
// pw++;
// ph++;
stroke(pointColor);
noFill();
iter.iterate();
// this iteration of Iterator does not have this Noisy Method yet!
// iter.iterateWithNoisyExponent();
// draw label
/*
textFont(font, 36);
textAlign(CENTER);
totalPoints += generations;
String tPoints = str(totalPoints);
float stringW = textWidth(tPoints);
fill(nearBlack);
noStroke();
// args for rect(startx, starty, width, height)
rect((width/2)-(stringW/2), height-(100+36), stringW,36);
fill(lightBGray);
text(tPoints, width/2, height-100);
*/
// get new color
iter.noisePlease();
pointColor = iter.noiseColor(red, green, blue, alpha);
if((frameCount % 1000) == 0){
String filename = path + "fx02.0" + frameCount + ".png";
save(filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment