LibGd 2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
lines, ellipses, polygons and Arc Drawing pixel operations

Data Structures

struct  gdPoint
 A point in the coordinate space of the image. More...
 
struct  gdRect
 A rectangle in the coordinate space of the image. More...
 

Macros

#define gdArc   0
 Style flags for drawing arcs and chords Style is a bitwise OR ( | operator ) of these. gdArc and gdChord are mutually exclusive; gdChord just connects the starting and ending angles with a straight line, while gdArc produces a rounded edge. gdPie is a synonym for gdArc. gdNoFill indicates that the arc or chord should be outlined, not filled. gdEdged, used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center; this is a good way to outline (rather than fill) a 'pie slice'.
 
#define gdPie   gdArc
 
#define gdChord   1
 
#define gdNoFill   2
 
#define gdEdged   4
 

Typedefs

typedef struct gdPointgdPointPtr
 
typedef struct gdRectgdRectPtr
 

Functions

void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 Draws a closed polygon.
 
void gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 Draws an open polygon.
 
void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 Draws a filled polygon.
 
void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
 Draws a filled arc or a filled chord.
 
void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
 Draws an arc or a chord.
 
void gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
 Draw an ellipse, stroke only.
 
void gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
 Draw a filled ellipse.
 
void gdImageAABlend (gdImagePtr im)
 
void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
 Draws a rectangle.
 
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
 Draws a filled rectangle.
 
void gdImageSetClip (gdImagePtr im, int x1, int y1, int x2, int y2)
 Sets the clipping rectangle.
 
void gdImageGetClip (gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
 Gets the current clipping rectangle.
 
void gdImageSetBrush (gdImagePtr im, gdImagePtr brush)
 Sets the brush for following drawing operations.
 
void gdImageSetTile (gdImagePtr im, gdImagePtr tile)
 Sets the tile for following drawing operations.
 
void gdImageSetAntiAliased (gdImagePtr im, int c)
 Set the color for subsequent anti-aliased drawing.
 
void gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend)
 
void gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels)
 Sets the style for following drawing operations.
 
void gdImageSetThickness (gdImagePtr im, int thickness)
 

Detailed Description

Note
2.4+ brings a 2D Vector APIs with high quality rendering and options. Similar to Canvas 2D APIs. We recommend it for new usages.

Macro Definition Documentation

◆ gdArc

#define gdArc   0

Style flags for drawing arcs and chords Style is a bitwise OR ( | operator ) of these. gdArc and gdChord are mutually exclusive; gdChord just connects the starting and ending angles with a straight line, while gdArc produces a rounded edge. gdPie is a synonym for gdArc. gdNoFill indicates that the arc or chord should be outlined, not filled. gdEdged, used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center; this is a good way to outline (rather than fill) a 'pie slice'.

mutually exclusive with gdChord

◆ gdChord

#define gdChord   1

mutually exclusive with gdArc

◆ gdEdged

#define gdEdged   4

used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center

◆ gdNoFill

#define gdNoFill   2

indicates that the arc or chord should be outlined, not filled

◆ gdPie

#define gdPie   gdArc

synonym for gdArc

Typedef Documentation

◆ gdPointPtr

typedef struct gdPoint * gdPointPtr

A pointer to a <gdPoint>.

◆ gdRectPtr

typedef struct gdRect * gdRectPtr

A pointer to a gdRect.

Function Documentation

◆ gdImageAABlend()

void gdImageAABlend ( gdImagePtr  im)

Group: Primitives

◆ gdImageArc()

void gdImageArc ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e,
int  color 
)

Draws an arc or a chord.

Parameters
imThe image.
cxThe x-coordinate of the center.
cyThe y-coordinate of the center.
wThe width of the arc.
hThe height of the arc.
sThe starting angle in degrees.
eThe ending angle in degrees.
colorThe color of the arc. A color identifier created with one of the image color allocate functions.
See also
gdImageFilledArc

< indicates that the arc or chord should be outlined, not filled

◆ gdImageEllipse()

void gdImageEllipse ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  color 
)

Draw an ellipse, stroke only.

Note
This function does not support gdImageSetThickness. GD 3.0 supports actual 2D vectors operation, you may rely on it if you need better 2D drawing operations.
Parameters
imThe destination image.
cxx-coordinate of the center.
cyy-coordinate of the center.
wThe ellipse width.
hThe ellipse height.
colorThe color of the ellipse. A color identifier created with one of the image color allocate functions.
See also
gdImageFilledEllipse

◆ gdImageFilledArc()

void gdImageFilledArc ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e,
int  color,
int  style 
)

Draws a filled arc or a filled chord.

Parameters
imThe image.
cxThe x-coordinate of the center.
cyThe y-coordinate of the center.
wThe width of the arc.
hThe height of the arc.
sThe starting angle in degrees.
eThe ending angle in degrees.
colorThe color of the arc. A color identifier created with one of the image color allocate functions.
styleThe style of the arc. A bitwise OR of gdArc,
See also
gdImageArc

< mutually exclusive with gdArc

< indicates that the arc or chord should be outlined, not filled

< mutually exclusive with gdArc

< indicates that the arc or chord should be outlined, not filled

< mutually exclusive with gdArc

< indicates that the arc or chord should be outlined, not filled

< used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center

< indicates that the arc or chord should be outlined, not filled

< used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center

◆ gdImageFilledEllipse()

void gdImageFilledEllipse ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  color 
)

Draw a filled ellipse.

Parameters
imThe destination image.
cxx-coordinate of the center.
cyy-coordinate of the center.
wThe ellipse width.
hThe ellipse height.
colorThe color of the ellipse. A color identifier created with one of the image color allocate functions.

◆ gdImageFilledPolygon()

void gdImageFilledPolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Draws a filled polygon.

The polygon is filled using the even-odd fillrule what can leave unfilled regions inside of self-intersecting polygons. This behavior might change in a future version.

Parameters
imThe image.
pThe vertices as array of <gdPoint>s.
nThe number of vertices.
cThe color.
See also
gdImagePolygon

◆ gdImageFilledRectangle()

void gdImageFilledRectangle ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Draws a filled rectangle.

Parameters
imThe image.
x1The x-coordinate of one of the corners.
y1The y-coordinate of one of the corners.
x2The x-coordinate of another corner.
y2The y-coordinate of another corner.
colorThe color.

◆ gdImageGetClip()

void gdImageGetClip ( gdImagePtr  im,
int *  x1P,
int *  y1P,
int *  x2P,
int *  y2P 
)

Gets the current clipping rectangle.

Parameters
imThe image.
x1P(out) The x-coordinate of the upper left corner.
y1P(out) The y-coordinate of the upper left corner.
x2P(out) The x-coordinate of the lower right corner.
y2P(out) The y-coordinate of the lower right corner.
See also
gdImageSetClip

◆ gdImageOpenPolygon()

void gdImageOpenPolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Draws an open polygon.

Parameters
imThe image.
pThe vertices as array of <gdPoint>s.
nThe number of vertices.
cThe color.
See also
gdImagePolygon

◆ gdImagePolygon()

void gdImagePolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Draws a closed polygon.

Parameters
imThe image.
pThe vertices as array of <gdPoint>s.
nThe number of vertices.
cThe color.
See also
gdImageOpenPolygon gdImageFilledPolygon

◆ gdImageRectangle()

void gdImageRectangle ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Draws a rectangle.

Corners are specified by their coordinates. The rectangle is drawn using the current line style and thickness.

Parameters
imThe image.
x1The x-coordinate of one of the corners.
y1The y-coordinate of one of the corners.
x2The x-coordinate of another corner.
y2The y-coordinate of another corner.
colorThe color.
See also
gdImageFilledRectangle

◆ gdImageSetAntiAliased()

void gdImageSetAntiAliased ( gdImagePtr  im,
int  c 
)

Set the color for subsequent anti-aliased drawing.

If gdAntiAliased is passed as color to drawing operations that support anti-aliased drawing (such as gdImageLine and gdImagePolygon), the actual color to be used can be set with this function.

Example: draw an anti-aliased blue line:

gdImageSetAntiAliased(im, gdTrueColorAlpha(0, 0, gdBlueMax, gdAlphaOpaque));
gdImageLine(im, 10,10, 20,20, gdAntiAliased);
void gdImageSetAntiAliased(gdImagePtr im, int c)
Set the color for subsequent anti-aliased drawing.
Definition gd.c:3203
Write an image as JPEG data to a gdIOCtx.
Parameters
im- The image.
c- The color.
See also
gdImageSetAntiAliasedDontBlend

◆ gdImageSetAntiAliasedDontBlend()

void gdImageSetAntiAliasedDontBlend ( gdImagePtr  im,
int  c,
int  dont_blend 
)

Set the color and "dont_blend" color for subsequent anti-aliased drawing

This extended variant of <gdImageSetAntiAliased> allows to also specify a (background) color that will not be blended in anti-aliased drawing operations.

Parameters
imThe image.
cThe color.
dont_blendWhether to blend.

◆ gdImageSetBrush()

void gdImageSetBrush ( gdImagePtr  im,
gdImagePtr  brush 
)

Sets the brush for following drawing operations.

Parameters
imThe image.
brushThe brush image.

◆ gdImageSetClip()

void gdImageSetClip ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2 
)

Sets the clipping rectangle.

The clipping rectangle restricts the drawing area for following drawing operations.

Parameters
im- The image.
x1- The x-coordinate of the upper left corner.
y1- The y-coordinate of the upper left corner.
x2- The x-coordinate of the lower right corner.
y2- The y-coordinate of the lower right corner.
See also
gdImageGetClip

◆ gdImageSetStyle()

void gdImageSetStyle ( gdImagePtr  im,
int *  style,
int  noOfPixels 
)

Sets the style for following drawing operations.

Parameters
imThe image.
styleAn array of color values.
noOfPixelThe number of color values.

◆ gdImageSetThickness()

void gdImageSetThickness ( gdImagePtr  im,
int  thickness 
)

Sets the thickness for following drawing operations

Parameters
imThe image.
thicknessThe thickness in pixels.

◆ gdImageSetTile()

void gdImageSetTile ( gdImagePtr  im,
gdImagePtr  tile 
)

Sets the tile for following drawing operations.

The tile is used for filling areas with a repeating pattern. The tile image is repeated to fill the area being drawn.

Parameters
imThe image.
tileThe tile image.