/[gzz]/gzz/gfx/libtexture/geometric.texture
ViewVC logotype

Diff of /gzz/gfx/libtexture/geometric.texture

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by jvk, Wed Oct 16 10:06:52 2002 UTC revision 1.6 by humppake, Thu Oct 17 13:03:29 2002 UTC
# Line 2  Line 2 
2  #include <math.h>  #include <math.h>
3    
4  #define FPARAM(name, default) float name = params->getFloat(#name, default);  #define FPARAM(name, default) float name = params->getFloat(#name, default);
5    #define SQR(A) ((A) * (A))
6    
7  float pyramid(float x, float y) {  float pyramid(float x, float y) {
8    x -= floor(x);    x -= floor(x);
# Line 51  float stripe(float x) { Line 51  float stripe(float x) {
51    return (x < .4999999);    return (x < .4999999);
52  }  }
53    
54    float circle(float x, float y) {
55      return ((SQR(x - 0.5) + SQR(y - 0.5)) <= SQR(0.5));
56    }
57    
58  void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) {  void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) {
59      FPARAM(type, 0);      FPARAM(type, 0);
60      FPARAM(scale, 1);      FPARAM(scale, 1);
# Line 112  void GENERATE(TextureParam *params, int Line 116  void GENERATE(TextureParam *params, int
116            if (components >= 2) data[ind++] = stripe(y);            if (components >= 2) data[ind++] = stripe(y);
117            if (components >= 3) data[ind++] = stripe(1 - xstep - x);            if (components >= 3) data[ind++] = stripe(1 - xstep - x);
118            if (components >= 4) data[ind++] = stripe(1 - ystep - y);            if (components >= 4) data[ind++] = stripe(1 - ystep - y);
           break;  
119          case 7:          case 7:
120            if (components >= 1) data[ind++] = rand() / (RAND_MAX + 1.0);            if (components >= 1) data[ind++] = rand() / (RAND_MAX + 1.0);
121            if (components >= 2) data[ind++] = rand() / (RAND_MAX + 1.0);            if (components >= 2) data[ind++] = rand() / (RAND_MAX + 1.0);
122            if (components >= 3) data[ind++] = rand() / (RAND_MAX + 1.0);            if (components >= 3) data[ind++] = rand() / (RAND_MAX + 1.0);
123            if (components >= 4) data[ind++] = rand() / (RAND_MAX + 1.0);            if (components >= 4) data[ind++] = rand() / (RAND_MAX + 1.0);
124            break;            break;
125                      case 8:
126          }            if (components >= 1) data[ind++] = circle(x + 0.5/width, y + 0.5/height);
127              if (components >= 2) data[ind++] = circle(x + 0.5/width, y + 0.5/height);
128              if (components >= 3) data[ind++] = circle(x + 0.5/width, y + 0.5/height);
129              if (components >= 4) data[ind++] = circle(x + 0.5/width, y + 0.5/height);
130              break;
131            }
132        }        }
133      }      }
134    
# Line 129  void GENERATE(TextureParam *params, int Line 137  void GENERATE(TextureParam *params, int
137      }      }
138            
139  }  }
140    
141    
142    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26