Customized line drawing

Customized line drawing — Thick and dashed line drawing primitives

Functions

Types and Values

Includes

#include <grx-3.0.h>

Description

The basic line drawing graphics primitives described previously always draw continuous lines which are one pixel wide. This group of line drawing functions can be used to draw wide and/or patterned lines. These functions have similar parameter passing conventions as the basic ones with one difference: instead of the color value a GrxLineOptions is passed instead.

Functions

grx_draw_line_with_options ()

void
grx_draw_line_with_options (gint x1,
                            gint y1,
                            gint x2,
                            gint y2,
                            const GrxLineOptions *o);

Draws a line on the current context from the starting coordinates to the ending coordinates using the specified options.

Parameters

x1

starting X coordinate

 

y1

starting Y coordinate

 

x2

ending X coordinate

 

y2

ending Y coordinate

 

o

the options

 

grx_draw_box_with_options ()

void
grx_draw_box_with_options (gint x1,
                           gint y1,
                           gint x2,
                           gint y2,
                           const GrxLineOptions *o);

Draws a rectangle on the current context using the specified coordinates and options.

Parameters

x1

the left X coordinate

 

y1

the top Y coordinate

 

x2

the right X coordinate

 

y2

the bottom Y coordinate

 

o

the options

 

grx_draw_circle_with_options ()

void
grx_draw_circle_with_options (gint xc,
                              gint yc,
                              gint r,
                              const GrxLineOptions *o);

Draws a circle on the current context centered at the specified coordinates with the specified radius and options.

Parameters

xc

the X coordinate of the center of the circle

 

yc

the Y coordinate of the center of the circle

 

r

the radius of the circle

 

o

the options

 

grx_draw_ellipse_with_options ()

void
grx_draw_ellipse_with_options (gint xc,
                               gint yc,
                               gint rx,
                               gint ry,
                               const GrxLineOptions *o);

Draws an ellipse on the current context using the specified options.

The ellipse can only draw ellipses with its major axis parallel with either the X or Y coordinate axis

Parameters

xc

the X coordinate of the center of the ellipse

 

yc

the Y coordinate of the center of the ellipse

 

rx

the radius in the X direction

 

ry

the radius in the Y direction

 

o

the options

 

grx_draw_circle_arc_with_options ()

void
grx_draw_circle_arc_with_options (gint xc,
                                  gint yc,
                                  gint r,
                                  gint start,
                                  gint end,
                                  GrxArcStyle style,
                                  const GrxLineOptions *o);

Draws an arc on the current context centered at the specified coordinates from the starting angle to the ending angle with the specified radius, arc style and options.

Parameters

xc

the X coordinate of the center of the arc

 

yc

the Y coordinate of the center of the arc

 

r

the radius of the arc

 

start

the starting angle in 1/10ths of degrees

 

end

the ending angle in 1/10ths of degrees

 

style

the arc style

 

o

the options

 

grx_draw_ellipse_arc_with_options ()

void
grx_draw_ellipse_arc_with_options (gint xc,
                                   gint yc,
                                   gint rx,
                                   gint ry,
                                   gint start,
                                   gint end,
                                   GrxArcStyle style,
                                   const GrxLineOptions *o);

Draws an arc on the current context centered at the specified coordinates from the starting angle to the ending angle with the specified radii, arc style and options.

Parameters

xc

the X coordinate of the center of the arc

 

yc

the Y coordinate of the center of the arc

 

rx

the radius in the X direction

 

ry

the radius in the Y direction

 

start

the starting angle in 1/10ths of degrees

 

end

the ending angle in 1/10ths of degrees

 

style

the arc style

 

o

the options

 

grx_draw_polyline_with_options ()

void
grx_draw_polyline_with_options (gint n_points,
                                GrxPoint *points,
                                const GrxLineOptions *o);

Draw a multi-segment line on the current context that connects each point in the points array using the specified options.

Parameters

n_points

the number of points in points

 

points

an array of GrxPoint.

[array length=n_points]

o

the options

 

grx_draw_polygon_with_options ()

void
grx_draw_polygon_with_options (gint n_points,
                               GrxPoint *points,
                               const GrxLineOptions *o);

Draw a closed polygon on the current context that connects each point in the points array using the specified options.

Coordinate arrays can either contain or omit the closing edge of the polygon. It will be automatically appended to the list if it is missing.

Parameters

n_points

the number of points in points

 

points

an array of GrxPoint.

[array length=n_points]

o

the options

 

Types and Values

GrxLineOptions

typedef struct {
    GrxColor color;
    gint     width;
    gint     n_dash_patterns;
    guint8   dash_pattern0;
    guint8   dash_pattern1;
    guint8   dash_pattern2;
    guint8   dash_pattern3;
    guint8   dash_pattern4;
    guint8   dash_pattern5;
    guint8   dash_pattern6;
    guint8   dash_pattern7;
} GrxLineOptions;

Custom line options structure.

Zero or one dash pattern length means the line is continuous. The dash pattern always begins with a drawn section.

Example, a white line 3 pixels wide (thick) and pixmap 6 pixels draw, 4 pixels nodraw:

GrxLineOptions my_line_options;
...
my_line_options.color = GRX_COLOR_WHITE;
my_line_options.width = 3;
my_line_options.n_dash_patterns = 2;
my_line_options.dash_pattern0 = 6;
my_line_options.dash_pattern1 = 4;
...

Members

GrxColor color;

color used to draw line

 

gint width;

width of the line

 

gint n_dash_patterns;

length of the dash pattern

 

guint8 dash_pattern0;

draw/nodraw pattern

 

guint8 dash_pattern1;

draw/nodraw pattern

 

guint8 dash_pattern2;

draw/nodraw pattern

 

guint8 dash_pattern3;

draw/nodraw pattern

 

guint8 dash_pattern4;

draw/nodraw pattern

 

guint8 dash_pattern5;

draw/nodraw pattern

 

guint8 dash_pattern6;

draw/nodraw pattern

 

guint8 dash_pattern7;

draw/nodraw pattern