Update of /cvsroot/meshdb/src/geo/alt
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22052
Modified Files:
Tag: leonard-dev
main.c
Log Message:
blending and catch some limit excesses
Index: main.c
===================================================================
RCS file: /cvsroot/meshdb/src/geo/alt/main.c,v
retrieving revision 1.3.2.7
retrieving revision 1.3.2.8
diff -u -d -r1.3.2.7 -r1.3.2.8
--- main.c 23 Jan 2005 01:52:23 -0000 1.3.2.7
+++ main.c 23 Jan 2005 12:04:34 -0000 1.3.2.8
@@ -88,7 +88,7 @@
{
struct alt alt;
int x, y;
- rgb_t rgb;
+ rgba_t rgba;
float fmin, fmax;
int ch;
int error = 0;
@@ -244,7 +244,7 @@
1.0/scale, 1.0/scale);
} else {
/* generate PNG output */
- image_set_type(IMAGE_TYPE_PNM);
+ image_set_type(IMAGE_TYPE_PNG);
image_begin(w, h);
}
@@ -346,7 +346,9 @@
for (n = 1; n < nmax; n++) {
int p;
- for (y = -n; y <= n; y++) {
+ for (y = -n; y <= n; y++)
+ if (-h2 <= y && y < h2)
+ {
float d = sqrt(n*n + y*y);
float aze = (H(n,y)-h0) / d;
float azw = (H(-n,y)-h0) / d;
@@ -366,7 +368,7 @@
VISIBLE(-n,y) = (azw >= shadow_w);
}
- for (y = -h2; y < h2; y++) {
+ for (y = -h2; y <= h2; y++) {
float yr = y * n / (float)h2;
int yrI = floor(yr);
float yrM = yr - yrI;
@@ -380,7 +382,9 @@
wall_w[y+h2+1] = azw;
}
- for (x = -n; x <= n; x++) {
+ for (x = -n; x <= n; x++)
+ if (-w2 <= x && x < w2)
+ {
float d = sqrt(n*n + x*x);
float azn = (H(x,n)-h0) / d;
float azs = (H(x,-n)-h0) / d;
@@ -400,7 +404,7 @@
VISIBLE(x,-n) = (azs >= shadow_s);
}
- for (x = -w2; x < w2; x++) {
+ for (x = -w2; x <= w2; x++) {
float xr = x * n / (float)w2;
int xrI = floor(xr);
float xrM = xr - xrI;
@@ -467,19 +471,24 @@
/* Crosses (and circles in red) */
if (iscross) {
if (iscross == 1) {
- rgb[0] = 255;
- rgb[1] = rgb[2] = 0;
+ rgba[0] = 255;
+ rgba[1] = 0;
+ rgba[2] = 0;
} else {
- rgb[0] = 255;
- rgb[1] = 0;
- rgb[2] = 128;
+ rgba[0] = 255;
+ rgba[1] = 0;
+ rgba[2] = 128;
}
+ rgba[3] = 255;
goto plot;
}
+ rgba[3] = 64;
+
if (isnanf(f)) {
- /* Unknown data (sea) is black */
- rgb[0] = rgb[1] = rgb[2] = 0;
+ /* Unknown data (sea) is grey/trans */
+ rgba[0] = rgba[1] = rgba[2] = 128;
+ rgba[3] = 0;
goto plot;
}
@@ -490,20 +499,23 @@
shade = (f - H(x-1,y-1)) / ((fmax-fmin) * 0.3) + 0.5;
if (shade < 0) shade = 0;
if (shade > 1) shade = 1;
+ if (isnanf(H(x-1,y-1))) shade = 0.5;
- rgb[0] = rgb[1] = rgb[2] = 255 * shade;
+ rgba[0] = rgba[1] = rgba[2] = 255 * shade;
/* Tinge with blue if visible */
- if (lflag && VISIBLE(x,y))
- rgb[2] = 255 - (255-rgb[2])/4;
+ if (lflag && VISIBLE(x,y)) {
+ rgba[2] = 255 - (255-rgba[2])/4;
+ rgba[3] = 96;
+ }
/*
-fprintf(stderr, "[%d,%d] = %lf,%lf -> %f -> <%u,%u,%u>\n",
-x,y,lon,lat,f,rgb[0],rgb[1],rgb[2]);
+fprintf(stderr, "[%d,%d] = %lf,%lf -> %f -> <%u,%u,%u,%u>\n",
+x,y,lon,lat,f,rgba[0],rgba[1],rgba[2],rgba[3]);
*/
plot:
- image_write_rgb(&rgb);
+ image_write_rgba(&rgba);
}
}
if (vflag)
|