• fullscreen
  • _3D_rotate.pde
  • point.pde
  • ArrayList points;
    color a = color(random(0, 255), random(0, 255), random(0, 255), 100);
    
    float x = 0;
    
    void setup() {
      background(0);
      size(700, 700, P3D);
      smooth();
      points = new ArrayList();
      strokeWeight(1);
    }
    
    void draw() {
      translate(width/2, 0);
      lights();
      if(keyPressed && key == ' ') {
        stroke(a);
        x = x + 0.5;
      } else {
        noStroke();
      }
    
      rotateY(x);
    
      for(int i = points.size() - 1; i >= 0; i--) {
        Point dots = (Point) points.get(i);
        dots.display();
      }
    }
    
    void mouseDragged() {
      points.add(new Point());
      Point pointz = (Point) points.get(points.size() - 1);
      pointz.setValues(pmouseX - width/2, pmouseY, mouseX - width/2, mouseY);
    }
    
    void keyPressed() {
      if(key == 'a') {
        setup();
      }
    }
    
    void keyReleased() {
      x = 0;
    }
    
    void mousePressed() {
      a = color(random(0, 255), random(0, 255), random(0, 255), 100);
    }
    
    
    
    
    
    
    
    
    class Point {
      float a, b, x, y;
      
      Point() {
      }
      
      void setValues(float apos, float bpos, float xpos, float ypos) {
        a = apos;
        b = bpos;
        x = xpos;
        y = ypos;
      }
      
      void display() {
        line(a, b, x, y);
      }
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Ben Mandeberg

    3D Line Rotate 2

    Add to Faves Me Likey@! 4
    You must login/register to add this sketch to your favorites.

    This one's a bit different. You won't be able to see what you draw, I sort of like the spontaneity of that. Also, it's in color this time with a bit of transparency.

    Draw by clicking and dragging.
    Rotate in 3D by pressing the space bar.
    Clear the screen by pressing "a".

    I like it! Nice.
    You need to login/register to comment.