Page 311 - Open Soource Technologies 304.indd
P. 311
Unit 12: Portable Document Format
Notes
Here’s some code that experiments with different shapes and stroking or filling. Its output is
shown in Figure 12.11.
// circle
pdf_setcolor($p,”fill”,”rgb”, 0.8, 0.5, 0.8);
pdf_circle($p,400,600,75);
pdf_fill_stroke($p);
// funky arc
pdf_setcolor($p,”fill”,”rgb”, 0.8, 0.5, 0.5);
pdf_moveto($p,200,600);
pdf_arc($p,300,600,50,0,120);
pdf_closepath($p);
pdf_fill_stroke($p); // dashed rectangle
pdf_setcolor($p,”stroke”,”rgb”, 0.3, 0.8, 0.3);
pdf_setdash($p,4,6);
pdf_rect($p,50,500,500,300);
pdf_stroke($p);
Figure 12.11: Different Shapes and Stroking and Filling Styles
12.4.3 Patterns
A pattern is a reusable component, defined outside of a page context, that is used in place of a
color for filling or stroking a path.
The pdf_begin_pattern( ) call returns a pattern handle:
$pattern = pdf_begin_pattern(pdf, width, height, xstep, ystep, painttype);
LOVELY PROFESSIONAL UNIVERSITY 305