Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Pastel::Graphics.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Pastel::Graphics 3"
132.TH Pastel::Graphics 3 "2003-04-29" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Pastel::Graphics \- Graphics context.\r
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Pastel;
139.Ve
140.PP
141.Vb 3
142\& my $graphics = Pastel::Graphics->new(...);\r
143\& $graphics->foo();\r
144\& $graphics->bar();
145.Ve
146.PP
147.Vb 1
148\& $graphics->show(); #dump the graphics on STDOUT
149.Ve
150.PP
151.Vb 1
152\& -or-
153.Ve
154.PP
155.Vb 2
156\& my $string = $graphics->get_svg(); # get the graphic as string\r
157\& print $string;
158.Ve
159.SH "DESCRIPTION"
160.IX Header "DESCRIPTION"
161\&\f(CW\*(C`Pastel::Graphics\*(C'\fR is the main workhorse of Pastel. It is equivalent to\r
162Java Graphics2D class. Each program first has to create once instance\r
163of this class, then call methods on this and lastly dump the whole\r
164instance onto \s-1STDOUT\s0 or get it as string.\r
165.PP
166The class provides the graphics context in that it hold all the\r
167necessary informations for drawing any graphics object correctly.\r
168.PP
169All styles like fonts, color and strokes are set into this class by\r
170calling appropriate methods. Shapes and Strings are drawn by calling\r
171\&\f(CW\*(C`draw()\*(C'\fR and \f(CW\*(C`draw_string()\*(C'\fR methods. For a tutorial introduction see\r
172Pastel programming manual.\r
173.PP
174There are certain shortcut methods that are inbuilt into this\r
175module. You can draw shapes without creating additional\r
176objects. Notable among these classes of methods are \f(CW\*(C`draw_3D_rect()\*(C'\fR\r
177and \f(CW\*(C`draw_round_rect()\*(C'\fR which are not availble from the\r
178Pastel::Geometry::Rectangle class.\r
179.SH "CONSTRUCTOR"
180.IX Header "CONSTRUCTOR"
181.Sh "\fInew()\fP"
182.IX Subsection "new()"
183Creates and returns a new \f(CW\*(C`Pastel::Graphics\*(C'\fR object.\r
184.PP
185.Vb 3
186\& Usage : $graphics = Pastel::Graphics->new(-width=>$w,\r
187\& -height=>$h,\r
188\& -DTD =>$dtd );
189.Ve
190.PP
191.Vb 6
192\& Args : $w - Optional. Width of the SVG document in pixels. If not\r
193\& provided default is 800.\r
194\& $h - Optional. Height of the SVG document in pixels. If not\r
195\& provided the default is 600.\r
196\& $dtd - Optional. DTD used for SVG document. You can pass your\r
197\& own DTD.
198.Ve
199.PP
200.Vb 1
201\& Returns: Pastel::Graphics object
202.Ve
203.SH "METHODS"
204.IX Header "METHODS"
205.Sh "\fIset_font()\fP"
206.IX Subsection "set_font()"
207Set the font for all the graphics object. Any string drawn using\r
208\&\f(CW\*(C`draw_string()\*(C'\fR after calling this method will be drawn using the\r
209font presently set using this method. Note that\r
210\&\f(CW\*(C`Pastel::Text::AttributedString\*(C'\fR objects are immune to font\r
211context. To set the font of \f(CW\*(C`Pastel::Text::AttributedString\*(C'\fR you need\r
212to set the font by setting it as attribute of the \f(CW\*(C`AttributedString\*(C'\fR\r
213object.\r
214.PP
215.Vb 1
216\& Usage : set_font($font)
217.Ve
218.PP
219.Vb 1
220\& Args : $font is a Pastel::Font object.
221.Ve
222.PP
223.Vb 1
224\& Returns : Nothing.
225.Ve
226.Sh "\fIset_paint()\fP"
227.IX Subsection "set_paint()"
228Sets the color of the graphics context. Any drawing of shapes or text\r
229will be carried out using the color presently set in the graphics\r
230context. The color can be solid color of Pastel::Color object or a\r
231gradient implementing Pastel::GradientI interface.\r
232.PP
233.Vb 1
234\& Usage : set_paint($color)
235.Ve
236.PP
237.Vb 1
238\& Args : $color is a Pastel::Color or Pastel::GradientI object.
239.Ve
240.PP
241.Vb 1
242\& Returns : Nothing.
243.Ve
244.Sh "\fIset_stroke()\fP"
245.IX Subsection "set_stroke()"
246If the current graphics context has the stroke object set then all\r
247further drawings will be stroked. The stroke color will be the current\r
248color set using \f(CW\*(C`set_paint()\*(C'\fR method. The swith off the stroking you\r
249need to unset the stroke by calling this method without any argument.\r
250.PP
251Because stroking is done using the current color set in the graphics\r
252context, to draw an object with both stroke and fill where the\r
253stroke-color and the fill-color are different, you need to fill the\r
254object first and set a different color before you draw the object. To\r
255draw a rectangle with blue border and red fill you might do this:\r
256.PP
257.Vb 10
258\& $g = Pastel::Graphics->new();\r
259\& $g->set_paint(Pastel::Color->red());\r
260\& $g->set_stroke( Pastel::BasicStroke->new(-width=>5) );\r
261\& my $rect = Pastel::Geometry::Rectangle(\r
262\& -x=>20,-y=>30,\r
263\& -width=>100,-height=>150\r
264\& );\r
265\& $g->fill($rect); # filled with red color\r
266\& $g->set_paint(Pastel::Color->blue());\r
267\& $g->draw($rect);
268.Ve
269.PP
270.Vb 2
271\& Usage : set_stroke($stroke) # set the stroke object\r
272\& set_stroke() # unset stroking
273.Ve
274.PP
275.Vb 1
276\& Args : $stroke is a Pastel::BasicStroke object.
277.Ve
278.PP
279.Vb 1
280\& Returns : Nothing.
281.Ve
282.Sh "\fIget_font()\fP"
283.IX Subsection "get_font()"
284Returns the current font object in the graphics context.\r
285.PP
286.Vb 1
287\& Usage : get_font();
288.Ve
289.PP
290.Vb 1
291\& Args : Nothing.
292.Ve
293.PP
294.Vb 1
295\& Returns : Pastel::Font object.
296.Ve
297.Sh "\fIget_paint()\fP"
298.IX Subsection "get_paint()"
299Returns the current paint object in the graphics context.\r
300.PP
301.Vb 1
302\& Usage : $g->get_paint()
303.Ve
304.PP
305.Vb 1
306\& Args : Nothing.
307.Ve
308.PP
309.Vb 1
310\& Returns : Pastel::Color or object implementing Pastel::GradientI interface.
311.Ve
312.Sh "\fIget_stroke()\fP"
313.IX Subsection "get_stroke()"
314Return the current stroke object in the graphics context. \r
315.PP
316.Vb 1
317\& Usage : get_stroke()
318.Ve
319.PP
320.Vb 1
321\& Args : Nothing.
322.Ve
323.PP
324.Vb 1
325\& Returns : Pastel::BasicStroke object if stroke is set or undef if not set.
326.Ve
327.Sh "\fIdraw_rect()\fP"
328.IX Subsection "draw_rect()"
329Shortcut function to draw a rectangle without creating additional\r
330object. The rectangle is stroked with the current \f(CW\*(C`BasicStroke\*(C'\fR\r
331object. If the \f(CW\*(C`BasicStroke\*(C'\fR is not set then the rectangle is created\r
332using an 1 pixel width line. The color of the line is determined by\r
333the current paint.\r
334.PP
335.Vb 1
336\& Usage : draw_rect($x, $y, $width, $height)
337.Ve
338.PP
339.Vb 4
340\& Args : $x - X coordinate of the top left corner vertice of rectangle.\r
341\& $y - Y coordinate of the top left corner vertice of rectangle.\r
342\& $width - Width of the rectangle.\r
343\& $height- Height of the rectangle.
344.Ve
345.PP
346.Vb 1
347\& Returns : Nothing.
348.Ve
349.Sh "\fIfill_rect()\fP"
350.IX Subsection "fill_rect()"
351Shortcut function to draw a filled rectangle without creating\r
352additional objects. The rectangle is filled with the current paint in\r
353the graphics context.\r
354.PP
355.Vb 1
356\& Usage : fill_rect($x, $y, $width, $height);
357.Ve
358.PP
359.Vb 4
360\& Args : $x - X coordinate of the top left corner of the rectangle.\r
361\& $y - Y coordinate of the top left corner of the rectangle.\r
362\& $width - Width of the rectangle in pixels.\r
363\& $height- Height of the rectangle in pixels.
364.Ve
365.PP
366.Vb 1
367\& Returns : Nothing
368.Ve
369.Sh "\fIdraw_round_rect()\fP"
370.IX Subsection "draw_round_rect()"
371Shortcut fuction to draw open rectangle with rounded corners. The\r
372rectangle is stroked with the current stroke if it is set. Otherwise\r
373it is drawn with 1 pixel width line. The color is determined by the\r
374current paint object.\r
375.PP
376.Vb 2
377\& Usage : draw_round_rect($x, $y, $width, $height,\r
378\& $arc_width, $arc_height);
379.Ve
380.PP
381.Vb 6
382\& Args : $x - X coordinate of the top left hand corner.\r
383\& $y - Y coordinate of the top left hand corner.\r
384\& $width - Width of the rectangle.\r
385\& $height - Height of the rectangle.\r
386\& $arc_width - Horizontal diameter of the arc at the four corners.\r
387\& $arc_height - vertical diameter of the arc at the four corners.
388.Ve
389.PP
390.Vb 1
391\& Returns : Nothing
392.Ve
393.Sh "\fIdraw_fill_round_rect()\fP"
394.IX Subsection "draw_fill_round_rect()"
395Draws a filled rectangle with rounded corners. The rectangle is filled\r
396with the current paint object in the graphics context.\r
397.PP
398.Vb 2
399\& Usage : $g->draw_fill_round_rect($x, $y, $width, $height,\r
400\& $arc_width, $arc_height);
401.Ve
402.PP
403.Vb 6
404\& Args : $x - X coordinate of the top left hand corner.\r
405\& $y - Y coordinate of the top left hand corner.\r
406\& $width - Width of the rectangle.\r
407\& $height - Height of the rectangle.\r
408\& $arc_width - Horizontal diameter of the arc at the four corners.\r
409\& $arc_height - vertical diameter of the arc at the four corners.
410.Ve
411.PP
412.Vb 1
413\& Returns : Nothing
414.Ve
415.Sh "\fIdraw_3D_rect()\fP"
416.IX Subsection "draw_3D_rect()"
417Draws a highlighted 3D effect rectangle. \r
418.PP
419.Vb 1
420\& Usage : $g->draw_3D_rect($x, $y, $width, $height, $raised, $bevel);
421.Ve
422.PP
423.Vb 6
424\& Args : $x - Top left corner X coordinate of the rectangle.\r
425\& $y - Top left corner Y coordinate of the rectangle.\r
426\& $width - Width of the rectangle.\r
427\& $height - Height of the rectangle.\r
428\& $raised - Optional. Takes value "true" or "false". Default "true". \r
429\& $bevel - Optional. Width of the bevel. Default 1.
430.Ve
431.PP
432.Vb 1
433\& Returns : Nothing
434.Ve
435.Sh "\fIdraw()\fP"
436.IX Subsection "draw()"
437Draws a \f(CW\*(C`Pastel::Shape\*(C'\fR object. The object is stroked using the current\r
438stroke object in the graphics context using the current paint object\r
439in the graphics context. The method works for any object which is a\r
440subclass of \f(CW\*(C`Pastel::Shape\*(C'\fR.\r
441.PP
442If you subclass Pastel::Shape. The child class must implement\r
443\&\f(CW\*(C`get_shape()\*(C'\fR method, which should return an instance of the graphics\r
444primitive (classes in \f(CW\*(C`Pastel::Geometry\*(C'\fR).\r
445.PP
446.Vb 1
447\& Usage : draw($shape)
448.Ve
449.PP
450.Vb 2
451\& Args : $shape - an object subclassed from Pastel::Shape. All the\r
452\& classes in Pastel::Geometry are subclass of Pastel::Shape.
453.Ve
454.PP
455.Vb 1
456\& Returns : Nothing
457.Ve
458.Sh "\fIdraw_string()\fP;"
459.IX Subsection "draw_string();"
460Draws the string supplied in the co-ordinates specified. Three types\r
461of strings can be drawn using this method. Native perl strings can be\r
462supplied which will be internally converted into suitable format. The\r
463entities are automatically escaped. You can even pass perl unicode\r
464strings directly into the method.\r
465.PP
466The methods also accepts \f(CW\*(C`Pastel::String\*(C'\fR objects which are nothing\r
467but an \s-1XML\s0 formatted container for the perl string.\r
468.PP
469In both these above cases the font in which the string will drawn is\r
470the current font object in the graphics context. The strings will also\r
471be stroked with the current stroke in the graphics context and it will\r
472drawn in the current paint color. \r
473.PP
474The method also accepts \f(CW\*(C`Pastel::Text::AttributedString\*(C'\fR object. In\r
475Java you pass an \f(CW\*(C`AttributedCharacterIterator\*(C'\fR into this method. In\r
476Pastel you pass the \f(CW\*(C`AttributedString\*(C'\fR object\r
477itself. \f(CW\*(C`AttributedString\*(C'\fR object are immune to current graphics\r
478context. If you want to change the stroke or color of the\r
479\&\f(CW\*(C`AttributedString\*(C'\fR do so in the directly in the object.\r
480.PP
481A major way in which \f(CW\*(C`Pastel\*(C'\fR differs from \f(CW\*(C`Java2D\*(C'\fR is that the\r
482coordinates can be arrays of numbers each determining the coordinated\r
483of each character in the string. See \s-1SVG\s0 specification for more\r
484details.\r
485.PP
486.Vb 4
487\& Usage : draw_string("perl string", $x, $y);\r
488\& draw_string("perl string", \e@x, \e@y);\r
489\& draw_string( $string,$x, $y);\r
490\& draw_string( $string, \e@x, \e@y);
491.Ve
492.PP
493.Vb 6
494\& Args : The method takes 3 arguments. The first argument can be an\r
495\& object of type Pastel::String or a pure perl string or\r
496\& Pastel::Text::AttributedString. The string supplied is converted to\r
497\& XML form automatically. All character code above 126 is converted to\r
498\& "&xff;" form. "<", ">", "&" and other XML entities are automatically\r
499\& created.
500.Ve
501.PP
502.Vb 6
503\& The second argument can be a single numerical value\r
504\& indicating the X cordinate of the first character of the\r
505\& string or the middle of the total length of the string or the\r
506\& last character depending on text anchoring. This argument\r
507\& also be a reference to an array indicating the X coordinates\r
508\& of successive characters in the string.
509.Ve
510.PP
511.Vb 3
512\& The third argument can be a single numerical or a reference\r
513\& to an array of numericals indicating the Y coordinate of the\r
514\& baseline of the glyph used for drawing the font.
515.Ve
516.Sh "\fIshow()\fP"
517.IX Subsection "show()"
518Dumps the graphics object as \s-1SVG\s0 on \s-1STDOUT\s0.\r
519.PP
520.Vb 1
521\& Usage : show()
522.Ve
523.PP
524.Vb 1
525\& Args : Nothing.
526.Ve
527.PP
528.Vb 1
529\& Returns : Nothing.
530.Ve
531.SH "SEE ALSO"
532.IX Header "SEE ALSO"
533.SH "COPYRIGHTS"
534.IX Header "COPYRIGHTS"
535Copyright (c) 2003 by Malay <curiouser@ccmb.res.in>. All rights reserved.\r
536.PP
537This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.\r