What can you create in Processing?

there are examples of drawing:

see Continuous Lines / Examples / Processing.org

or here where you can switch between drawing cirlce / line




// draw program 
// rubber = rubber 

PFont font;
//PShape ellipse;
color currentFill=color(111); 

ArrayList<Button> buttons = new ArrayList();  

boolean hold=false;

// define modes 
final int lineMode = 0;
final int circleMode = 1;
final int rubberMode = 2;
//current mode
int mode = lineMode;
// names of modes
String[] stringMode={ "line", 
  "circle (drag mouse)", 
  "rubber"};

// draw a circle variables 
boolean drawNewCircle; // During mouse dragging we can still abort the circle with ESC and change its size with the mouse 
PVector startCircle=new PVector(); 
float diameter; 

void setup() {
  size(768, 1024);

  PImage rubber;
  PImage save;
  PImage delete;
  PImage circle;

  background(255);
  rubber = loadImage("gomme.png");
  save = loadImage("save.png");
  delete = loadImage("delete.png");
  circle = loadImage("circle.png");
  //ellipse = loadShape("ellipse.svg");

  // font = loadFont("Grotex-Regular-48.vlw");
  // textFont(font);

  defineButton(rubber, "rubber", 600, 20, 64, 74);
  defineButton(save, "save", 520, 20, 64, 74); 
  defineButton(delete, "delete", 680, 20, 64, 74);
  //shape(ellipse, 300, 380, 188, 188);
  defineButton(circle, "circle (on/off)", 400, 20, 188, 188);
} 

void draw() {

  helpTextUpperLeftCorner(); 

  // display buttons
  for (Button b : buttons) {
    b.display();
  }

  textSize(48);
  text("un soleil", 20, 60); 
  fill(210);

  stroke(0);
  strokeWeight(6);
  if (!hold) {
    switch(mode) {
    case circleMode:
      // ignore
      break; 
    case lineMode:
      if (mousePressed) {
        line(mouseX, mouseY, pmouseX, pmouseY);
      }
      break;
    case rubberMode:
      //
      if (mousePressed) {
        fill(255); 
        noStroke(); 
        rect(mouseX, mouseY, 3, 3);
      }
      break; 
    default:
      //Error 
      break;
    }//switch
  }//if

  // During mouse dragging we can still abort the circle with ESC and change its size with the mouse 
  if (drawNewCircle) {
    // delete old circle 
    stroke(255); 
    fill(255);
    strokeWeight(3);
    ellipse( startCircle.x, startCircle.y, diameter, diameter);
    // show circle with current size diameter
    stroke(0);
    noFill(); 
    strokeWeight(1);
    diameter = 2 * dist (mouseX, mouseY, 
      startCircle.x, startCircle.y);
    stroke(0); 
    ellipse( startCircle.x, startCircle.y, diameter, diameter);
  }//if
  //
}

// -----------------------------------------------------

void helpTextUpperLeftCorner() {
  //
  textAlign(LEFT);
  fill(255); 
  noStroke(); 
  rect(0, 0, width, 30); 
  fill(0); 
  textSize(17);
  if (drawNewCircle) {
    text("drag mouse to resize circle, ESC to abort", 22, 22);
  } else { 
    text("mode is " + stringMode[mode], 22, 22);
  }//else 
  // default
  fill(210);
}//func

void mousePressed() {
  for (Button b : buttons) {
    if (b.over()) {
      exec(b.id);
      hold=true; 
      return;
    }//if
  }//for
  if (mode==circleMode) {
    startCircle.x=mouseX;
    startCircle.y=mouseY;
    drawNewCircle=true;
    diameter=0;
  }
}

void mouseReleased() {

  if (drawNewCircle) {
    // finish the circle in red 
    noStroke();
    fill(currentFill);
    ellipse( startCircle.x, startCircle.y, diameter, diameter);
  }
  hold=false;
  drawNewCircle=false;
  diameter=0;
}

// ------------------------------------------------------------

void keyPressed() {
  if (key==ESC) {

    key=0;

    if (drawNewCircle) {
      stroke(255); 
      fill(255);
      strokeWeight(3);
      ellipse( startCircle.x, startCircle.y, diameter, diameter);

      hold=false;
      drawNewCircle=false;
      diameter=0;
    }
  } 

  // COLORS 

  else if (key=='0') {
    currentFill=color(255, 0, 0);
  } else if (key=='1') {
    currentFill=color(0, 255, 0);
  } else if (key=='2') {
    currentFill=color(0, 0, 255);
  } else if (key=='3') {
    currentFill=color(0);
  } else if (key=='4') {
    currentFill=color(201);
  } else if (key=='5') {
    currentFill=color(34);
  } else if (key=='6') {
    currentFill=color(255, 248, 44);
  }
}

// -------------------------------------------------------------------

void exec(int id) {
  // execute commands 
  println(id);

  switch (id) {
  case 0:
    mode=rubberMode;
    break; 

  case 1:
    // 
    save("zrewuizwre.png");
    break; 

  case 2:
    background(255);
    break;

  case 3:
    if (mode!=circleMode)
      mode=circleMode; 
    else 
    mode=lineMode;
    break;
  default:
    break;
  }//switch
}

void defineButton(PImage img, 
  String s, 
  float x, float y, 
  float w, float h) {
  buttons.add (new Button(img, s, x, y, buttons.size()));
}

//===================================================================

class Button {

  PImage img=null; 
  String s; 
  float x, y; 
  int id; 

  Button(PImage img_, 
    String s_, 
    float x_, float y_, 
    int id_) {
    img=img_; 
    s=s_;
    x=x_;
    y=y_;

    id=id_;
  }

  void display() {
    if (img!=null) {
      imageMode(CENTER); 
      image(img, x, y);
      return;
    }

    textAlign(CENTER);
    textSize(17);
    text(s, x, y);
    textAlign(LEFT);
  }//

  boolean over() {
    return 
      dist (mouseX, mouseY, x, y) < 30;
  }
  //
}//class
// 
2 Likes