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
Wheatley Heights, New York

... American, 3.41% Asian, 0.00% Pacific Islander, 4.15% from other races, and 3.73% from two or more races. 11.67% of the population are Hispanic or Latino of any race. There ...

 
 
 
This page was created in 101.8 ms