We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm in a processing class and I'm terrible at it.
float spacing, x, y, diameter;
import processing.pdf.*;
boolean saveOneFrame = false;
void setup(){
size(720, 720);
spacing=width/6;
frameRate(2);
}
void draw(){
if(saveOneFrame == true){
beginRecord(PDF, "Dots-####.pdf");
}
background(255);
fill(0);
noStroke();
translate(width/6, height/6);
for(int dotX=0; dotX<5; dotX ++){
for(int dotY=0; dotY<5; dotY ++){
x= dotX*spacing;
y= dotY*spacing;
//diameter=60;
//diameter=60+dotX*20;
//diameter= 60+dotY*20;
//diameter= 20+dotX*20 +dotY*20;
diameter= random(20+60);
// diameter= 60+dist(x+spacing, y+spacing, mouseX, mouseY)/4;
//diameter= 20-dist(x+spacing, y+spacing, mouseX, mouseY)/6;
//noLoop();
ellipse(x, y, diameter, diameter);
}
}
if(saveOneFrame == true){
endRecord();
saveOneFrame = false;
}
}
void mousePressed(){
saveOneFrame = true;
}
Answers
https://forum.Processing.org/two/discussions/tagged?Tag=beginrecord()
By "change this to lines" do you mean that you want to change this:
to drawing a line, e.g. using the
line()
function?https://forum.processing.org/two/discussion/18509/how-can-i-change-the-circles-to-triangles
First we changed from circles to triangles. Now we're changing from circles to lines?
Oh dear. See, when I gave you an answer before, and you accepted it, I assumed that you understood that by CHANGING THE CODE I had also CHANGED WHAT THE SKETCH DID.
The are like, related.
So if you want to CHANGE WHAT THE SKETCH DOES, that means that you are going to have to CHANGE SOME CODE.
What code do you change? Well, you first need to understand what your code does. Hopefully you can determine which line of code it is that draws the circles. HINT: It's the line of code I changed before to draw triangles instead.
Once you have found the code that draws the circles, change it to draw lines.
Seriously now, UNDERSTAND the code. That you have failed to do this so far is obviously the cause for why you're doing so terrible at it.
Then try to make the change yourself. Post the code of your attempt for more help.
@Franz654 --
Try reading the code -- slowly -- and following what is happening where. Then you will know how to change it.
setup()
, which sets everything up...frameRate(2)
means that draw will get called twice a seconddraw()
is being called (twice a second) for as long as the sketch runsmousePressed()
) it sets a variablesaveOnFrame
totrue
. If when draw happens (twice a second!) it sees that variable is true, it starts writing a PDF at the beginning, then saves the PDF at the end. You could instead make your mouse do something else (or additionally do something else).Programming isn't like memorizing a big long list of words -- most of it is about learning grammar. Once you begin to learn how things work in general, you can find where unfamiliar words are, what they are, learn new words, and substitute old things for new things to make changes. Check out the introductory tutorials.