/* Copyright (C) 2007 Andre Seidelt, All Rights Reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ ArrayList points = new ArrayList(); int MAX_COLOR = 200; int currentColor = 0; class Point { int mX,mY; Point(int x, int y) { mX = x; mY = y; } } void setup() { size(300,300); smooth(); noStroke(); colorMode(HSB, 100); } synchronized void draw() { background(0); // set color int h = currentColor % 100; int s = currentColor > 100 ? (currentColor - 100) % 100 : 0; currentColor++; if(currentColor > MAX_COLOR) { currentColor = 0; } stroke(h, s, 100); // draw points and lines for(int i = 0; i < points.size(); i++) { Point src = (Point) points.get(i); point(src.mX, src.mY); for(int j = i + 1; j < points.size(); j++) { Point dst = (Point) points.get(j); line(src.mX, src.mY, dst.mX, dst.mY); } } } synchronized void mousePressed() { if(mouseButton == LEFT) { Point p = new Point(mouseX, mouseY); points.add(p); } else if(mouseButton == RIGHT) { points.clear(); } }