PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.13.1
GiveWP – Donation Plugin and Fundraising Platform v4.13.1
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / vendor / tecnickcom / tcpdf / examples / example_030.php
example_030.php
191 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //============================================================+
3 // File name : example_030.php
4 // Begin : 2008-06-09
5 // Last Update : 2013-05-14
6 //
7 // Description : Example 030 for TCPDF class
8 // Colour gradients
9 //
10 // Author: Nicola Asuni
11 //
12 // (c) Copyright:
13 // Nicola Asuni
14 // Tecnick.com LTD
15 // www.tecnick.com
16 // info@tecnick.com
17 //============================================================+
18
19 /**
20 * Creates an example PDF TEST document using TCPDF
21 * @package com.tecnick.tcpdf
22 * @abstract TCPDF - Example: Colour gradients
23 * @author Nicola Asuni
24 * @since 2008-06-09
25 * @group color
26 * @group pdf
27 */
28
29 // Include the main TCPDF library (search for installation path).
30 require_once('tcpdf_include.php');
31
32 // create new PDF document
33 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
34
35 // set document information
36 $pdf->setCreator(PDF_CREATOR);
37 $pdf->setAuthor('Nicola Asuni');
38 $pdf->setTitle('TCPDF Example 030');
39 $pdf->setSubject('TCPDF Tutorial');
40 $pdf->setKeywords('TCPDF, PDF, example, test, guide');
41
42 // set default header data
43 $pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 030', PDF_HEADER_STRING);
44
45 // set header and footer fonts
46 $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
47 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
48
49 // set default monospaced font
50 $pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED);
51
52 // set margins
53 $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
54 $pdf->setHeaderMargin(PDF_MARGIN_HEADER);
55 $pdf->setFooterMargin(PDF_MARGIN_FOOTER);
56
57 // set auto page breaks
58 $pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
59
60 // set image scale factor
61 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
62
63 // set some language-dependent strings (optional)
64 if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
65 require_once(dirname(__FILE__).'/lang/eng.php');
66 $pdf->setLanguageArray($l);
67 }
68
69 // ---------------------------------------------------------
70
71 // set font
72 $pdf->setFont('helvetica', 'B', 20);
73
74 // --- first page ------------------------------------------
75
76 // add a page
77 $pdf->AddPage();
78
79 $pdf->Cell(0, 0, 'TCPDF Gradients', 0, 1, 'C', 0, '', 0, false, 'T', 'M');
80
81 // set colors for gradients (r,g,b) or (grey 0-255)
82 $red = array(255, 0, 0);
83 $blue = array(0, 0, 200);
84 $yellow = array(255, 255, 0);
85 $green = array(0, 255, 0);
86 $white = array(255);
87 $black = array(0);
88
89 // set the coordinates x1,y1,x2,y2 of the gradient (see linear_gradient_coords.jpg)
90 $coords = array(0, 0, 1, 0);
91
92 // paint a linear gradient
93 $pdf->LinearGradient(20, 45, 80, 80, $red, $blue, $coords);
94
95 // write label
96 $pdf->Text(20, 130, 'LinearGradient()');
97
98 // set the coordinates fx,fy,cx,cy,r of the gradient (see radial_gradient_coords.jpg)
99 $coords = array(0.5, 0.5, 1, 1, 1.2);
100
101 // paint a radial gradient
102 $pdf->RadialGradient(110, 45, 80, 80, $white, $black, $coords);
103
104 // write label
105 $pdf->Text(110, 130, 'RadialGradient()');
106
107 // paint a coons patch mesh with default coordinates
108 $pdf->CoonsPatchMesh(20, 155, 80, 80, $yellow, $blue, $green, $red);
109
110 // write label
111 $pdf->Text(20, 240, 'CoonsPatchMesh()');
112
113 // set the coordinates for the cubic Bézier points x1,y1 ... x12, y12 of the patch (see coons_patch_mesh_coords.jpg)
114 $coords = array(
115 0.00,0.00, 0.33,0.20, //lower left
116 0.67,0.00, 1.00,0.00, 0.80,0.33, //lower right
117 0.80,0.67, 1.00,1.00, 0.67,0.80, //upper right
118 0.33,1.00, 0.00,1.00, 0.20,0.67, //upper left
119 0.00,0.33); //lower left
120 $coords_min = 0; //minimum value of the coordinates
121 $coords_max = 1; //maximum value of the coordinates
122
123 // paint a coons patch gradient with the above coordinates
124 $pdf->CoonsPatchMesh(110, 155, 80, 80, $yellow, $blue, $green, $red, $coords, $coords_min, $coords_max);
125
126 // write label
127 $pdf->Text(110, 240, 'CoonsPatchMesh()');
128
129 // --- second page -----------------------------------------
130 $pdf->AddPage();
131
132 // first patch: f = 0
133 $patch_array[0]['f'] = 0;
134 $patch_array[0]['points'] = array(
135 0.00,0.00, 0.33,0.00,
136 0.67,0.00, 1.00,0.00, 1.00,0.33,
137 0.8,0.67, 1.00,1.00, 0.67,0.8,
138 0.33,1.80, 0.00,1.00, 0.00,0.67,
139 0.00,0.33);
140 $patch_array[0]['colors'][0] = array('r' => 255, 'g' => 255, 'b' => 0);
141 $patch_array[0]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255);
142 $patch_array[0]['colors'][2] = array('r' => 0, 'g' => 255,'b' => 0);
143 $patch_array[0]['colors'][3] = array('r' => 255, 'g' => 0,'b' => 0);
144
145 // second patch - above the other: f = 2
146 $patch_array[1]['f'] = 2;
147 $patch_array[1]['points'] = array(
148 0.00,1.33,
149 0.00,1.67, 0.00,2.00, 0.33,2.00,
150 0.67,2.00, 1.00,2.00, 1.00,1.67,
151 1.5,1.33);
152 $patch_array[1]['colors'][0]=array('r' => 0, 'g' => 0, 'b' => 0);
153 $patch_array[1]['colors'][1]=array('r' => 255, 'g' => 0, 'b' => 255);
154
155 // third patch - right of the above: f = 3
156 $patch_array[2]['f'] = 3;
157 $patch_array[2]['points'] = array(
158 1.33,0.80,
159 1.67,1.50, 2.00,1.00, 2.00,1.33,
160 2.00,1.67, 2.00,2.00, 1.67,2.00,
161 1.33,2.00);
162 $patch_array[2]['colors'][0] = array('r' => 0, 'g' => 255, 'b' => 255);
163 $patch_array[2]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 0);
164
165 // fourth patch - below the above, which means left(?) of the above: f = 1
166 $patch_array[3]['f'] = 1;
167 $patch_array[3]['points'] = array(
168 2.00,0.67,
169 2.00,0.33, 2.00,0.00, 1.67,0.00,
170 1.33,0.00, 1.00,0.00, 1.00,0.33,
171 0.8,0.67);
172 $patch_array[3]['colors'][0] = array('r' => 0, 'g' => 0, 'b' => 0);
173 $patch_array[3]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255);
174
175 $coords_min = 0;
176 $coords_max = 2;
177
178 $pdf->CoonsPatchMesh(10, 45, 190, 200, '', '', '', '', $patch_array, $coords_min, $coords_max);
179
180 // write label
181 $pdf->Text(10, 250, 'CoonsPatchMesh()');
182
183 // ---------------------------------------------------------
184
185 //Close and output PDF document
186 $pdf->Output('example_030.pdf', 'D');
187
188 //============================================================+
189 // END OF FILE
190 //============================================================+
191