## GoPattern

GoPattern —

## Synopsis

                GOPattern;
    enum        GOPatternType;
    GOPatternType go_pattern_from_str           (char const *name);
    charconst	* go_pattern_as_str               (GOPatternType pattern);
    gboolean    go_pattern_is_solid             (GOPattern const *pat,
                                                 GOColor *color);
    void        go_pattern_set_solid            (GOPattern *pat,
                                                 GOColor fore);
    void        go_pattern_render_svp           (GOPattern const *pat,
                                                 ArtSVP const *svp,
                                                 int x0,
                                                 int y0,
                                                 int x1,
                                                 int y1,
                                                 art_u8 *buf,
                                                 int rowstride);
    guint8const 	* go_pattern_get_pattern       (GOPattern const *pat);
    char*       go_pattern_get_svg_path         (GOPattern const *pattern,
                                                 double *width,
                                                 double *height);
    gpointer    go_pattern_selector             (GOColor fore,
                                                 GOColor back,
                                                 GOPatternType default_pat);

## Description

## Details

### GOPattern

    typedef struct {
    	GOColor	 fore, back;
    	unsigned pattern;
    } GOPattern;

### enum GOPatternType

    typedef enum {
    	GO_PATTERN_SOLID,
    	GO_PATTERN_GREY75,
    	GO_PATTERN_GREY50,
    	GO_PATTERN_GREY25,
    	GO_PATTERN_GREY125,
    	GO_PATTERN_GREY625,
    	GO_PATTERN_HORIZ,
    	GO_PATTERN_VERT,
    	GO_PATTERN_REV_DIAG,
    	GO_PATTERN_DIAG,
    	GO_PATTERN_DIAG_CROSS,
    	GO_PATTERN_THICK_DIAG_CROSS,
    	GO_PATTERN_THIN_HORIZ,
    	GO_PATTERN_THIN_VERT,
    	GO_PATTERN_THIN_REV_DIAG,
    	GO_PATTERN_THIN_DIAG,
    	GO_PATTERN_THIN_HORIZ_CROSS,
    	GO_PATTERN_THIN_DIAG_CROSS,
    	GO_PATTERN_FOREGROUND_SOLID,
    	GO_PATTERN_SMALL_CIRCLES,
    	GO_PATTERN_SEMI_CIRCLES,
    	GO_PATTERN_THATCH,
    	GO_PATTERN_LARGE_CIRCLES,
    	GO_PATTERN_BRICKS,
    	GO_PATTERN_MAX
    } GOPatternType;

### go_pattern_from_str ()

    GOPatternType go_pattern_from_str           (char const *name);

`name` : |
Returns : |

### go_pattern_as_str ()

    charconst	* go_pattern_as_str               (GOPatternType pattern);

`pattern` : |
Returns : |

### go_pattern_is_solid ()

    gboolean    go_pattern_is_solid             (GOPattern const *pat,
                                                 GOColor *color);

`pat` : | GOPattern
`color` : | GOColor
Returns : | if `pat` is solid, and stores the color in `color`. If `pat` is not solid `color` is not touched.

### go_pattern_set_solid ()

    void        go_pattern_set_solid            (GOPattern *pat,
                                                 GOColor fore);

Makes `pat` a solid pattern with colour `fore`.

`pat` : | a GOPattern
`fore` : | a GOColor

### go_pattern_render_svp ()

    void        go_pattern_render_svp           (GOPattern const *pat,
                                                 ArtSVP const *svp,
                                                 int x0,
                                                 int y0,
                                                 int x1,
                                                 int y1,
                                                 art_u8 *buf,
                                                 int rowstride);

Renders the shape specified with `svp` over the `buf` RGB buffer. `x1` - `x0` specifies the width, and `y1` - `y0` specifies the height, of the rectangle rendered. The new pixels are stored starting at the first byte of `buf`. Thus, the `x0` and `y0` parameters specify an offset within `svp`, and may be tweaked as a way of doing integer-pixel translations without fiddling with `svp` itself.

The `pat` argument specifies the pattern for the rendering. Pixels of entirely 0 winding number are left untouched. Pixels of entirely 1 winding number have the pattern `pat` composited over them (ie, are replaced by the red, green, blue components of `pat->fore` or `pat->back` depending on the stipple associated with `pat->pattern`. if the alpha component is 0xff). Pixels of intermediate coverage are linearly interpolated.

`pat` : | GOPattern
`svp` : | The source sorted vector path.
`x0` : | Left coordinate of destination rectangle.
`y0` : | Top coordinate of destination rectangle.
`x1` : | Right coordinate of destination rectangle.
`y1` : | Bottom coordinate of destination rectangle.
`buf` : | Destination RGBA buffer.
`rowstride` : | Rowstride of `buf` buffer.

### go_pattern_get_pattern ()

    guint8const 	* go_pattern_get_pattern       (GOPattern const *pat);

`pat` : |
Returns : |

### go_pattern_get_svg_path ()

    char*       go_pattern_get_svg_path         (GOPattern const *pattern,
                                                 double *width,
                                                 double *height);

Retrieves an SVG path as string, which represents pattern shape. Caller is responsible for freeing the resulting string.

If width != NULL, returns pattern width. If height != NULL, returns pattern height.

`pattern` : | a GOPattern
`width` : | pattern width
`height` : | pattern height
Returns : | a char buffer.

### go_pattern_selector ()

    gpointer    go_pattern_selector             (GOColor fore,
                                                 GOColor back,
                                                 GOPatternType default_pat);

`fore` : |
`back` : |
`default_pat` : |
Returns : |