class VoronoiCrystal{ ArrayList polygons; int order; int MAXORDER; color fillColor; color strokeColor; float floor; VoronoiCrystal(Voronoi voronoi, int MAXORDER, float floor){ polygons=new ArrayList(); Polygon currentPolygon; order = voronoi.order; fillColor=voronoi.fillColor; this.floor=floor; strokeColor=color(0,160-order*(120.0f/MAXORDER)); this.MAXORDER=MAXORDER; Iterator cellItr = voronoi.cells.iterator(); while(cellItr.hasNext()){ Cell currentCell = (Cell)cellItr.next(); float heightFactor = order*order*50.0f*exp(-15.0f*dist(currentCell.centerPoint.x,currentCell.centerPoint.y,width/2,width/2)/width); currentPolygon=new Polygon(currentCell.periphery,strokeColor,0.5f*(MAXORDER-order+1),fillColor,floor,floor+heightFactor); polygons.add(currentPolygon); } } void draw(){ Iterator polygonItr = polygons.iterator(); while(polygonItr.hasNext()){ ((Polygon)polygonItr.next()).draw(); } } } class Polygon{ ArrayList points; color strokeColor; color fillColor; float strokeWeight; float floor; float ceiling; Polygon(){ points=new ArrayList(); strokeColor=color(0); fillColor=color(0); strokeWeight=1.0f; } Polygon(final ArrayList points,final color strokeColor, final float strokeWeight, final color fillColor, final float floor , final float ceiling){ this.points=new ArrayList(); this.points.addAll(points); this.strokeColor=strokeColor; this.fillColor=fillColor; this.strokeWeight=strokeWeight; this.floor=floor; this.ceiling=ceiling; } void draw(){ fill(fillColor); //noStroke(); stroke(strokeColor); //strokeWeight(strokeWeight); beginShape(); Iterator itr = points.iterator(); beginShape(); itr = points.iterator(); while(itr.hasNext()){ Point2D currentPoint= (Point2D)itr.next(); vertex(currentPoint.x,currentPoint.y,ceiling); } if (points.size()>0)vertex(((Point2D)points.get(0)).x,((Point2D)points.get(0)).y,ceiling); endShape(); for(int i=0;i