daily pastebin goal
20%
SHARE
TWEET

ppm255(3).cpp

a guest Aug 2nd, 2014 960 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. // NOTE: compile with g++ filename.cpp -std=c++11
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5. #define DIM 1024
  6. #define DM1 (DIM-1)
  7. #define _sq(x) ((x)*(x))                           // square
  8. #define _cb(x) abs((x)*(x)*(x))                    // absolute value of cube
  9. #define _cr(x) (unsigned char)(pow((x),1.0/3.0))   // cube root
  10.  
  11. unsigned char GR(int,int);
  12. unsigned char BL(int,int);
  13.  
  14. unsigned char RD(int i,int j){
  15.     // YOUR CODE HERE
  16. }
  17. unsigned char GR(int i,int j){
  18.     // YOUR CODE HERE
  19. }
  20. unsigned char BL(int i,int j){
  21.     // YOUR CODE HERE
  22. }
  23.  
  24. void pixel_write(int,int);
  25. FILE *fp;
  26. int main(){
  27.     fp = fopen("MathPic","wb");
  28.     fprintf(fp, "P6\n%d %d\n255\n", DIM, DIM);
  29.     for(int j=0;j<DIM;j++)
  30.         for(int i=0;i<DIM;i++)
  31.             pixel_write(i,j);
  32.     fclose(fp);
  33.     return 0;
  34. }
  35. void pixel_write(int i, int j){
  36.     static unsigned char color[3];
  37.     color[0] = RD(i,j)&255;
  38.     color[1] = GR(i,j)&255;
  39.     color[2] = BL(i,j)&255;
  40.     fwrite(color, 1, 3, fp);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top