Skip to content
Martin Prout edited this page Apr 8, 2014 · 9 revisions

Simple vanilla processing sketch:-

CircleTest.pde

Circle circle;

void setup() {
  size(200, 200);
  circle = new Circle(100);
}

void draw() {
  background(0);
  circle.draw();
}

Circle.pde (class in separate tab in ide)

class Circle {
  float size;
  Circle(float sz) {
    size = sz;
  }
  
  void draw() {
    fill(200);
    ellipse(width / 2, height /2, size, size);
  }
}

When translated to java (by processing) prior to compiling

CircleTest.java

import processing.core.*; 
import processing.data.*; 
import processing.event.*; 
import processing.opengl.*; 

import java.util.HashMap; 
import java.util.ArrayList; 
import java.io.File; 
import java.io.BufferedReader; 
import java.io.PrintWriter; 
import java.io.InputStream; 
import java.io.OutputStream; 
import java.io.IOException; 

public class CircleTest extends PApplet {

Circle circle;

public void setup() {
  size(400, 400);
  circle = new Circle(100);
}

public void draw() {
  background(0);
  circle.draw();
}

class Circle {
  float size;
  Circle(float sz) {
    size = sz;
  }
  public void draw() {
    fill(200);
    ellipse(width / 2, height /2, sz, sz);
  }
}

  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "CircleTest" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}