Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void make_header(int w, int h);
- void print_Row (float yValue, int w, int h);
- void make_pixel (unsigned char r, unsigned char g, unsigned char b);
- void make_header(int w, int h){
- fprintf(stdout,"P6\n");
- fprintf(stdout,"%d %d 255\n", w, h);
- }
- void print_Row(float yValue, int w, int h)
- {
- int count;
- for(count=0; count<yValue; count++)
- {
- make_pixel(255,0,0);
- }
- for(count=count; count<w-yValue; count++)
- {
- make_pixel(0,255,0);
- }
- for(count=count; count<w; count++)
- {
- make_pixel(0,0,255);
- }
- }
- void make_pixel (unsigned char r, unsigned char g, unsigned char b)
- {
- fprintf(stdout,"%c%c%c", r,g,b);
- }
- int main()
- {
- float slope1, slope2, wmid, hmid, yValue ;
- int w, h, count=0;
- fprintf(stderr, "\nEnter a width: ");
- scanf("%d", &w);
- fprintf(stderr, "\nEnter a height: ");
- scanf("%d", &h);
- make_header (int w, int h);
- wmid = w / 2;
- hmid = h / 2;
- slope1 = (hmid)/(wmid);
- slope2 = 1/slope1;
- for(count=0; count<hmid; count++)
- {
- if(count>slope1 && count>slope2) {
- make_pixel(255, 0, 0);
- }
- else if(count>slope1 && count<slope2) {
- make_pixel(0, 255, 0);
- }
- else if(count<slope1 && count>slope2) {
- make_pixel(0, 0, 255);
- }
- for(count=hmid; count<h; count++)
- {
- if(count
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement