Last active
August 19, 2017 07:02
-
-
Save afarah1/24b25e09e87342b07bac8fdd50e3c94f to your computer and use it in GitHub Desktop.
Draws a rectangle divided in half
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ./this width height topRGB bottomRGB | |
* ./this 400 400 FFFF00 000000 | feh - | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int | |
main(int argc, char **argv) | |
{ | |
if (argc != 5) | |
return 1; | |
int w = atoi(argv[1]), | |
h = atoi(argv[2]), | |
top = strtol(argv[3], 0, 16), | |
bottom = strtol(argv[4], 0, 16); | |
printf("P3 %d %d 255 ", w, h); | |
for (int i = 0; i < h; i++) | |
for (int j = 0; j < w; j++) | |
if ((i * w) - (j * h) > 0) | |
printf("%d %d %d ", top >> 16, top >> 8 & 0xFF, top & 0xFF); | |
else | |
printf("%d %d %d ", bottom >> 16, bottom >> 8 & 0xFF, bottom & 0xFF); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment