Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #define DIM_X 500
- #define DIM_Y 500
- int main() {
- FILE *image_file;
- int i, j;
- int red, green, blue;
- image_file = fopen("im.pnm", "wb");
- fprintf(image_file, "P6\n");
- fprintf(image_file, "%d %d\n", DIM_X, DIM_Y);
- fprintf(image_file, "255\n");
- for (i = 0; i < DIM_X; i++)
- for (j = 0; j < DIM_Y; j++)
- {
- red = abs(floor(sin(i)*750 + sin(j)*750)) % 256;;
- green = 0;
- blue = 0;
- fputc(red, image_file);
- fputc(green, image_file);
- fputc(blue, image_file);
- }
- fclose(image_file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement