Permalink
Browse files

Moved trunk/code_swarm to tags/prototype/code_swarm.

Now we can end support of the Processing version.


git-svn-id: http://codeswarm.googlecode.com/svn/trunk@160 eda9c206-d64f-0410-a2f2-67f3fa0499ed
  • Loading branch information...
1 parent b1d13b8 commit 8d4c685ecb600cceaabca7bd092b47f1082d2480 michael.ogawa committed Jul 13, 2008
@@ -1,71 +0,0 @@
-/*
- Copyright 2008 Michael Ogawa
-
- This file is part of code_swarm.
-
- code_swarm is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- code_swarm is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with code_swarm. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-class ColorAssigner
-{
- ArrayList tests;
- color defaultColor = color(128, 128, 128);
-
- public ColorAssigner()
- {
- tests = new ArrayList();
- }
-
- void addRule( String expr, color c1, color c2 )
- {
- ColorTest t = new ColorTest();
- t.expr = expr;
- t.c1 = c1;
- t.c2 = c2;
- addRule( t );
- }
-
- void addRule( ColorTest t )
- {
- tests.add( t );
- }
-
- color getColor( String s )
- {
- for( int i = 0; i < tests.size(); i++ )
- {
- ColorTest t = (ColorTest)tests.get(i);
- if ( t.passes( s ) )
- return t.assign();
- }
-
- return defaultColor;
- }
-}
-
-class ColorTest
-{
- String expr;
- color c1, c2;
-
- boolean passes( String s )
- {
- return s.matches( expr );
- }
-
- color assign()
- {
- return lerpColor( c1, c2, random(1.0) );
- }
-}
View
@@ -1,44 +0,0 @@
-/*
- Copyright 2008 Michael Ogawa
-
- This file is part of code_swarm.
-
- code_swarm is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- code_swarm is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with code_swarm. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-class ColorBins
-{
- color [] colorList;
- int num;
-
- ColorBins()
- {
- colorList = new color[2];
- num = 0;
- }
-
- void add( color c )
- {
- if ( num >= colorList.length )
- colorList = expand( colorList );
-
- colorList[num] = c;
- num++;
- }
-
- void sort()
- {
- colorList = PApplet.sort( colorList );
- }
-}
View
@@ -1,80 +0,0 @@
-/*
- Copyright 2008 Michael Ogawa
-
- This file is part of code_swarm.
-
- code_swarm is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- code_swarm is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with code_swarm. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-class Edge
-{
- Node from;
- Node to;
- float len;
- int life;
-
- Edge( Node from, Node to )
- {
- this.from = from;
- this.to = to;
- this.len = 40; //25
- this.life = 255;
- }
-
- void relax()
- {
- float vx = to.x - from.x;
- float vy = to.y - from.y;
- float d = mag( vx, vy );
- if ( d > 0 )
- {
- float f = (len - d) / (d * 3);
- f = f * map( life, 0, 255, 0, 1.0 );
- float dx = f * vx;
- float dy = f * vy;
- to.dx += dx;
- to.dy += dy;
- from.dx -= dx;
- from.dy -= dy;
- }
- }
-
-
- void draw()
- {
- if ( life > 240 )
- {
- stroke( 255, life );
- strokeWeight( 0.35 );
- line( from.x, from.y, to.x, to.y );
- }
- }
-
- void update()
- {
- decay();
- }
-
- void decay()
- {
- life += -2;
- if ( life < 0 )
- life = 0;
- }
-
- void freshen()
- {
- life = 255;
- }
-}
View
@@ -1,52 +0,0 @@
-/*
- Copyright 2008 Michael Ogawa
-
- This file is part of code_swarm.
-
- code_swarm is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- code_swarm is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with code_swarm. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import java.util.*;
-
-class FileEvent implements Comparable
-{
- Date date;
- String author;
- String filename;
- String path;
- int linesadded;
- int linesremoved;
-
- FileEvent( long datenum, String author, String path, String filename )
- {
- this( datenum, author, path, filename, 0, 0 );
- }
-
- FileEvent( long datenum, String author,
- String path, String filename,
- int linesadded, int linesremoved )
- {
- this.date = new Date( (long)datenum );
- this.author = author;
- this.path = path;
- this.filename = filename;
- this.linesadded = linesadded;
- this.linesremoved = linesremoved;
- }
-
- int compareTo( Object o )
- {
- return date.compareTo( ((FileEvent)o).date );
- }
-}
Oops, something went wrong.

0 comments on commit 8d4c685

Please sign in to comment.