summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-02-11 13:18:09 +0000
committerTim Redfern <tim@eclectronics.org>2012-02-11 13:18:09 +0000
commite22a28b930d02ac7b30fd4866bef2ec2d22a062d (patch)
tree96f8938ec06aec7c96c176edc708f8f4aab46325
parentc7284a5e4f7a1ed2846344d7b221ad74db8d0334 (diff)
bitmap lines
-rw-r--r--parsecalldata.pde17
1 files changed, 15 insertions, 2 deletions
diff --git a/parsecalldata.pde b/parsecalldata.pde
index f82c0e3..5870e6d 100644
--- a/parsecalldata.pde
+++ b/parsecalldata.pde
@@ -77,8 +77,11 @@ class bitmapcountry extends country {
RPoint br=outline.getBottomRight();
RPoint tlp=normpix(tl);
RPoint brp=normpix(br);
- float pixstep=(br.x-tl.x)/lightmap.width;
+ float pixstep=xs/lightmap.width;
float totalbright=0;
+ float bmin=255;
+ float bmax=0;
+ println("searching "+tl.x+","+tl.y+" -> "+(tl.x+(pixstep*(brp.x-tlp.x)))+","+(tl.y+(pixstep*(brp.y-tlp.y))));
for (int i=0;i<brp.x-tlp.x;i++) {
for (int j=0;j<brp.y-tlp.y;j++) {
RPoint pn=new RPoint(tl.x+(i*pixstep),tl.y+(j*pixstep));
@@ -86,6 +89,8 @@ class bitmapcountry extends country {
float bn=brightness(lightmap.get((int)brp.x+i,(int)brp.y+j));
points.add(new weightedpixel(normalise(pn),bn));
totalbright +=bn;
+ if (bn>bmax) bmax=bn;
+ if (bn<bmin) bmin=bn;
}
}
}
@@ -95,7 +100,7 @@ class bitmapcountry extends country {
runbright+=points.get(i).bright*bfactor;
points.get(i).index=runbright;
}
- if (DEBUG) println(name+"; bounds: "+tl.x+","+tl.y+" - "+points.size()+" pixels");
+ if (DEBUG) println(name+"; bounds: "+tl.x+","+tl.y+" : "+br.x+","+br.y+" - "+points.size()+" pixels, "+bmin+"-"+bmax+" avg: "+(totalbright/points.size()));
}
RPoint normalise(RPoint p) {
@@ -110,6 +115,14 @@ class bitmapcountry extends country {
return new RPoint(px,py);
}
+ RPoint getpoint(){
+ float index=random(0.999);
+ int i=0;
+ while (points.get(i).index<index) {
+ i++;
+ }
+ return new RPoint(points.get(i).pt.x+random(1),points.get(i).pt.y+random(1));
+ }
}
class calldata {