repositories
/
SugarCubes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Much faster granims
[SugarCubes.git]
/
GranimPattern.pde
diff --git
a/GranimPattern.pde
b/GranimPattern.pde
index 0af19f38f551c6d8a7ecd8472455bf3b163a10f9..606c9e2e3ca17219f203eb11cabda5b06b8ce2b3 100644
(file)
--- a/
GranimPattern.pde
+++ b/
GranimPattern.pde
@@
-1,6
+1,7
@@
import java.util.LinkedHashMap;
class Graphic
{
import java.util.LinkedHashMap;
class Graphic
{
+ public boolean changed = false;
public int position = 0;
public ArrayList<Integer> graphicBuffer;
Graphic()
public int position = 0;
public ArrayList<Integer> graphicBuffer;
Graphic()
@@
-16,21
+17,21
@@
class Graphic
};
class Granim extends Graphic
{
};
class Granim extends Graphic
{
-
Linked
HashMap<String,Graphic> displayList;
+ HashMap<String,Graphic> displayList;
Granim()
{
Granim()
{
- displayList = new
Linked
HashMap<String,Graphic>();
+ displayList = new HashMap<String,Graphic>();
}
public Graphic addGraphic(String name, Graphic g)
{
}
public Graphic addGraphic(String name, Graphic g)
{
- //graphicBuffer.clear();
while(width()< g.position+1)
{
graphicBuffer.add(color(0,0,0));
}
drawAll();
displayList.put(name , g);
while(width()< g.position+1)
{
graphicBuffer.add(color(0,0,0));
}
drawAll();
displayList.put(name , g);
+ changed =true;
return g;
}
return g;
}
@@
-41,15
+42,29
@@
class Granim extends Graphic
public void update()
{
public void update()
{
-
+
for(Graphic g : displayList.values())
{
if(g instanceof Granim)
{
((Granim) g).update();
for(Graphic g : displayList.values())
{
if(g instanceof Granim)
{
((Granim) g).update();
+
+ }
+ changed = changed || g.changed;
+ if(changed)
+ {
+ while(width()< g.position + g.width())
+ {
+ graphicBuffer.add(color(0,0,0));
+ }
+ if(g.changed)
+ {
+ drawOne(g);
+ g.changed =false;
+ }
}
}
}
}
-
drawAll()
;
+
changed = false
;
}
public void drawOne(Graphic g)
}
public void drawOne(Graphic g)
@@
-58,25
+73,16
@@
class Granim extends Graphic
}
public void drawAll()
{
}
public void drawAll()
{
- graphicBuffer.clear();
- for(Graphic g : displayList.values())
- {
- while(width()< g.position + g.width())
- {
- graphicBuffer.add(color(0,0,0));
- }
- drawOne(g);
- }
}
};
class GranimPattern extends SCPattern
{
}
};
class GranimPattern extends SCPattern
{
-
Linked
HashMap<String,Graphic> displayList;
+ HashMap<String,Graphic> displayList;
GranimPattern(GLucose glucose)
{
super(glucose);
GranimPattern(GLucose glucose)
{
super(glucose);
- displayList = new
Linked
HashMap<String,Graphic>();
+ displayList = new HashMap<String,Graphic>();
}
public Graphic addGraphic(String name, Graphic g)
}
public Graphic addGraphic(String name, Graphic g)
@@
-94,7
+100,7
@@
class GranimPattern extends SCPattern
{
drawToPointList();
}
{
drawToPointList();
}
-
+ private Integer[] gbuffer;
public void drawToPointList()
{
for(Graphic g : displayList.values())
public void drawToPointList()
{
for(Graphic g : displayList.values())
@@
-103,12
+109,16
@@
class GranimPattern extends SCPattern
{
((Granim) g).update();
}
{
((Granim) g).update();
}
- List<Point> drawList = model.points.subList(g.position, g.position + g.width());
-
+ List<Point> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
+ println("drawlistsize "+drawList.size());
+
+ gbuffer = g.graphicBuffer.toArray(new Integer[0]);
+
for (int i=0; i < drawList.size(); i++)
{
for (int i=0; i < drawList.size(); i++)
{
- colors[drawList.get(i).index] =
(int) g.graphicBuffer.get(i)
;
+ colors[drawList.get(i).index] =
gbuffer[i]
;
}
}
+ g.changed =false;
}
}
}
}
@@
-192,13
+202,14
@@
class RandomsGranim extends Granim
public void update()
{
super.update();
public void update()
{
super.update();
- if(
count % 5
0==0)
+ if(
instanceCount<50 && count % 2
0==0)
{
instanceCount++;
Graphic h=addGraphic("myrandoms_"+instanceCount, makeGraphic(_len));
h.position = instanceCount*(_len+100);
println("one more " + instanceCount+" at "+h.position);
count=0;
{
instanceCount++;
Graphic h=addGraphic("myrandoms_"+instanceCount, makeGraphic(_len));
h.position = instanceCount*(_len+100);
println("one more " + instanceCount+" at "+h.position);
count=0;
+ changed = true;
}
count++;
}
count++;
@@
-216,5
+227,6
@@
class ColorDotsGraphic extends Graphic
{
graphicBuffer.add(color(colorVal, 255, 255));
}
{
graphicBuffer.add(color(colorVal, 255, 255));
}
+ changed = true;
}
};
}
};