Advertisement
Atheuz

Untitled

Oct 4th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. #define DIM_X 500
  6. #define DIM_Y 500
  7.  
  8. int main() {
  9.     FILE *image_file;
  10.     int i, j;
  11.     int red, green, blue;
  12.  
  13.     image_file = fopen("im.pnm", "wb");
  14.  
  15.     fprintf(image_file, "P6\n");
  16.     fprintf(image_file, "%d %d\n", DIM_X, DIM_Y);
  17.     fprintf(image_file, "255\n");
  18.  
  19.     for (i = 0; i < DIM_X; i++)
  20.         for (j = 0; j < DIM_Y; j++)
  21.         {
  22.             red = abs(floor(sin(i)*750 + sin(j)*750)) % 256;;
  23.             green = 0;
  24.             blue = 0;
  25.             fputc(red, image_file);
  26.             fputc(green, image_file);
  27.             fputc(blue, image_file);
  28.         }
  29.  
  30.     fclose(image_file);
  31.     return 0;
  32. }
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement