We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › UPDATED: IP address plot: Useful
Page Index Toggle Pages: 1
UPDATED: IP address plot: Useful? (Read 509 times)
UPDATED: IP address plot: Useful?
Jun 11th, 2008, 7:17pm
 
To better understand regular expressions, I used match() to parse IP addresses that have visited my website. I use the octets as parameters to the fill() function, for example:

IP address 192.168.1.5

would be used as fill(192,168,1);

The last octet I use for positioning the circle along the x-axis. Here is a picture of what was achieved:

...

Anything useful? What can I do to make it useful enough for people to care?

Code:

void setup() {
size(256,256);
background(0);
smooth();
noStroke();
noLoop();//Used so the circles are only drawn once
}
//Read the ip addresses from the below file.
String lines[] = loadStrings("http://www.savacafe.com/ips.txt");

void draw() {
for (int i=0; i < lines.length; i++) {
String ips[] = match(lines[i], "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})");
String oct[] = split(ips[0], '.');
fill(float(oct[0]),float(oct[1]),float(oct[2]));
ellipse(float(oct[3]),int(random(height)),8,8);
}
}
Page Index Toggle Pages: 1