I have drawn a Diamond/rhombus in C, but I don't now how i can fill the shape in, any ideas?
Code:
#include <stdio.h>
#include <gd.h>
int main()
{
/* Declare and initialise variables for a new image.
These steps are done once before using drawing functions. */
gdImagePtr gdImage = gdImageCreate( 300, 300 );
FILE *jpgFile = NULL;
int red;
/* The first call to gdImageColorAllocate() always sets the image background.
This step can only be done once before using drawing functions. */
gdImageColorAllocate( gdImage, 250, 250, 250 );
/* Subsequent calls to gdImageColorAllocate() creates new colors for drawing.
It is similar using a paint brush with a specific color. The brush can be
used over and over. This is only needed each time a new color is required. */
red = gdImageColorAllocate( gdImage, 255, 0, 0 );
/* Most of the work is done by using drawing functions.
These functions set the line width to 4 and draws a diagonal line. */
gdImageSetThickness( gdImage, 2 );
gdImageLine( gdImage, 150, 0, 0, 150, red );
gdImageSetThickness( gdImage, 2 );
gdImageLine( gdImage, 150, 0, 300, 150, red );
gdImageSetThickness( gdImage, 2 );
gdImageLine( gdImage, 150, 300, 0, 150, red );
gdImageSetThickness( gdImage, 2 );
gdImageLine( gdImage, 300, 150, 150, 300, red );
/* These steps save the image in memory out to a physical file on the server.
These steps are done once when the drawing is done. */
jpgFile = fopen( "test.jpg", "wb" );
gdImageJpeg( gdImage, jpgFile, -1 );
/* These steps clear all memory and files used with the image.
These steps are done once when the image is no longer used. */
fclose( jpgFile );
gdImageDestroy( gdImage );
}