mateprint.Context

Main object of MatePrint

## Synopsis

        mateprint.Context
        gobject.GObject

    	   mateprint.Context
    	   config

    	    newpath

            moveto
            x
            y

            lineto
            x
            y

            curveto
            x1
            y1
            x2
            y2
            x3
            y3

            closepath

            strokepath

            bpath
            bpath
            append

            vpath
            vpath
            append

            arcto
            x
            y
            radius
            angle1
            angle2
            direction

            setrgbcolor
            r
            g
            b

            setopacity
            opacity

            setlinewidth
            width

            setmiterlimit
            limit

            setlinejoin
            join_type

            setlinecap
            cap_type

            setdash
            n_values
            values
            offset

            setfont
            font

            clip

            eoclip

            concat
            matrix

            scale
            sx
            sy

            rotate
            theta

            translate
            x
            y

            gsave

            grestore

            fill

            eofill

            stroke

            show
            text

            show_sized
            text
            bytes

            glyphlist
            glyphlist

            grayimage
            data
            width
            height
            rowstride

            rgbimage
            data
            width
            height
            rowstride

            rgbaimage
            data
            width
            height
            rowstride

            beginpage
            name

            showpage
            name

            line_stroked
            x0
            y0
            x1
            y1

            rect_stroked
            x
            y
            width
            height

            rect_filled
            x
            y
            width
            height

## Ancestry

    +-- gobject.GObject
      +-- mateprint.Context

## Description

## Constructor

    	  mateprint.Context
    	  config

`config` :

- a `mateprint.Config`.

Returns :

- a new `mateprint.Context`.

Creates a new `mateprint.Context` object.

## Methods

### mateprint.Context.newpath

                    newpath

`config` :

- a `mateprint.Config`.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `newpath`() method resets currentpath to empty path. As currentpoint is defined as the last point of open path segment, is also erases currentpoint.

### mateprint.Context.moveto

                    moveto
                        x
                    y

`x` :

- X position in user coordinates.

`y` :

- Y position in user coordinates.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `moveto`() method starts new subpath in currentpath with coordinates x,y. Moves currentpoint to x,y.

### mateprint.Context.lineto

                    lineto
                    x
                    y

`x` :

- X position in user coordinates.

`y` :

- Y position in user coordinates.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `moveto`() method adds new straight line segment from currentpoint to x,y to currentpath. Moves currentpoint to x,y. If currentpoint is not defined, returns MATE_PRINT_ERROR_NOCURRENTPOINT.

### mateprint.Context.curveto

                    curveto
                    x1
                    y1
                    x2
                    y2
                    x3
                    y3

`x1` :

- X position of first control point in user coordinates.

`y1` :

- Y position of first control point in user coordinates.

`x2` :

- X position of second control point in user coordinates.

`y2` :

- Y position of second control point in user coordinates.

`x3` :

- X position of third control point in user coordinates.

`y3` :

- Y position of third control point in user coordinates.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `curveto`() method adds new cubig bezier segment with control points x1,y1 and x2,y2 and endpoint x3,y3 to currentpath. Moves currentpoint to x3,y3. If currentpoint is not defined, returns MATE_PRINT_ERROR_NOCURRENTPOINT.

### mateprint.Context.closepath

                    closepath

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `closepath`() method closes the last segment of currentpath, optionally drawing straight line segment from its endpoint to starting point. Erases currentpoint. If currentpath is empty, returns MATE_PRINT_ERROR_NOCURRENTPATH.

### mateprint.Context.strokepath

                    strokepath

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `strokepath`() method converts currentpath to new path, that is identical to area painted by mate_print_stroke function, using currentpath. I.e. strokepath followed by fill giver result identical to stroke. If currentpath is empty, returns MATE_PRINT_ERROR_NOCURRENTPATH. Stroked path is always closed, so currentpoint is erased.

### mateprint.Context.bpath

                    bpath
                    bpath
                    append

`bpath` :

- a list of ArtBpath segments

`append` :

- whether to append to currentpath

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `bpath`() method adds all bpath segments up to ART_END to currentpath. If append is false, currentpath is cleared first, otherwise segments are appended to existing path. This is identical to adding all segments by hand, so the final state of currentpoint depends on segments processed.

### mateprint.Context.vpath

                    vpath
                    vpath
                    append

`vpath` :

- a list of ArtVpath segments

`append` :

- whether to append to currentpath

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `vpath`() method adds all vpath line segments up to ART_END to currentpath. If append is false, currentpath is cleared first, otherwise segments are appended to existing path. This is identical to adding all segments by hand, so the final state of currentpoint depends on segments processed.

### mateprint.Context.arcto

                    arcto
                    x
                    y
                    radius
                    angle1
                    angle2
                    direction

`x` :

- X position of control point in user coordinates.

`y` :

- Y position of control point in user coordinates.

`radius` :

- the radius of the arc.

`angle1` :

- start angle in degrees.

`angle2` :

- end angle in degrees.

`direction` :

- direction of movement, 0 counterclockwise 1 clockwise.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `arcto`() method adds an arc with control points x and y with a radius radius and from angle1 to andgle2 in degrees. direction 1 is clockwise 0 counterclockwise

### mateprint.Context.setrgbcolor

                    setrgbcolor
                    r
                    g
                    b

`r` :

- Red channel value.

`g` :

- Green channel value.

`b` :

- Blue channel value.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setrgbcolor`() method sets color in graphic state to RGB triplet. This does not imply anything about which colorspace is used internally. Channel values are clamped to 0.0 - 1.0 region, 0.0 meaning minimum.

### mateprint.Context.setopacity

                    setopacity
                    opacity

`opacity` :

- opacity value.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setopacity`() method sets painting opacity in graphic state to given value. Value is clamped to 0.0 - 1.0 region, 0.0 meaning full transparency and 1.0 completely opaque paint.

### mateprint.Context.setlinewidth

                    setlinewidth
                    width

`width` :

- line width in user coordinates.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setlinewidth`() method sets line width in graphic state to given value. Value is given in user coordinates, so effective line width depends on CTM at the moment of stroke or strokepath. Line width is always uniform in all directions, regardless of stretch factor of CTM. Default line width is 1.0 in user coordinates.

### mateprint.Context.setmiterlimit

                    setmiterlimit
                    limit

`limit` :

- miter limit in degrees.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setmiterlimit`() method sets minimum angle between two lines, in which case miter join is used. For smaller angles, join is beveled. Default miter limit is 4 degrees.

### mateprint.Context.setlinejoin

                    setlinejoin
                    join_type

`join_type` :

- integer indicating join type.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setlinejoin`() method sets join type for non-colinear line segments. 0 - miter 1 - round 2 - bevel Default join type is miter.

### mateprint.Context.setlinecap

                    setlinecap
                    cap_type

`cap_type` :

- integer indicating cap type.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setlinecap`() method sets cap type for line endpoints. 0 - butt 1 - round 2 - square Default cap type is butt.

### mateprint.Context.setdash

                    setdash
                    n_values
                    values
                    offset

`n_values` :

- number of dash segment lengths.

`values` :

- nrray of dash segment lengths.

`offset` :

- line starting offset in dash.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setdash`() method sets line dashing to given pattern. If n_dash is odd, the result is, as if actual number of segments is 2 times bigger, and 2 copies of dash arrays concatenated. If n_values is 0, line is set solid. Dash segment lengths are given in user coordinates, so the actual dash lengths depend on CTM at the time of stroke or strokepath. Dashing is always uniform in all directions, regardless of the stretching factor of CTM. Default is solid line.

### mateprint.Context.setfont

                    setfont
                    font

`font` :

- MateFont to use for text.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `setfont`() method sets font in graphic state. Font is referenced by mate print, so caller may discard it immediately afterwards. Default font is system dependent.

### mateprint.Context.clip

                    clip

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `clip`() method defines drawing region as inside area of currentpath. If path is self-intersecting or consists of several overlapping subpaths, nonzero rule is used to define the inside orea of path. All open subpaths of currentpath are closed. If currentpath is empty, MATE_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.

### mateprint.Context.eoclip

                    eoclip

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `erclip`() method defines drawing region as inside area of currentpath. If path is self-intersecting or consists of several overlapping subpaths, even-odd rule is used to define the inside area of path. All open subpaths of currentpath are closed. If currentpath is empty, MATE_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.

### mateprint.Context.concat

                    concat
                    matrix

`matrix` :

- 3x2 affine transformation matrix.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `concat`() method appends matrix to current transformation matrix (CTM). The resulting transformation from user coordinates to page coordinates is, as if coordinates would first be transformed by matrix, and the results by CTM. Matrix is given in column order, i.e. X' = X * m[0] + Y * m[2] + m[4] Y' = X * m[1] + Y * m[3] + m[5]

### mateprint.Context.scale

                    scale
                    sx
                    sy

`sx` :

- X scale.

`sy` :

- Y scale.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `scale`() method scales user coordinate system by given X and Y values.

### mateprint.Context.rotate

                    rotate
                    theta

`theta` :

- angle in degrees.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `scale`() method rotates user coordinate system theta degrees counterclockwise.

### mateprint.Context.translate

                    translate
                    x
                    y

`x` :

- new starting X.

`y` :

- new starting Y.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `translate`() method move the starting point of user coordinate system to given point.

### mateprint.Context.gsave

                    gsave

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `gsave`() method saves current graphic state (transformation, color, line properties, font) into stack (push). Values itself remain unchanged. You can later restore saved values, using grestore, but not over page boundaries. Graphic state stack has to be cleared for each showpage, i.e. the number of gsave has to match the number of grestore for each page.

### mateprint.Context.grestore

                    grestore

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `grestore`() method retrieves last saved graphic state from stack (pop). Stack has to be at least the size of one.

### mateprint.Context.fill

                    fill

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `fill`() method fills the inside area of currentpath, using current graphic state. If path is self-intersecting or consists of several overlapping subpaths, nonzero rule is used to define the inside area of path. All open subpaths of currentpath are closed. If currentpath is empty, MATE_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.

### mateprint.Context.eofill

                    eofill

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `eofill`() method fills the inside area of currentpath, using current graphic state. If path is self-intersecting or consists of several overlapping subpaths, even-odd rule is used to define the inside area of path. All open subpaths of currentpath are closed. If currentpath is empty, MATE_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.

### mateprint.Context.stroke

                    stroke

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `stroke`() method strokes currentpath, i.e. draws line along it, with style, defined by current graphic state values. If currentpath is empty, MATE_PRINT_ERROR_NOCURRENTPATH is returned. Currentpath is emptied by this function.

### mateprint.Context.show

                    show
                    text

`text` :

- Null-terminated UTF-8 string.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `show`() method draws UTF-8 text at currentpoint, using current font from graphic state. Input text is validated, and MATE_PRINT_ERROR_BADVALUE returned, if it is not valid UTF-8. Both currentpath and currentpoint are erased.

### mateprint.Context.show_sized

                    show_sized
                    text
                    bytes

`text` :

- UTF-8 text string.

`bytes` :

- number of bytes to use from string.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `show_sized`() method draws UTF-8 text at currentpoint, using current font from graphic state. Input text is validated, and MATE_PRINT_ERROR_BADVALUE returned, if it is not valid UTF-8. Both currentpath and currentpoint are erased.

### mateprint.Context.glyphlist

                    glyphlist
                    text

`glyphlist` :

- MateGlyphList text object.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `glyphlist`() method draws text, using MateGlyphList rich text format. Glyphlist is rendered in user coordinates, starting from currentpoint. Both currentpath and currentpoint are erased.

### mateprint.Context.grayimage

                    grayimage
                    data
                    width
                    height
                    rowstride

`data` :

- pointer to image pixel buffer.

`width` :

- image buffer width.

`height` :

- image buffer height.

`rowstride` :

- image buffer rowstride.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `grayimage`() method draws grayscale image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 1 byte per pixel, with value 255 marking white and 0 black.

### mateprint.Context.rgbimage

                    rgbimage
                    data
                    width
                    height
                    rowstride

`data` :

- pointer to image pixel buffer.

`width` :

- image buffer width.

`height` :

- image buffer height.

`rowstride` :

- image buffer rowstride.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `rgbimage`() method draws RGB color image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 3 bytes per pixel, order RGB, with value 255 marking maximum and 0 minimum value.

### mateprint.Context.rgbaimage

                    rgbaimage
                    data
                    width
                    height
                    rowstride

`data` :

- pointer to image pixel buffer.

`width` :

- image buffer width.

`height` :

- image buffer height.

`rowstride` :

- image buffer rowstride.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `rgbaimage`() method draws RGB color image with transparency channel image into unit square (0,0 - 1,1) in current coordinate system. Image buffer has to be 4 bytes per pixel, order RGBA, with value 255 marking maximum and 0 minimum value. Alpha value 255 means full opacity, 0 full transparency.

### mateprint.Context.beginpage

                    beginpage
                    name

`name` :

- name of the page, NULL if you just want to use the page number of the page.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `glyphlist`() method starts new output page with name. Naming is used for interactive contexts like MatePrintPreview and Document Structuring Convention conformant PostScript output. This function has to be called before any drawing methods and immediately after each showpage albeit the last one. It also resets graphic state values (transformation, color, line properties, font), so one has to define these again at the beginning of each page.

### mateprint.Context.showpage

                    showpage

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `showpage`() method finishes rendering of current page, and marks it as shown. All subsequent drawing methods will fail, until new page is started with newpage. Printing contexts may process drawing methods differently - some do rendering immediately (like MatePrintPreview), some accumulate all operators to internal stack, and only after showpage is any output produced.

### mateprint.Context.line_stroked

                    line_stroked
                    x0
                    y0
                    x1
                    y1

`x0` :

- X position of start point in user coordinates.

`y0` :

- Y position of start point in user coordinates.

`x1` :

- X position of end point in user coordinates.

`y1` :

- Y position of end point in user coordinates.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `line_stroked`() method is a convenience function to draw a line. Uses stroke to do the actual work.

### mateprint.Context.rect_stroked

                    rect_stroked
                    x
                    y
                    width
                    height

`x` :

- X position of origin of rectangle in user coordinates.

`y` :

- Y position of origin of rectangle in user coordinates.

`width` :

- width of the rectangle.

`height` :

- height of the rectangle.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `rect_stroked`() method is a convenience function to draw a rectangle. Uses stroke to do the actual work.

### mateprint.Context.rect_filled

                    rect_filled
                    x
                    y
                    width
                    height

`x` :

- X position of origin of rectangle in user coordinates.

`y` :

- Y position of origin of rectangle in user coordinates.

`width` :

- width of the rectangle.

`height` :

- height of the rectangle.

Returns :

- MATE_PRINT_OK or positive value on success, negative error code on failure.

The `rect_filled`() method is a convenience function to draw a filled rectangle. Uses stroke to do the actual work.