Encyclopedia > Image:Aliased.png

  Article Content

Image:Aliased.png

Aliased chessboard

Created with a variant of this program, which I (Loisel 03:56 Jan 24, 2003 (UTC)) wrote myself:

  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <math.h>
  4. include <time.h>
  5. include <assert.h>
int color(double x, double y) {
  double t,z;
  int i,j,k;

  x=x/128.0-0.5;
  y=y/1024.0;

  t=1.0/(y+0.01);
  z=t*x;
  i=floor(t);
  j=floor(z);
  k=i+j;
  //  printf("%f %f -> %i %i %i\n",t,z,i,j,k%2);
  return ((k%2)!=0);
}

double myrand() {

  return rand()/((double)RAND_MAX);
}

int main() {

  int i,j,k,l;
  double x,y;
  printf("P5\n128 128\n255\n");
  srand(time(0));
  for(i=0;i<128;i++)
    for(j=0;j<128;j++)
      {
k=0; for(l=0;l<255;l++) { x=j+myrand(); y=i+myrand(); k+=color(x,y); } assert(k>=0 && k<=255); k=(k/4)*4; // cygwin bug? fwrite(&k,1,1,stdout);
      }
}

Image links

There are no pages that link to this image.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Canadian Charter of Rights and Freedoms

... clause states: The Canadian Charter of Rights and Freedoms guarantees the rights and freedoms set out in it subject only to such reasonable limits prescribed by law ...

 
 
 
This page was created in 27.3 ms