Pattern filled graphics primitives

Pattern filled graphics primitives — Patterned drawing and filling primitives

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── GrxPixmap

Includes

#include <grx-3.0.h>

Description

The library also supports a pattern filled version of the basic filled primitives described above. These functions have similar parameter passing conventions as the basic ones with one difference: instead of the color value a GrxPixmap has to be passed to them.

Functions

grx_pixmap_new ()

GrxPixmap *
grx_pixmap_new (const guint8 *pixels,
                gint w,
                gint h,
                const GArray *colors);

Build a pixmap from pixels .

The elements of the pixels array are used as indices in colors . This means that pixmaps created this way can use at most 256 colors. NOTE: any color modifiers (GrXOR, GrOR, GrAND) OR-ed to the elements of the color table are ignored.

Parameters

pixels

a two dimensional array of bytes.

[array]

w

the width of the pixel array

 

h

the height of the pixel array

 

colors

color table for the pixel array.

[element-type GrxColor][nullable]

Returns

a new GrxPixmap or NULL if there was an error.

[nullable]


grx_pixmap_new_from_bits ()

GrxPixmap *
grx_pixmap_new_from_bits (const guint8 *bits,
                          gint w,
                          gint h,
                          GrxColor fg,
                          GrxColor bg);

Builds a pixmap fill pattern from bitmap data. It is useful if the width of the bitmap pattern is not eight as such bitmap patterns can not be used to build a GrBitmap structure.

Parameters

bits

the bitmap data

 

w

the width of the bitmap data

 

h

the height of the bitmap data

 

fg

the forground color

 

bg

the background color

 

Returns

a new GrxPixmap or NULL if there was an error.

[nullable]


grx_pixmap_new_from_context ()

GrxPixmap *
grx_pixmap_new_from_context (GrxContext *context);

Converts a graphics context to a pixmap fill pattern.

This is useful when the pixmap can be created with graphics drawing operations. NOTE: the pixmap pattern and the original context share the drawing RAM, thus if the context is redrawn the fill pattern changes as well.

Parameters

context

the context

 

Returns

a new GrxPixmap or NULL if there was an error.

[nullable]


grx_pixmap_copy ()

GrxPixmap *
grx_pixmap_copy (GrxPixmap *pixmap);

Make a copy of pixmap .

Parameters

pixmap

the pixmap

 

Returns

a new GrxPixmap.


grx_pixmap_free ()

void
grx_pixmap_free (GrxPixmap *pixmap);

Frees any dynamically allocated memory associated with the pixmap.

Parameters

pixmap

the pixmap

 

grx_pixmap_mirror ()

GrxPixmap *
grx_pixmap_mirror (GrxPixmap *pixmap,
                   GrxPixmapMirrorFlags flags);

Creates a new pixmap, flipping left-right and/or top-bottom as indicated by flags .

Parameters

pixmap

the source pixmap

 

flags

the mirror flags

 

Returns

the new pixmap.

[transfer full]


grx_pixmap_stretch ()

GrxPixmap *
grx_pixmap_stretch (GrxPixmap *pixmap,
                    gint new_width,
                    gint new_height);

Creates a new pixmap stretching pixmap to new_width by new_height .

Parameters

pixmap

the source pixmap

 

new_width

the new width

 

new_height

the new height

 

Returns

the new pixmap.

[transfer full]


grx_draw_pixmap ()

void
grx_draw_pixmap (gint x,
                 gint y,
                 GrxPixmap *p);

Draws the entire image on the current context with the top, left corner at x , y .

Parameters

x

the left edge

 

y

the top edge

 

p

the pixmap

 

grx_draw_pixmap_tiled ()

void
grx_draw_pixmap_tiled (gint x1,
                       gint y1,
                       gint x2,
                       gint y2,
                       GrxPixmap *p);

Draws as much of the image as possible (repeating if necessary) on the current in the rectangle defined by x1 , y1 and x2 , y2

Parameters

x1

the left edge

 

y1

the top edge

 

x2

the right edge

 

y2

the bottom edge

 

p

the pixmap

 

grx_draw_pixel_with_offset_pixmap ()

void
grx_draw_pixel_with_offset_pixmap (gint x0,
                                   gint y0,
                                   gint x,
                                   gint y,
                                   GrxPixmap *p);

Draws a single pixel of an pixmap on the current context at x , y .

The color of the pixel comes from the pixmap as if p was tiled over the entrire context starting with the top/left of the pixmap at x0 , y0 .

Parameters

x0

the alignment X coordinate

 

y0

the alignment Y coordinate

 

x

the X coordinate

 

y

the Y coordinate

 

p

the pixmap

 

grx_draw_line_with_pixmap ()

void
grx_draw_line_with_pixmap (gint x1,
                           gint y1,
                           gint x2,
                           gint y2,
                           GrxLineOptions *o,
                           GrxPixmap *p);

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

Parameters

x1

starting X coordinate

 

y1

starting Y coordinate

 

x2

ending X coordinate

 

y2

ending Y coordinate

 

o

the line options

 

p

the pixmap

 

grx_draw_hline_with_offset_pixmap ()

void
grx_draw_hline_with_offset_pixmap (gint x0,
                                   gint y0,
                                   gint x,
                                   gint y,
                                   gint width,
                                   GrxPixmap *p);

Draws a single line of an pixmap on the current context starting at x , y . The pixmap can be offset from the line by specifying x0 , y0 different from x , y . The pixmap is repeated if the width of the line is greater than the width of the pixmap.

Parameters

x0

the alignment X coordinate

 

y0

the alignment Y coordinate

 

x

the top X coordinate

 

y

the left Y coordinate

 

width

the width of the line

 

p

the pixmap

 

grx_draw_box_with_pixmap ()

void
grx_draw_box_with_pixmap (gint x1,
                          gint y1,
                          gint x2,
                          gint y2,
                          GrxLineOptions *o,
                          GrxPixmap *p);

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

Parameters

x1

the left X coordinate

 

y1

the top Y coordinate

 

x2

the right X coordinate

 

y2

the bottom Y coordinate

 

o

the line options

 

p

the pixmap

 

grx_draw_circle_with_pixmap ()

void
grx_draw_circle_with_pixmap (gint xc,
                             gint yc,
                             gint r,
                             GrxLineOptions *o,
                             GrxPixmap *p);

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

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 line options

 

p

the pixmap

 

grx_draw_ellipse_with_pixmap ()

void
grx_draw_ellipse_with_pixmap (gint xc,
                              gint yc,
                              gint rx,
                              gint ry,
                              GrxLineOptions *o,
                              GrxPixmap *p);

Draws an ellipse on the current context using the specified line options and pattern.

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 line options

 

p

the pixmap

 

grx_draw_circle_arc_with_pixmap ()

void
grx_draw_circle_arc_with_pixmap (gint xc,
                                 gint yc,
                                 gint r,
                                 gint start,
                                 gint end,
                                 GrxArcStyle style,
                                 GrxLineOptions *o,
                                 GrxPixmap *p);

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 line options and pixmap.

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 line options

 

p

the pixmap

 

grx_draw_ellipse_arc_with_pixmap ()

void
grx_draw_ellipse_arc_with_pixmap (gint xc,
                                  gint yc,
                                  gint rx,
                                  gint ry,
                                  gint start,
                                  gint end,
                                  GrxArcStyle style,
                                  GrxLineOptions *o,
                                  GrxPixmap *p);

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 line options and pixmap.

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 line options

 

p

the pixmap

 

grx_draw_polyline_with_pixmap ()

void
grx_draw_polyline_with_pixmap (gint n_points,
                               GrxPoint *points,
                               GrxLineOptions *o,
                               GrxPixmap *p);

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

Parameters

n_points

the number of points in points

 

points

an array of GrxPoint.

[array length=n_points]

o

the line options

 

p

the pixmap

 

grx_draw_polygon_with_pixmap ()

void
grx_draw_polygon_with_pixmap (gint n_points,
                              GrxPoint *points,
                              GrxLineOptions *o,
                              GrxPixmap *p);

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

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 line options

 

p

the pixmap

 

grx_draw_filled_pixel_with_pixmap ()

void
grx_draw_filled_pixel_with_pixmap (gint x,
                                   gint y,
                                   GrxPixmap *p);

Draw a single pixel on the current context at the specified coordinates.

The color of the pixel comes from the pixmap as if p was tiled over the entrire context starting with the top/left of the pixmap at 0, 0.

Parameters

x

the X coordinate

 

y

the Y coordinate

 

p

the pixmap

 

grx_draw_filled_line_with_pixmap ()

void
grx_draw_filled_line_with_pixmap (gint x1,
                                  gint y1,
                                  gint x2,
                                  gint y2,
                                  GrxPixmap *p);

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

For horizontal and vertical lines, see grx_draw_hline() and grx_draw_vline().

Parameters

x1

starting X coordinate

 

y1

starting Y coordinate

 

x2

ending X coordinate

 

y2

ending Y coordinate

 

p

the pixmap

 

grx_draw_filled_box_with_pixmap ()

void
grx_draw_filled_box_with_pixmap (gint x1,
                                 gint y1,
                                 gint x2,
                                 gint y2,
                                 GrxPixmap *p);

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

Parameters

x1

the left X coordinate

 

y1

the top Y coordinate

 

x2

the right X coordinate

 

y2

the bottom Y coordinate

 

p

the pixmap

 

grx_draw_filled_box_with_offset_pixmap ()

void
grx_draw_filled_box_with_offset_pixmap
                               (gint x0,
                                gint y0,
                                gint x1,
                                gint y1,
                                gint x2,
                                gint y2,
                                GrxPixmap *p);

Fills the rectangle x1 , y1 , x2 , y2 in the current context with the pixmap. This pixmap can be offset from the rectangle by specifying x0 , y0 different from x1 , y1 . The pixmap is tiled if needed to fill the rectangle.

Parameters

x0

the alignment X coordinate

 

y0

the alignment Y coordinate

 

x1

the top X coordinate

 

y1

the left Y coordinate

 

x2

the right X coordinate

 

y2

the bottom Y coordinate

 

p

the pixmap

 

grx_draw_filled_circle_with_pixmap ()

void
grx_draw_filled_circle_with_pixmap (gint xc,
                                    gint yc,
                                    gint r,
                                    GrxPixmap *p);

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

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

 

p

the pixmap

 

grx_draw_filled_ellipse_with_pixmap ()

void
grx_draw_filled_ellipse_with_pixmap (gint xc,
                                     gint yc,
                                     gint rx,
                                     gint ry,
                                     GrxPixmap *p);

Draws a filled ellipse on the current context using the specified pixmap.

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

 

p

the pixmap

 

grx_draw_filled_circle_arc_with_pixmap ()

void
grx_draw_filled_circle_arc_with_pixmap
                               (gint xc,
                                gint yc,
                                gint r,
                                gint start,
                                gint end,
                                GrxArcStyle style,
                                GrxPixmap *p);

Draws a filled 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 pixmap.

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

 

p

the pixmap

 

grx_draw_filled_ellipse_arc_with_pixmap ()

void
grx_draw_filled_ellipse_arc_with_pixmap
                               (gint xc,
                                gint yc,
                                gint rx,
                                gint ry,
                                gint start,
                                gint end,
                                GrxArcStyle style,
                                GrxPixmap *p);

Draws a filled 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 pixmap.

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

 

p

the pixmap

 

grx_draw_filled_polygon_with_pixmap ()

void
grx_draw_filled_polygon_with_pixmap (gint n_points,
                                     GrxPoint *points,
                                     GrxPixmap *p);

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

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]

p

the pixmap

 

grx_draw_filled_convex_polygon_with_pixmap ()

void
grx_draw_filled_convex_polygon_with_pixmap
                               (gint n_points,
                                GrxPoint *points,
                                GrxPixmap *p);

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

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.

This version is slightly more efficient that grx_draw_filled_polygon() but requires that the polygon is convex. It can also be used to fill some concave polygons whose boundaries do not intersect any horizontal scan line more than twice. It can also be used to fill several disjoint nonoverlapping polygons in a single operation.

Parameters

n_points

the number of points in points

 

points

an array of GrxPoint.

[array length=n_points]

p

the pixmap

 

grx_flood_fill_with_pixmap ()

void
grx_flood_fill_with_pixmap (gint x,
                            gint y,
                            GrxColor border,
                            GrxPixmap *p);

Flood-fills the area of the current context bounded by the color border using x , y as the starting point.

Parameters

x

the starting X coordinate

 

y

the starting Y coordinate

 

border

the color of the border that contains the fill

 

p

the pixmap of the fill

 

Types and Values

enum GrxPixmapMirrorFlags

Flags used by grx_pixmap_mirror().

Members

GRX_PIXMAP_MIRROR_HORIZONTAL

inverse left-right

 

GRX_PIXMAP_MIRROR_VERTICAL

inverse top-bottom

 

GrxPixmap

typedef struct {
} GrxPixmap;

A fill pattern stored in a layout identical to the video RAM for filling using 'bitblt'-s. It is mode dependent, typically one of the library functions is used to build it.