In this sketch we will be handing the drawing responsibilities entirely over to the computer.
We are also adding functionality to Processing by importing a library into our sketch.
We will start at the sketch menu at the top of the screen and select Import Library:
Select PDF Export:
Processing will insert a line at the beginning of your sketch:
import processing.pdf*;
In this sketch we are going to use Perlin noise to inform the random movement of the pen on the screen. We are going to use float, which in Processing is a container (variable) in which you can put numbers and pull them up later.
float perlinPosition = 0;
float perlinSpeed = 0.01;
void setup() {
size(600,600);
background(255);
beginRecord(PDF, "pdf/wheel.pdf"); //begin the PDF renderer record
}
This sketch takes a unique approach to drawing: instead of making us figure out the rotation, we are going to make the "paper" rotate:
void draw() {
translate(width/2, height/2); //moves the point of origin to middle of screen
rotate(frameCount * 0.01); // turn the drawing surface, makes it so you don't have to use sine and cosine aka trigonometry
float armLength = noise(perlinPosition) *200; //define how long the line is drawn by using perlin noise
perlinPosition = perlinPosition + perlinSpeed;
stroke(0,50); //stroke is black then gray
line(0 , 0 , armLength, 0);
ellipse( armLength, 0, 5, 5);
}
#1 - Can you change the color in the wheel to be random?
#2- Can you make the ellipse at the end a rectangle instead? Try changing the color of the rectangle only.