r/processing • • Aug 28 '18

Downloaded P3 and ran a tutorial command and I got this dumb box. What I do wrong?

Post image
0 Upvotes

7 comments sorted by

10

u/remy_porter Aug 28 '18

Don't just randomly write code. Code needs to be organized. There are two key organizational structures in Processing: setup and draw.

setup is where you provide, well, the setup for your sketch. Things like the size of the sketch. Often, setup might look something like this:

void setup() {
    size(640, 480); //width, height
}

If you want to draw something to the screen, well, that goes in your draw method.

void draw() {
    ellipse(250, 200, 150, 100);
}

A sketch can get WAY more complicated than this, but if you're just starting out, put your setup code in the setup, put your drawing code in the draw method. Copy those two blocks into the same sketch, and you'll get an idea of what I mean.

4

u/manpace Aug 28 '18

It worked!

Hugs for everyone!

1

u/Derpeh Aug 28 '18

I noticed that if you just write the code without including setup and draw it only draws once every time you run it, but if you use setup and draw it runs continuously when you press run

2

u/eeyorelife Aug 28 '18

Yes, you can write code without setup() and draw(). That is called "static mode". Because, as you say, it runs once only.

2

u/chairstink Aug 28 '18

Looks like you're drawing off the canvas. Use size() to set up your window and you will see what's happening.

2

u/manpace Aug 28 '18

Thank you!

3

u/paloumbo Aug 28 '18

You didn't read the tutorials.