-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgGen.c
More file actions
32 lines (30 loc) · 723 Bytes
/
Copy pathimgGen.c
File metadata and controls
32 lines (30 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
srand(time(NULL));
char *filepath = "images/output.ppm";
FILE *fptr = fopen(filepath, "wb");
int h = 16 * 60;
int w = 9 * 60;
fprintf(fptr, "P6\n");
fprintf(fptr, "%d %d\n", h, w);
fprintf(fptr, "255\n");
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
int randNum = rand() % 20;
if (((i + randNum) / 60 + (j + randNum) / 60) % 2) {
fputc(0xFF, fptr);
fputc(0x00, fptr);
fputc(0x00, fptr);
} else {
fputc(0x00, fptr);
fputc(0x00, fptr);
fputc(0x00, fptr);
}
}
}
fclose(fptr);
printf("Image generated at %s\n", filepath);
return 0;
}