Hi there! I am trying to draw something as this made by hand circles with processing. I know this two ways, but deforming an ellipse is still too geometric and rounded corners of a rect is not bad but not as spontaneous as the doodle that I am sending. So is there another way to deform a circle to make it really natural?
Now I would like to draw a loop of concentric circles, so I have created a function with the organic shape. But I don’t even know if it is working because I don’t see it anymore. Could you please help me?
float noiseMax = 0.7;
void setup() {
size(1000,1000);
}
void drawCircle(float i, float j){
translate(width/2, height/2);
stroke(0,0,0);
noFill();
beginShape();
for (float a=0; a<TWO_PI; a+=0.1){
float xoff=map(cos(a),-1,1,0,noiseMax);
float yoff=map(sin(a),-1,1,0,noiseMax);
float r= map(noise(xoff,yoff),0,1,i,j);
float x = r * cos(a);
float y = r * sin(a);
vertex(x,y);
}
endShape(CLOSE);
//noLoop();
}
void draw() {
background(255,255,255);
for (float i=0; i<100; i+=5){
for (float j=0; j<100; j+=5){
drawCircle(i,j);
}
}
}
Noise is making these circles like circles made by humans, but it is also making every circle similar to closer one. And I was actually looking for independent concentric circles, as if they would be drawn by hand, like in this doodle:
Each circle is tracing out a circular path through the noise. If you don’t want the circles correlated, pick a random point to circle around. noise() is symmetric about the origin so to avoid that, I move everything over by 2000 in addition to adding a random amount.
I am trying some different options about color. I have thought about a gradient. So I have typed this sketch to make it simpler, trying to create a gradient in a loop. But it only works when I use the same variable in color that I have used to multiply lines , It does not work if I try to use another variable with other values.
size(500,500);
strokeWeight(5);
colorMode(HSB,360,100,100);
for (int i =0; i <500; i+=20){
//for(int j=100; i<300; i+=1){
stroke(i);
line(i,0,i,500);
}
//}
well, thank you so much again, @scudly , your code produces amazing results : D
I have typed a line to see different designs pressing enter and I have discovered that all of them work really good as a stop motion, if you see one every second or half a second. How could I make and export an infinite loop with, for example, 10 designs restarting again and again?
float noiseScale = 0.002;
void setup() {
size(1000,1000);
noLoop();
}
void drawCircle( float innerR, float outerR ){
noFill();
float rx = random(2000), ry = random(2000);
beginShape();
for( float i=0; i<360; i++ ) {
float a = TAU*i/360;
float xoff = 2000 + rx + innerR * noiseScale * cos(a);
float yoff = 2000 + ry + innerR * noiseScale * sin(a);
float r = innerR + (outerR-innerR) * noise( xoff, yoff );
float x = r * cos(a);
float y = r * sin(a);
vertex(x,y);
}
endShape(CLOSE);
}
void draw() {
color a = color(204,255,255);
color b = color(204,153,255);
color c = color(255,0,102);
translate(width/2, height/2);
background(255,255,255);
for (float i=-40; i<400; i+=1) {
float u = 1.*i/450;
//middle
stroke(b);
//inside
if( random(1) > u ) { stroke(a); }
//outside
else if( random(1) < u*u ) { stroke(c); }
drawCircle(i,i+100);
}
}
void keyPressed() {
if( keyCode == ENTER ) draw();
else if( key == '+' ) saveFrame();
redraw();
}
We are using both random() and noise() so to repeat, we need to set both randomSeed() and noiseSeed() to get a repeating set of values. Both of those take integers whereas random() gives us a float so I have to scale it up and cast to an int. floats only have 24 bits of precision, so to keep it uniform, I only sample from 2**24 values (the 1<<24 part). Each time through draw(), I initialize the random stream with the next random seed and then use its first value to initialize the noiseSeed value as well.
float noiseScale = 0.002;
int repeatCount = 10;
int baseSeed;
void setup() {
size(1000,1000);
noLoop();
baseSeed = int(random(1<<24));
}
void drawCircle( float innerR, float outerR ){
noFill();
float rx = random(2000), ry = random(2000);
beginShape();
for( float i=0; i<360; i++ ) {
float a = TAU*i/360;
float xoff = 2000 + rx + innerR * noiseScale * cos(a);
float yoff = 2000 + ry + innerR * noiseScale * sin(a);
float r = innerR + (outerR-innerR) * noise( xoff, yoff );
float x = r * cos(a);
float y = r * sin(a);
vertex(x,y);
}
endShape(CLOSE);
}
void draw() {
randomSeed( baseSeed + (frameCount % repeatCount) );
noiseSeed( int(random(1<<24)) );
color a = color(204,255,255);
color b = color(204,153,255);
color c = color(255,0,102);
translate(width/2, height/2);
background(255,255,255);
for (float i=-40; i<400; i+=1) {
float u = 1.*i/450;
//middle
stroke(b);
//inside
if( random(1) > u ) { stroke(a); }
//outside
else if( random(1) < u*u ) { stroke(c); }
drawCircle(i,i+100);
}
}
void keyPressed() {
if( keyCode == ENTER ) draw();
else if( key == '+' ) saveFrame();
redraw();
}