Using The Functions Included In PNGwriter
PNGwriter has many functions to draw useful figures in your images. They'll allow you to add simple figures to your images, without having to figure out how to write the code and optimize it (done that!).
Important Note: Many new functions have been added and they have not yet been documented on the web page. The best place to read about them is the Quick Reference PDF in the Downloads section.
pngwriter::line(int startx, int starty, int endx, int endy, int red, int green, int blue)
|
Draws a line from (startx, starty) to (endx, endy), with the specified colour. |
pngwriter::square(int lowerleftx, int lowerlefty, int upperrightx, int upperrighty, int red, int green, int blue)
|
Draws a rectangle, from giving the coordinates of the lower left and upper right corners, in the specified colour.
|
pngwriter::filledsquare(int lowerleftx, int lowerlefty, int upperrightx, int upperrighty, int red, int green, int blue)
|
Same as before, but the rectangle is solid. |
pngwriter::circle(int centrex, int centreY, int radius, int red, int green, int blue)
|
Draws a circle. |
pngwriter::filledcircle(int centrex, int centreY, int radius, int red, int green, int blue)
|
Draws a filled circle. |
These two images are examples of what can be done with these functions.
one.png
two.png
This is the code that generates them.
#include "pngwriter.h"
#include
#include
int main()
{
int i,j;
pngwriter one(300,300,0,"one.png");
pngwriter two(300,300,0,"two.png");
one.filledsquare(50,100,100,200,0,65535,0);
one.line(150,150,290,290,65535,0,0);
one.line(150,150,10,290,65535,0,0);
one.line(150,150,290,10,65535,0,0);
one.line(150,150,10,10,65535,0,0);
one.line(150,100,150,200,65535,0,0);//Draws the red cross
one.line(100,150,200,150,65535,0,0);
one.square(30,30,250,50,0,65535,65535);
one.filledcircle(100,100,50,65535,0,65535);
one.circle(210,220,10,20000,20000,50000);
one.close();
for(intiter = 1;iter< 300;iter++) //Draws the gradient in the lower left corner
{
two.line(1,300,iter,1,65535-65535*((double)iter)/300.0, 0,65535);
}
for(intiter2 = 0; iter2 < 8; iter2++) //Draws the green circles
{
two.filledcircle(280-25*iter2,250,10,0,65535 - 65535*((double)iter2/7.0),0);
}
for(intiter3 = 120; iter3>0;iter3--)
{
two.filledsquare(70,70,70+iter3,70+iter3,0,0,65535 -65535*((double)iter3/120.0 ));
}
two.close();
return 0;
}
|
|