Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void make_header(int w, int h);
  4. void print_Row (float yValue, int w, int h);
  5. void make_pixel (unsigned char r, unsigned char g, unsigned char b);
  6.  
  7. void make_header(int w, int h){
  8. fprintf(stdout,"P6\n");
  9. fprintf(stdout,"%d %d 255\n", w, h);
  10. }
  11.  
  12. void print_Row(float yValue, int w, int h)
  13. {
  14. int count;
  15.  
  16. for(count=0; count<yValue; count++)
  17. {
  18. make_pixel(255,0,0);
  19. }
  20.  
  21.  
  22. for(count=count; count<w-yValue; count++)
  23. {
  24. make_pixel(0,255,0);
  25. }
  26.  
  27. for(count=count; count<w; count++)
  28. {
  29. make_pixel(0,0,255);
  30. }
  31. }
  32.  
  33. void make_pixel (unsigned char r, unsigned char g, unsigned char b)
  34. {
  35. fprintf(stdout,"%c%c%c", r,g,b);
  36. }
  37.  
  38. int main()
  39. {
  40. float slope1, slope2, wmid, hmid, yValue ;
  41.  
  42. int w, h, count=0;
  43.  
  44. fprintf(stderr, "\nEnter a width: ");
  45. scanf("%d", &w);
  46. fprintf(stderr, "\nEnter a height: ");
  47. scanf("%d", &h);
  48. make_header (int w, int h);
  49.  
  50. wmid = w / 2;
  51. hmid = h / 2;
  52. slope1 = (hmid)/(wmid);
  53. slope2 = 1/slope1;
  54.  
  55. for(count=0; count<hmid; count++)
  56. {
  57. if(count>slope1 && count>slope2) {
  58. make_pixel(255, 0, 0);
  59. }
  60. else if(count>slope1 && count<slope2) {
  61. make_pixel(0, 255, 0);
  62. }
  63. else if(count<slope1 && count>slope2) {
  64. make_pixel(0, 0, 255);
  65. }
  66. for(count=hmid; count<h; count++)
  67. {
  68. if(count
  69. }
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement