Atheuz

Untitled

Oct 5th, 2011 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. /*
  2.  *  Dato: 03-10-2011
  3.  *  Kursus: Imperativ Programming
  4.  *  Underviser: Kurt Nørmark
  5.  *  Opgave: http://people.cs.aau.dk/~normark/impr-c/control-more-iteration-for-slide-exercise-1.html
  6.  */
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <math.h>
  11.  
  12. #define PI 3.1415926535
  13.  
  14. int main() {
  15.  
  16.     FILE *image_file;
  17.     int i, j;
  18.     int red, green, blue;
  19.     int counter;
  20.  
  21.     image_file = fopen("out.pnm", "wb");
  22.  
  23.     // Header
  24.     fputs("P6\n", image_file);
  25.     fputs("500 500\n", image_file);
  26.     fputs("255\n", image_file);
  27.  
  28.     counter = 0;
  29.  
  30.     // Rækker
  31.     for(i = 0; i < 500; i++)
  32.         // Søjler
  33.         for (j = 0; j < 500; j++)
  34.         {
  35.            
  36. //            if(abs(round(sin(i)*500))==j)
  37. //            {
  38. //                fputc(255, image_file);
  39. //                fputc(0, image_file);
  40. //                fputc(0, image_file);
  41. //            }
  42. //            else if(abs(round(cos(i)*500))==j)
  43. //            {
  44. //                fputc(255, image_file);
  45. //                fputc(0, image_file);
  46. //                fputc(0, image_file);
  47. //            }
  48.  
  49.                 fputc(abs(floor(sin(i)*sin(j)*750)) % 256, image_file); // abs(floor(sin(i)*sin(j)*500)) % 256
  50.                 fputc(abs(floor(sin(i)*sin(j)*500)) % 256, image_file); // abs(floor(asin(j)*asin(i)*1)) % 256
  51.                 fputc(abs(floor(sin(i)*sin(j)*250)) % 256, image_file); // abs(floor(sin(i+j)*asin(i+j)*1)) % 256
  52.                 counter++;
  53.             //printf("%d, ", abs(round(cos(i)*500)));
  54.             //printf("%d, ", abs(round(sin(i)*500)));
  55.         }
  56.  
  57.     fclose(image_file);
  58.  
  59.     printf("%d", counter);
  60.  
  61.     return 0;
  62. }
  63.  
  64.  
  65.  
Add Comment
Please, Sign In to add comment