Re: [Gnome-print] information about printing a grid



Hello!

I'll write down some explanations, I hope I can use later in
writing real reference/tutorial.

On 31 Jul 2001 17:50:52 +0100, talus wrote:
> please can someone explain me how to draw a table width gnome-print API?
> 
> int gnome_print_newpath (GnomePrintContext *pc);
> int gnome_print_moveto (GnomePrintContext *pc, double x, double y);
> int gnome_print_lineto (GnomePrintContext *pc, double x, double y);
> int gnome_print_curveto (GnomePrintContext *pc, double x1, double y1, 
> double x2, double y2, double x3, double y3);
> int gnome_print_closepath (GnomePrintContext *pc);

Gnome-print (PostScript) drawing model is that of pencil, pen and brush.
Initially you take a pen, and sketch a line.

newpath - start new line (forgetting all previous drawing)
moveto - move pencil without drawing line (starts new standalone part)
lineto - draw straight line
curveto - draw bezier curve (you have to consult some computer graphic
          book, if you do not know, what are bezier curves)
closepath - draw line from current pencil position to the begginning of
          segment

> void gnome_print_vpath (GnomePrintContext * gpc, ArtVpath * vpath, 
> gboolean append);
> void gnome_print_bpath (GnomePrintContext * gpc, ArtBpath * bpath, 
> gboolean append);

These are versions, that take libart path description and draw that.
- vpath can have only moveto, lineto and closepath
- bpath can have curveto as well
These are useful, as libart path descriptions are used extensively
for on-screen display (in canvas)

Now drawing path with pencil does not produce anything visible. You
can think it to be a sketch you later erase with rubber.

To actually draw anything you have 2 options:
- trace it with pen, creating LINE
- fill it with brush, creating filled SHAPE

gnome_print_stroke draws a line
gnome_print_(eo)fill fills the inside region of line, creating shape.
The 
difference between fill and eofill is, how the inside is calculated for
self-intersecting line.

> int gnome_print_strokepath (GnomePrintContext *pc);

This is complex operation, that produces new path form existing path,
such
that filling new path is identical to stroking the original one. It is 
seldom used by normal code.

Notice, that stroke and fill erase the original pencil line, so if you
want both filled and stroked line, you have to draw pencil-line
twice (or use gsave/grestore)

> /* Graphic state manipulation */
> 
> int gnome_print_setrgbcolor (GnomePrintContext *pc, double r, double g, 
> double b);
> int gnome_print_setopacity (GnomePrintContext *pc, double opacity);
> int gnome_print_setlinewidth (GnomePrintContext *pc, double width);
> int gnome_print_setmiterlimit (GnomePrintContext *pc, double limit);
> int gnome_print_setlinejoin (GnomePrintContext *pc, int jointype);
> int gnome_print_setlinecap (GnomePrintContext *pc, int captype);
> int gnome_print_setdash (GnomePrintContext *pc, int n_values, const 
> double *values, double offset);

These set current pen/brush settings. Usually you are only intereseted
in color and line width. Setting these once remains in effect, until
you overwrite given setting, or grestore is encountered

> int gnome_print_setfont (GnomePrintContext *pc, GnomeFont *font);

Sets font for subsequent show operators

> int gnome_print_clip (GnomePrintContext *pc);
> int gnome_print_eoclip (GnomePrintContext *pc);

These generate clipping paths from current pencil path. I.e. nothing is
drawn, and all later drawing operations can only draw into the inside
region of path.
Once set, clipping path can only be cleared by grestore

> /* CTM manipulation */
> 
> int gnome_print_concat (GnomePrintContext *pc, const double matrix[6]);
> int gnome_print_scale (GnomePrintContext *pc, double sx, double sy);
> int gnome_print_rotate (GnomePrintContext *pc, double theta_in_degrees);
> int gnome_print_translate (GnomePrintContext *pc, double x, double y);

These manipulate coordinate transformation. All path composing operators
use user-coordinate system. For convenience this can differ from actual
page coordinate system (72dpi, 0,0 in lower-left).
Transformation is coded as 3x2 double matrix, and this is, what concat
expects. Other three are convenience functions, that generate a commonly
requested effect, using transformation matrixes:

scale - scales user coordinates. I.e. everything drawn will be sx, sy
times
        bigger
rotate - rotates user coordinate system
translate - moves user coordinate system

> /* Stack */

gsave - saves all relevant graphic parameters to stack, i.e.
- current sketched pencil line
- pen and brush parameters
- clip path
- transformation matrix

grestore - restores last saved graphic parameters

These are extremely useful, if you are printing complex documents. Child
objects can be wrappen between gsave/grestore pairs, so changes in
graphic settings cannot affect rendering of parent document.

> i simply don't know what most of this functions is supose to do and how 
> they work?
> I get a printing function with text formatted and  with font of my 
> choice. Now i want to Draw a grid to show information inside can someone 
> tellme how can i do this because I'm no wizard to guess wich function to 
> use and how to use it is there any kind of documentation that i could use?
> thanks

1. Set graphic state (once, unless you want different line styles)
setrgbcolor
setlinewidth

2. Drawing straight line
newpath
moveto
lineto
stroke

3. Repeat (2) until everything is drawn

Hope that helps,
Lauris Kaplinski







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]