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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#include <iostream>
#include "csufmedia.h"
#include <cmath>
using namespace std;
int main()
{
load_canvas("donuts.ppm");
int x, y;
for (x = 0; x < canvas_width(); x++) // loop through every x coordinate
{
for (y = 0; y < canvas_height(); y++) // and through every y coordinate
{
// get the red, green, and blue intensities for the pixel at
// coordinate (x, y)
double r = get_red(x, y),
g = get_green(x, y),
b = get_blue(x, y);
// compute new RGB intensities
double new_r = 1 - r, // Inversion. You will need different code here
new_g = 1 - g, // to do posterization.
new_b = 1 - b;
// Update the color of the pixel in the canvas.
set_pixel(x, y, new_r, new_g, new_b);
}
}
// border
rectangle(0, 0, // left side
10, 1024, // width: 10 pixels, height: 1024 pixels
.99, .89, .65); // beige
rectangle(802, 0, // right side
10, 1024, // width: 10 pixels, height: 1024 pixels
.99, .89, .65); // beige
rectangle(0, 0, // top
812, 10, // width: 812 pixels, height: 10 pixels
.99, .89, .65); // beige
rectangle(0, 1014, // bottom
812, 10, // width: 812 pixels, height: 10 pixels
.99, .89, .65); // beige
//rectangle
rectangle(10, 914, // bottom
792, 100, // width: 792 pixels, height: 100 pixels
0, .19, .30); // navy
// H in hope
rectangle(327, 924, // right leg
10, 80, // width: 10 pixels, height: 80 pixels
.44, .59, .62); // light blue
rectangle(287, 959, // middle
40, 10, // width: 40 pixels, height: 10 pixels
.44, .59, .62); // light blue
rectangle(277, 924, // left leg
10, 80, // width: 10 pixels, height: 80 pixels
.44, .59, .62); // light blue
// O in hope
vertical_semicircle(387, 924, // right side
30, // inner radius: 30 pixels
40, // outer radius: 40 pixels
true, // make it leftward
.44, .59, .62); // light blue
vertical_semicircle(347, 924, // left side
30, // inner radius: 30 pixels
40, // outer radius: 40 pixels
false, // make it rightward not leftward
.44, .59, .62); // light blue
// P
rectangle(437, 924, // leg
10, 80, // width: 10 pixels, height: 80 pixels
.44, .59, .62); // light blue
vertical_semicircle(447, 924, // half circle of P
20, // inner radius: 20 pixels
30, // outer radius: 30 pixels
true, // make it rightward not leftward
.44, .59, .62); // light blue
// E
rectangle(487, 924, // leg
10, 80, // width: 10 pixels, height: 80 pixels
.44, .59, .62); // light blue
rectangle(497, 959, // top
30, 10, // width:30 pixels, height: 10 pixels
.44, .59, .62); // light blue
rectangle(497, 924, // middle
30, 10, // width: 30 pixels, height: 10 pixels
.44, .59, .62); // light blue
rectangle(497, 994, // bottom
30, 10, // width: 30 pixels, height: 10 pixels
.44, .59, .62); // light blue
save_canvas("donuts2.ppm");
return 0;
}
|