I8sinc.c 593 Bytes
/*
 *  create 8-bit I, one-D texture
 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define ABS(x)		((x) < 0 ? -(x) : (x))

float
  func1(int i)
{
  return(ABS(cos((float)i*0.150) * exp(-0.015*i)));
}

main(int argc, char **argv)
{
  int i;

#ifndef GNU_PLOT
  printf("static Gfx I8sinc_C_dummy_aligner[] = { gsSPEndDisplayList() };\n");
  printf("unsigned char I8sinc[256] = {\n");

  for(i = 0; i < 256; i++)
  {
    printf("%d,\n", (int) (255 * func1(i)) );
  }
  printf("};\n"); 
#else
  for(i = 0; i < 256; i++)
  {
    printf("%d\n", (int) (255 * func1(i));
  }
#endif
}