0% found this document useful (0 votes)
134 views21 pages

Core - Using PApplet

The document discusses the basic structure of a Processing sketch. It shows that a Processing sketch contains an import statement to include the Processing library, a class that extends PApplet, and setup() and draw() methods. The setup() method is used to initialize variables and set the size of the canvas, while the draw() method continuously executes graphics commands and is where the main sketch logic and display code goes. An example loads an image from a URL in the setup() method to use as a background.

Uploaded by

memememe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views21 pages

Core - Using PApplet

The document discusses the basic structure of a Processing sketch. It shows that a Processing sketch contains an import statement to include the Processing library, a class that extends PApplet, and setup() and draw() methods. The setup() method is used to initialize variables and set the size of the canvas, while the draw() method continuously executes graphics commands and is where the main sketch logic and display code goes. An example loads an image from a URL in the setup() method to use as a background.

Uploaded by

memememe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

(x,y)

(x,y)

x
(x,y)

y
0 200

0
(x,y) ?
200
0 200

0
(50,50)
200
Now in Processing .
Now in Processing .
import processing.core.*;

public class MyPApplet extends PApplet {

public void setup() { GUI data type


...
}
public void draw() {
...
}
}
import processing.core.*; Tell Java where to find PApplet

public class MyPApplet extends PApplet {

public void setup() {


...
}
public void draw() {
...
}
}
import processing.core.*;

public class MyPApplet extends PApplet {

public void setup() {


... Configure canvas
}
public void draw() {
... Display content
}
}
import processing.core.*;

public class MyPApplet extends PApplet {

public void setup() {


... Executed once
}
public void draw() {
... Loops often
}
}
import processing.core.*;

public class MyPApplet extends PApplet {

}
import processing.core.*;

public class MyPApplet extends PApplet {

}
import processing.core.*;

public class MyPApplet extends PApplet {

public void setup() {


...
}
public void draw() {
...
}
}
import processing.core.*;

public class MyPApplet extends PApplet


{
private String URL = "http://...jpg";
private PImage backgroundImg;

public void setup()


{

public void draw()


{
// Body not shown
}
}
import processing.core.*;

public class MyPApplet extends PApplet


{
String URL = "http://...jpg";
PImage backgroundImg;

public void setup()


{
size(200,200);
backgroundImg = loadImage(URL,"jpg");
}

public void draw()


{
// Body not shown
}
}
import processing.core.*;

public class MyPApplet extends PApplet


{
String URL = "http://...jpg";
PImage backgroundImg;

public void setup()


{
size(200,200);
backgroundImg = loadImage(URL,"jpg");
}

public void draw()


{
// Body not shown
}
}
import processing.core.*;

public class MyPApplet extends PApplet


{
private String URL = "http://...jpg";
private PImage backgroundImg;

public void setup()


{
size(200,200);
backgroundImg = loadImage(URL,"jpg");
}

public void draw()


{
// Body not shown
}
}

You might also like