grad

The Gravity PDF grad class.

Defined (1)

The class is defined in the following location(s).

/vendor/blueliquiddesigns/mpdf/classes/grad.php  
  1. class grad 
  2.  
  3. var $mpdf = null; 
  4.  
  5. public function __construct(mPDF $mpdf) 
  6. $this->mpdf = $mpdf; 
  7.  
  8. // mPDF 5.3.A1 
  9. function CoonsPatchMesh($x, $y, $w, $h, $patch_array = array(), $x_min = 0, $x_max = 1, $y_min = 0, $y_max = 1, $colspace = 'RGB', $return = false) 
  10. $s = ' q '; 
  11. $s.=sprintf(' %.3F %.3F %.3F %.3F re W n ', $x * _MPDFK, ($this->mpdf->h - $y) * _MPDFK, $w * _MPDFK, -$h * _MPDFK); 
  12. $s.=sprintf(' %.3F 0 0 %.3F %.3F %.3F cm ', $w * _MPDFK, $h * _MPDFK, $x * _MPDFK, ($this->mpdf->h - ($y + $h)) * _MPDFK); 
  13. $n = count($this->mpdf->gradients) + 1; 
  14. $this->mpdf->gradients[$n]['type'] = 6; //coons patch mesh 
  15. $this->mpdf->gradients[$n]['colorspace'] = $colspace; //coons patch mesh 
  16. $bpcd = 65535; //16 BitsPerCoordinate 
  17. $trans = false; 
  18. $this->mpdf->gradients[$n]['stream'] = ''; 
  19. for ($i = 0; $i < count($patch_array); $i++) { 
  20. $this->mpdf->gradients[$n]['stream'].=chr($patch_array[$i]['f']); //start with the edge flag as 8 bit 
  21. for ($j = 0; $j < count($patch_array[$i]['points']); $j++) { 
  22. //each point as 16 bit 
  23. if (($j % 2) == 1) { // Y coordinate (adjusted as input is From top left) 
  24. $patch_array[$i]['points'][$j] = (($patch_array[$i]['points'][$j] - $y_min) / ($y_max - $y_min)) * $bpcd; 
  25. $patch_array[$i]['points'][$j] = $bpcd - $patch_array[$i]['points'][$j]; 
  26. } else { 
  27. $patch_array[$i]['points'][$j] = (($patch_array[$i]['points'][$j] - $x_min) / ($x_max - $x_min)) * $bpcd; 
  28. if ($patch_array[$i]['points'][$j] < 0) 
  29. $patch_array[$i]['points'][$j] = 0; 
  30. if ($patch_array[$i]['points'][$j] > $bpcd) 
  31. $patch_array[$i]['points'][$j] = $bpcd; 
  32. $this->mpdf->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j] / 256)); 
  33. $this->mpdf->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j] % 256)); 
  34. for ($j = 0; $j < count($patch_array[$i]['colors']); $j++) { 
  35. //each color component as 8 bit 
  36. if ($colspace == 'RGB') { 
  37. $this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][1]); 
  38. $this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][2]); 
  39. $this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][3]); 
  40. if (isset($patch_array[$i]['colors'][$j][4]) && ord($patch_array[$i]['colors'][$j][4]) < 100) { 
  41. $trans = true; 
  42. } else if ($colspace == 'CMYK') { 
  43. $this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][1]) * 2.55); 
  44. $this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][2]) * 2.55); 
  45. $this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][3]) * 2.55); 
  46. $this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][4]) * 2.55); 
  47. if (isset($patch_array[$i]['colors'][$j][5]) && ord($patch_array[$i]['colors'][$j][5]) < 100) { 
  48. $trans = true; 
  49. } else if ($colspace == 'Gray') { 
  50. $this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][1]); 
  51. if ($patch_array[$i]['colors'][$j][2] == 1) { 
  52. $trans = true; 
  53. } // transparency converted from rgba or cmyka() 
  54. // TRANSPARENCY 
  55. if ($trans) { 
  56. $this->mpdf->gradients[$n]['stream_trans'] = ''; 
  57. for ($i = 0; $i < count($patch_array); $i++) { 
  58. $this->mpdf->gradients[$n]['stream_trans'].=chr($patch_array[$i]['f']); 
  59. for ($j = 0; $j < count($patch_array[$i]['points']); $j++) { 
  60. //each point as 16 bit 
  61. $this->mpdf->gradients[$n]['stream_trans'].=chr(floor($patch_array[$i]['points'][$j] / 256)); 
  62. $this->mpdf->gradients[$n]['stream_trans'].=chr(floor($patch_array[$i]['points'][$j] % 256)); 
  63. for ($j = 0; $j < count($patch_array[$i]['colors']); $j++) { 
  64. //each color component as 8 bit // OPACITY 
  65. if ($colspace == 'RGB') { 
  66. $this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][4]) * 2.55)); 
  67. } else if ($colspace == 'CMYK') { 
  68. $this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][5]) * 2.55)); 
  69. } else if ($colspace == 'Gray') { 
  70. $this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][3]) * 2.55)); 
  71. $this->mpdf->gradients[$n]['trans'] = true; 
  72. $s .= ' /TGS' . $n . ' gs '; 
  73. //paint the gradient 
  74. $s .= '/Sh' . $n . ' sh' . "\n"; 
  75. //restore previous Graphic State 
  76. $s .= 'Q' . "\n"; 
  77. if ($return) { 
  78. return $s; 
  79. } else { 
  80. $this->mpdf->_out($s); 
  81.  
  82. // type = linear:2; radial: 3; 
  83. // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). 
  84. // The default value is from left to right (x1=0, y1=0, x2=1, y2=0). 
  85. // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,  
  86. // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). 
  87. // (fx, fy) should be inside the circle, otherwise some areas will not be defined 
  88. // $col = array(R, G, B/255); or array(G/255); or array(C, M, Y, K/100) 
  89. // $stops = array('col'=>$col [, 'opacity'=>0-1] [, 'offset'=>0-1]) 
  90. function Gradient($x, $y, $w, $h, $type, $stops = array(), $colorspace = 'RGB', $coords = '', $extend = '', $return = false, $is_mask = false) 
  91. if (strtoupper(substr($type, 0, 1)) == 'L') { 
  92. $type = 2; 
  93. } // linear 
  94. else if (strtoupper(substr($type, 0, 1)) == 'R') { 
  95. $type = 3; 
  96. } // radial 
  97. if ($colorspace != 'CMYK' && $colorspace != 'Gray') { 
  98. $colorspace = 'RGB'; 
  99. $bboxw = $w; 
  100. $bboxh = $h; 
  101. $usex = $x; 
  102. $usey = $y; 
  103. $usew = $bboxw; 
  104. $useh = $bboxh; 
  105.  
  106. if ($type < 1) { 
  107. $type = 2; 
  108. if ($coords[0] !== false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $coords[0], $m)) { 
  109. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  110. if ($tmp) { 
  111. $coords[0] = $tmp / $w; 
  112. if ($coords[1] !== false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $coords[1], $m)) { 
  113. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  114. if ($tmp) { 
  115. $coords[1] = 1 - ($tmp / $h); 
  116. // LINEAR 
  117. if ($type == 2) { 
  118. $angle = (isset($coords[4]) ? $coords[4] : false); 
  119. $repeat = (isset($coords[5]) ? $coords[5] : false); 
  120. // ALL POINTS SET (default for custom mPDF linear gradient) - no -moz 
  121. if ($coords[0] !== false && $coords[1] !== false && $coords[2] !== false && $coords[3] !== false) { 
  122. // do nothing - coords used as they are 
  123.  
  124. // If both a <point> and <angle> are defined, the gradient axis starts from the point and runs along the angle. The end point is 
  125. // defined as before - in this case start points may not be in corners, and axis may not correctly fall in the right quadrant. 
  126. // NO end points (Angle defined & Start points) 
  127. else if ($angle !== false && $coords[0] !== false && $coords[1] !== false && $coords[2] === false && $coords[3] === false) { 
  128. if ($angle == 0 || $angle == 360) { 
  129. $coords[3] = $coords[1]; 
  130. if ($coords[0] == 1) 
  131. $coords[2] = 2; 
  132. else 
  133. $coords[2] = 1; 
  134. else if ($angle == 90) { 
  135. $coords[2] = $coords[0]; 
  136. $coords[3] = 1; 
  137. if ($coords[1] == 1) 
  138. $coords[3] = 2; 
  139. else 
  140. $coords[3] = 1; 
  141. else if ($angle == 180) { 
  142. if ($coords[4] == 0) 
  143. $coords[2] = -1; 
  144. else 
  145. $coords[2] = 0; 
  146. $coords[3] = $coords[1]; 
  147. else if ($angle == 270) { 
  148. $coords[2] = $coords[0]; 
  149. if ($coords[1] == 0) 
  150. $coords[3] = -1; 
  151. else 
  152. $coords[3] = 0; 
  153. else { 
  154. $endx = 1; 
  155. $endy = 1; 
  156. if ($angle <= 90) { 
  157. if ($angle <= 45) { 
  158. $endy = tan(deg2rad($angle)); 
  159. } else { 
  160. $endx = tan(deg2rad(90 - $angle)); 
  161. $b = atan2(($endy * $bboxh), ($endx * $bboxw)); 
  162. $ny = 1 - $coords[1] - (tan($b) * (1 - $coords[0])); 
  163. $tx = sin($b) * cos($b) * $ny; 
  164. $ty = cos($b) * cos($b) * $ny; 
  165. $coords[2] = 1 + $tx; 
  166. $coords[3] = 1 - $ty; 
  167. } else if ($angle <= 180) { 
  168. if ($angle <= 135) { 
  169. $endx = tan(deg2rad($angle - 90)); 
  170. } else { 
  171. $endy = tan(deg2rad(180 - $angle)); 
  172. $b = atan2(($endy * $bboxh), ($endx * $bboxw)); 
  173. $ny = 1 - $coords[1] - (tan($b) * ($coords[0])); 
  174. $tx = sin($b) * cos($b) * $ny; 
  175. $ty = cos($b) * cos($b) * $ny; 
  176. $coords[2] = -$tx; 
  177. $coords[3] = 1 - $ty; 
  178. } else if ($angle <= 270) { 
  179. if ($angle <= 225) { 
  180. $endy = tan(deg2rad($angle - 180)); 
  181. } else { 
  182. $endx = tan(deg2rad(270 - $angle)); 
  183. $b = atan2(($endy * $bboxh), ($endx * $bboxw)); 
  184. $ny = $coords[1] - (tan($b) * ($coords[0])); 
  185. $tx = sin($b) * cos($b) * $ny; 
  186. $ty = cos($b) * cos($b) * $ny; 
  187. $coords[2] = -$tx; 
  188. $coords[3] = $ty; 
  189. } else { 
  190. if ($angle <= 315) { 
  191. $endx = tan(deg2rad($angle - 270)); 
  192. } else { 
  193. $endy = tan(deg2rad(360 - $angle)); 
  194. $b = atan2(($endy * $bboxh), ($endx * $bboxw)); 
  195. $ny = $coords[1] - (tan($b) * (1 - $coords[0])); 
  196. $tx = sin($b) * cos($b) * $ny; 
  197. $ty = cos($b) * cos($b) * $ny; 
  198. $coords[2] = 1 + $tx; 
  199. $coords[3] = $ty; 
  200.  
  201. // -moz If the first parameter is only an <angle>, the gradient axis starts from the box's corner that would ensure the 
  202. // axis goes through the box. The axis runs along the specified angle. The end point of the axis is defined such that the 
  203. // farthest corner of the box from the starting point is perpendicular to the gradient axis at that point. 
  204. // NO end points or Start points (Angle defined) 
  205. else if ($angle !== false && $coords[0] === false && $coords[1] === false) { 
  206. if ($angle == 0 || $angle == 360) { 
  207. $coords[0] = 0; 
  208. $coords[1] = 0; 
  209. $coords[2] = 1; 
  210. $coords[3] = 0; 
  211. } else if ($angle == 90) { 
  212. $coords[0] = 0; 
  213. $coords[1] = 0; 
  214. $coords[2] = 0; 
  215. $coords[3] = 1; 
  216. } else if ($angle == 180) { 
  217. $coords[0] = 1; 
  218. $coords[1] = 0; 
  219. $coords[2] = 0; 
  220. $coords[3] = 0; 
  221. } else if ($angle == 270) { 
  222. $coords[0] = 0; 
  223. $coords[1] = 1; 
  224. $coords[2] = 0; 
  225. $coords[3] = 0; 
  226. } else { 
  227. if ($angle <= 90) { 
  228. $coords[0] = 0; 
  229. $coords[1] = 0; 
  230. if ($angle <= 45) { 
  231. $endx = 1; 
  232. $endy = tan(deg2rad($angle)); 
  233. } else { 
  234. $endx = tan(deg2rad(90 - $angle)); 
  235. $endy = 1; 
  236. } else if ($angle <= 180) { 
  237. $coords[0] = 1; 
  238. $coords[1] = 0; 
  239. if ($angle <= 135) { 
  240. $endx = tan(deg2rad($angle - 90)); 
  241. $endy = 1; 
  242. } else { 
  243. $endx = 1; 
  244. $endy = tan(deg2rad(180 - $angle)); 
  245. } else if ($angle <= 270) { 
  246. $coords[0] = 1; 
  247. $coords[1] = 1; 
  248. if ($angle <= 225) { 
  249. $endx = 1; 
  250. $endy = tan(deg2rad($angle - 180)); 
  251. } else { 
  252. $endx = tan(deg2rad(270 - $angle)); 
  253. $endy = 1; 
  254. } else { 
  255. $coords[0] = 0; 
  256. $coords[1] = 1; 
  257. if ($angle <= 315) { 
  258. $endx = tan(deg2rad($angle - 270)); 
  259. $endy = 1; 
  260. } else { 
  261. $endx = 1; 
  262. $endy = tan(deg2rad(360 - $angle)); 
  263. $b = atan2(($endy * $bboxh), ($endx * $bboxw)); 
  264. $h2 = $bboxh - ($bboxh * tan($b)); 
  265. $px = $bboxh + ($h2 * sin($b) * cos($b)); 
  266. $py = ($bboxh * tan($b)) + ($h2 * sin($b) * sin($b)); 
  267. $x1 = $px / $bboxh; 
  268. $y1 = $py / $bboxh; 
  269. if ($angle <= 90) { 
  270. $coords[2] = $x1; 
  271. $coords[3] = $y1; 
  272. } else if ($angle <= 180) { 
  273. $coords[2] = 1 - $x1; 
  274. $coords[3] = $y1; 
  275. } else if ($angle <= 270) { 
  276. $coords[2] = 1 - $x1; 
  277. $coords[3] = 1 - $y1; 
  278. } else { 
  279. $coords[2] = $x1; 
  280. $coords[3] = 1 - $y1; 
  281. // -moz If the first parameter to the gradient function is only a <point>, the gradient axis starts from the specified point,  
  282. // and ends at the point you would get if you rotated the starting point by 180 degrees about the center of the box that the 
  283. // gradient is to be applied to. 
  284. // NO angle and NO end points (Start points defined) 
  285. else if ((!isset($angle) || $angle === false) && $coords[0] !== false && $coords[1] !== false) { // should have start and end defined 
  286. $coords[2] = 1 - $coords[0]; 
  287. $coords[3] = 1 - $coords[1]; 
  288. $angle = rad2deg(atan2($coords[3] - $coords[1], $coords[2] - $coords[0])); 
  289. if ($angle < 0) { 
  290. $angle += 360; 
  291. } else if ($angle > 360) { 
  292. $angle -= 360; 
  293. if ($angle != 0 && $angle != 360 && $angle != 90 && $angle != 180 && $angle != 270) { 
  294. if ($w >= $h) { 
  295. $coords[1] *= $h / $w; 
  296. $coords[3] *= $h / $w; 
  297. $usew = $useh = $bboxw; 
  298. $usey -= ($w - $h); 
  299. } else { 
  300. $coords[0] *= $w / $h; 
  301. $coords[2] *= $w / $h; 
  302. $usew = $useh = $bboxh; 
  303.  
  304. // -moz If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values, the gradient 
  305. // axis starts from the top of the box and runs vertically downwards, ending at the bottom of the box. 
  306. else { // default values T2B 
  307. // All values are set in parseMozGradient - so won't appear here 
  308. $coords = array(0, 0, 1, 0); // default for original linear gradient (L2R) 
  309. $s = ' q'; 
  310. $s .= sprintf(' %.3F %.3F %.3F %.3F re W n', $x * _MPDFK, ($this->mpdf->h - $y) * _MPDFK, $w * _MPDFK, -$h * _MPDFK) . "\n"; 
  311. $s .= sprintf(' %.3F 0 0 %.3F %.3F %.3F cm', $usew * _MPDFK, $useh * _MPDFK, $usex * _MPDFK, ($this->mpdf->h - ($usey + $useh)) * _MPDFK) . "\n"; 
  312.  
  313. // RADIAL 
  314. else if ($type == 3) { 
  315. $radius = (isset($coords[4]) ? $coords[4] : false); 
  316. $angle = (isset($coords[5]) ? $coords[5] : false); // ?? no effect 
  317. $shape = (isset($coords[6]) ? $coords[6] : false); 
  318. $size = (isset($coords[7]) ? $coords[7] : false); 
  319. $repeat = (isset($coords[8]) ? $coords[8] : false); 
  320. // ALL POINTS AND RADIUS SET (default for custom mPDF radial gradient) - no -moz 
  321. if ($coords[0] !== false && $coords[1] !== false && $coords[2] !== false && $coords[3] !== false && $coords[4] !== false) { 
  322. // do nothing - coords used as they are 
  323. // If a <point> is defined 
  324. else if ($shape !== false && $size !== false) { 
  325. if ($coords[2] == false) { 
  326. $coords[2] = $coords[0]; 
  327. if ($coords[3] == false) { 
  328. $coords[3] = $coords[1]; 
  329. // ELLIPSE 
  330. if ($shape == 'ellipse') { 
  331. $corner1 = sqrt(pow($coords[0], 2) + pow($coords[1], 2)); 
  332. $corner2 = sqrt(pow($coords[0], 2) + pow((1 - $coords[1]), 2)); 
  333. $corner3 = sqrt(pow((1 - $coords[0]), 2) + pow($coords[1], 2)); 
  334. $corner4 = sqrt(pow((1 - $coords[0]), 2) + pow((1 - $coords[1]), 2)); 
  335. if ($size == 'closest-side') { 
  336. $radius = min($coords[0], $coords[1], (1 - $coords[0]), (1 - $coords[1])); 
  337. } else if ($size == 'closest-corner') { 
  338. $radius = min($corner1, $corner2, $corner3, $corner4); 
  339. } else if ($size == 'farthest-side') { 
  340. $radius = max($coords[0], $coords[1], (1 - $coords[0]), (1 - $coords[1])); 
  341. } else { 
  342. $radius = max($corner1, $corner2, $corner3, $corner4); 
  343. } // farthest corner (default) 
  344. // CIRCLE 
  345. else if ($shape == 'circle') { 
  346. if ($w >= $h) { 
  347. $coords[1] = $coords[3] = ($coords[1] * $h / $w); 
  348. $corner1 = sqrt(pow($coords[0], 2) + pow($coords[1], 2)); 
  349. $corner2 = sqrt(pow($coords[0], 2) + pow((($h / $w) - $coords[1]), 2)); 
  350. $corner3 = sqrt(pow((1 - $coords[0]), 2) + pow($coords[1], 2)); 
  351. $corner4 = sqrt(pow((1 - $coords[0]), 2) + pow((($h / $w) - $coords[1]), 2)); 
  352. if ($size == 'closest-side') { 
  353. $radius = min($coords[0], $coords[1], (1 - $coords[0]), (($h / $w) - $coords[1])); 
  354. } else if ($size == 'closest-corner') { 
  355. $radius = min($corner1, $corner2, $corner3, $corner4); 
  356. } else if ($size == 'farthest-side') { 
  357. $radius = max($coords[0], $coords[1], (1 - $coords[0]), (($h / $w) - $coords[1])); 
  358. } else if ($size == 'farthest-corner') { 
  359. $radius = max($corner1, $corner2, $corner3, $corner4); 
  360. } // farthest corner (default) 
  361. $usew = $useh = $bboxw; 
  362. $usey -= ($w - $h); 
  363. } else { 
  364. $coords[0] = $coords[2] = ($coords[0] * $w / $h); 
  365. $corner1 = sqrt(pow($coords[0], 2) + pow($coords[1], 2)); 
  366. $corner2 = sqrt(pow($coords[0], 2) + pow((1 - $coords[1]), 2)); 
  367. $corner3 = sqrt(pow((($w / $h) - $coords[0]), 2) + pow($coords[1], 2)); 
  368. $corner4 = sqrt(pow((($w / $h) - $coords[0]), 2) + pow((1 - $coords[1]), 2)); 
  369. if ($size == 'closest-side') { 
  370. $radius = min($coords[0], $coords[1], (($w / $h) - $coords[0]), (1 - $coords[1])); 
  371. } else if ($size == 'closest-corner') { 
  372. $radius = min($corner1, $corner2, $corner3, $corner4); 
  373. } else if ($size == 'farthest-side') { 
  374. $radius = max($coords[0], $coords[1], (($w / $h) - $coords[0]), (1 - $coords[1])); 
  375. } else if ($size == 'farthest-corner') { 
  376. $radius = max($corner1, $corner2, $corner3, $corner4); 
  377. } // farthest corner (default) 
  378. $usew = $useh = $bboxh; 
  379. if ($radius == 0) { 
  380. $radius = 0.001; 
  381. } // to prevent error 
  382. $coords[4] = $radius; 
  383.  
  384. // -moz If entire function consists of only <stop> values 
  385. else { // default values 
  386. // All values are set in parseMozGradient - so won't appear here 
  387. $coords = array(0.5, 0.5, 0.5, 0.5); // default for radial gradient (centred) 
  388. $s = ' q'; 
  389. $s .= sprintf(' %.3F %.3F %.3F %.3F re W n', $x * _MPDFK, ($this->mpdf->h - $y) * _MPDFK, $w * _MPDFK, -$h * _MPDFK) . "\n"; 
  390. $s .= sprintf(' %.3F 0 0 %.3F %.3F %.3F cm', $usew * _MPDFK, $useh * _MPDFK, $usex * _MPDFK, ($this->mpdf->h - ($usey + $useh)) * _MPDFK) . "\n"; 
  391.  
  392. $n = count($this->mpdf->gradients) + 1; 
  393. $this->mpdf->gradients[$n]['type'] = $type; 
  394. $this->mpdf->gradients[$n]['colorspace'] = $colorspace; 
  395. $trans = false; 
  396. $this->mpdf->gradients[$n]['is_mask'] = $is_mask; 
  397. if ($is_mask) { 
  398. $trans = true; 
  399. if (count($stops) == 1) { 
  400. $stops[1] = $stops[0]; 
  401. if (!isset($stops[0]['offset'])) { 
  402. $stops[0]['offset'] = 0; 
  403. if (!isset($stops[(count($stops) - 1)]['offset'])) { 
  404. $stops[(count($stops) - 1)]['offset'] = 1; 
  405.  
  406. // Fix stop-offsets set as absolute lengths 
  407. if ($type == 2) { 
  408. $axisx = ($coords[2] - $coords[0]) * $usew; 
  409. $axisy = ($coords[3] - $coords[1]) * $useh; 
  410. $axis_length = sqrt(pow($axisx, 2) + pow($axisy, 2)); 
  411. } else { 
  412. $axis_length = $coords[4] * $usew; 
  413. } // Absolute lengths are meaningless for an ellipse - Firefox uses Width as reference 
  414.  
  415. for ($i = 0; $i < count($stops); $i++) { 
  416. if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $stops[$i]['offset'], $m)) { 
  417. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  418. $stops[$i]['offset'] = $tmp / $axis_length; 
  419.  
  420.  
  421. if (isset($stops[0]['offset']) && $stops[0]['offset'] > 0) { 
  422. $firststop = $stops[0]; 
  423. $firststop['offset'] = 0; 
  424. array_unshift($stops, $firststop); 
  425. if (!$repeat && isset($stops[(count($stops) - 1)]['offset']) && $stops[(count($stops) - 1)]['offset'] < 1) { 
  426. $endstop = $stops[(count($stops) - 1)]; 
  427. $endstop['offset'] = 1; 
  428. $stops[] = $endstop; 
  429. if ($stops[0]['offset'] > $stops[(count($stops) - 1)]['offset']) { 
  430. $stops[0]['offset'] = 0; 
  431. $stops[(count($stops) - 1)]['offset'] = 1; 
  432.  
  433. for ($i = 0; $i < count($stops); $i++) { 
  434. // mPDF 5.3.74 
  435. if ($colorspace == 'CMYK') { 
  436. $this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F %.3F', (ord($stops[$i]['col']{1}) / 100), (ord($stops[$i]['col']{2}) / 100), (ord($stops[$i]['col']{3}) / 100), (ord($stops[$i]['col']{4}) / 100)); 
  437. } else if ($colorspace == 'Gray') { 
  438. $this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F', (ord($stops[$i]['col']{1}) / 255)); 
  439. } else { 
  440. $this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F', (ord($stops[$i]['col']{1}) / 255), (ord($stops[$i]['col']{2}) / 255), (ord($stops[$i]['col']{3}) / 255)); 
  441. if (!isset($stops[$i]['opacity'])) { 
  442. $stops[$i]['opacity'] = 1; 
  443. } else if ($stops[$i]['opacity'] > 1 || $stops[$i]['opacity'] < 0) { 
  444. $stops[$i]['opacity'] = 1; 
  445. } else if ($stops[$i]['opacity'] < 1) { 
  446. $trans = true; 
  447. $this->mpdf->gradients[$n]['stops'][$i]['opacity'] = $stops[$i]['opacity']; 
  448. // OFFSET 
  449. if ($i > 0 && $i < (count($stops) - 1)) { 
  450. if (!isset($stops[$i]['offset']) || (isset($stops[$i + 1]['offset']) && $stops[$i]['offset'] > $stops[$i + 1]['offset']) || $stops[$i]['offset'] < $stops[$i - 1]['offset']) { 
  451. if (isset($stops[$i - 1]['offset']) && isset($stops[$i + 1]['offset'])) { 
  452. $stops[$i]['offset'] = ($stops[$i - 1]['offset'] + $stops[$i + 1]['offset']) / 2; 
  453. } else { 
  454. for ($j = ($i + 1); $j < count($stops); $j++) { 
  455. if (isset($stops[$j]['offset'])) { 
  456. break; 
  457. $int = ($stops[$j]['offset'] - $stops[($i - 1)]['offset']) / ($j - $i + 1); 
  458. for ($f = 0; $f < ($j - $i - 1); $f++) { 
  459. $stops[($i + $f)]['offset'] = $stops[($i + $f - 1)]['offset'] + ($int); 
  460. $this->mpdf->gradients[$n]['stops'][$i]['offset'] = $stops[$i]['offset']; 
  461. $this->mpdf->gradients[$n]['stops'][$i]['offset'] = $stops[$i]['offset']; 
  462.  
  463. if ($repeat) { 
  464. $ns = count($this->mpdf->gradients[$n]['stops']); 
  465. $offs = array(); 
  466. for ($i = 0; $i < $ns; $i++) { 
  467. $offs[$i] = $this->mpdf->gradients[$n]['stops'][$i]['offset']; 
  468. $gp = 0; 
  469. $inside = true; 
  470. while ($inside) { 
  471. $gp++; 
  472. for ($i = 0; $i < $ns; $i++) { 
  473. $this->mpdf->gradients[$n]['stops'][(($ns * $gp) + $i)] = $this->mpdf->gradients[$n]['stops'][(($ns * ($gp - 1)) + $i)]; 
  474. $tmp = $this->mpdf->gradients[$n]['stops'][(($ns * ($gp - 1)) + ($ns - 1))]['offset'] + $offs[$i]; 
  475. if ($tmp < 1) { 
  476. $this->mpdf->gradients[$n]['stops'][(($ns * $gp) + $i)]['offset'] = $tmp; 
  477. } else { 
  478. $this->mpdf->gradients[$n]['stops'][(($ns * $gp) + $i)]['offset'] = 1; 
  479. $inside = false; 
  480. break(2); 
  481.  
  482. if ($trans) { 
  483. $this->mpdf->gradients[$n]['trans'] = true; 
  484. $s .= ' /TGS' . $n . ' gs '; 
  485. if (!is_array($extend) || count($extend) < 1) { 
  486. $extend = array('true', 'true'); // These are supposed to be quoted - appear in PDF file as text 
  487. $this->mpdf->gradients[$n]['coords'] = $coords; 
  488. $this->mpdf->gradients[$n]['extend'] = $extend; 
  489. //paint the gradient 
  490. $s .= '/Sh' . $n . ' sh ' . "\n"; 
  491. //restore previous Graphic State 
  492. $s .= ' Q ' . "\n"; 
  493. if ($return) { 
  494. return $s; 
  495. } else { 
  496. $this->mpdf->_out($s); 
  497.  
  498. function parseMozGradient($bg) 
  499. // background[-image]: -moz-linear-gradient(left, #c7Fdde 20%, #FF0000 ); 
  500. // background[-image]: linear-gradient(left, #c7Fdde 20%, #FF0000 ); // CSS3 
  501. if (preg_match('/repeating-/', $bg)) { 
  502. $repeat = true; 
  503. } else { 
  504. $repeat = false; 
  505. if (preg_match('/linear-gradient\((.*)\)/', $bg, $m)) { 
  506. $g = array(); 
  507. $g['type'] = 2; 
  508. $g['colorspace'] = 'RGB'; 
  509. $g['extend'] = array('true', 'true'); 
  510. $v = trim($m[1]); 
  511. // Change commas inside e.g. rgb(x, x, x) 
  512. while (preg_match('/(\([^\)]*?), /', $v)) { 
  513. $v = preg_replace('/(\([^\)]*?), /', '\\1@', $v); 
  514. // Remove spaces inside e.g. rgb(x, x, x) 
  515. while (preg_match('/(\([^\)]*?)[ ]/', $v)) { 
  516. $v = preg_replace('/(\([^\)]*?)[ ]/', '\\1', $v); 
  517. $bgr = preg_split('/\s*, \s*/', $v); 
  518. for ($i = 0; $i < count($bgr); $i++) { 
  519. $bgr[$i] = preg_replace('/@/', ', ', $bgr[$i]); 
  520. // Is first part $bgr[0] a valid point/angle? 
  521. $first = preg_split('/\s+/', trim($bgr[0])); 
  522. if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i', $bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i', $bgr[0])) { 
  523. $startStops = 1; 
  524. } else if (trim($first[(count($first) - 1)]) === "0") { 
  525. $startStops = 1; 
  526. } else { 
  527. $check = $this->mpdf->ConvertColor($first[0]); 
  528. if ($check) 
  529. $startStops = 0; 
  530. else 
  531. $startStops = 1; 
  532. // first part a valid point/angle? 
  533. if ($startStops == 1) { // default values 
  534. // [<point> || <angle>, ] = [<% em px left center right bottom top> || <deg grad rad 0>, ] 
  535. if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i', $bgr[0], $m)) { 
  536. $angle = $m[1] + 0; 
  537. if (strtolower($m[2]) == 'deg') { 
  538. $angle = $angle; 
  539. } else if (strtolower($m[2]) == 'grad') { 
  540. $angle *= (360 / 400); 
  541. } else if (strtolower($m[2]) == 'rad') { 
  542. $angle = rad2deg($angle); 
  543. while ($angle < 0) { 
  544. $angle += 360; 
  545. $angle = ($angle % 360); 
  546. } else if (trim($first[(count($first) - 1)]) === "0") { 
  547. $angle = 0; 
  548. if (preg_match('/left/i', $bgr[0])) { 
  549. $startx = 0; 
  550. } else if (preg_match('/right/i', $bgr[0])) { 
  551. $startx = 1; 
  552. if (preg_match('/top/i', $bgr[0])) { 
  553. $starty = 1; 
  554. } else if (preg_match('/bottom/i', $bgr[0])) { 
  555. $starty = 0; 
  556. // Check for %? ?% or %% 
  557. if (preg_match('/(\d+)[%]/i', $first[0], $m)) { 
  558. $startx = $m[1] / 100; 
  559. } else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[0], $m)) { 
  560. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  561. if ($tmp) { 
  562. $startx = $m[1]; 
  563. if (isset($first[1]) && preg_match('/(\d+)[%]/i', $first[1], $m)) { 
  564. $starty = 1 - ($m[1] / 100); 
  565. } else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[1], $m)) { 
  566. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  567. if ($tmp) { 
  568. $starty = $m[1]; 
  569. if (isset($startx) && !isset($starty)) { 
  570. $starty = 0.5; 
  571. if (!isset($startx) && isset($starty)) { 
  572. $startx = 0.5; 
  573. // If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values, the gradient axis starts from the top of the box and runs vertically downwards, ending at the bottom of the box. 
  574. else { // default values T2B 
  575. $starty = 1; 
  576. $startx = 0.5; 
  577. $endy = 0; 
  578. $endx = 0.5; 
  579. $coords = array(); 
  580. if (!isset($startx)) { 
  581. $startx = false; 
  582. if (!isset($starty)) { 
  583. $starty = false; 
  584. if (!isset($endx)) { 
  585. $endx = false; 
  586. if (!isset($endy)) { 
  587. $endy = false; 
  588. if (!isset($angle)) { 
  589. $angle = false; 
  590. $g['coords'] = array($startx, $starty, $endx, $endy, $angle, $repeat); 
  591. $g['stops'] = array(); 
  592. for ($i = $startStops; $i < count($bgr); $i++) { 
  593. $stop = array(); 
  594. // parse stops 
  595. $el = preg_split('/\s+/', trim($bgr[$i])); 
  596. // mPDF 5.3.74 
  597. $col = $this->mpdf->ConvertColor($el[0]); 
  598. if ($col) { 
  599. $stop['col'] = $col; 
  600. } else { 
  601. $stop['col'] = $col = $this->mpdf->ConvertColor(255); 
  602. if ($col{0} == 1) 
  603. $g['colorspace'] = 'Gray'; 
  604. else if ($col{0} == 4 || $col{0} == 6) 
  605. $g['colorspace'] = 'CMYK'; 
  606. if ($col{0} == 5) { 
  607. $stop['opacity'] = ord($col{4}) / 100; 
  608. } // transparency from rgba() 
  609. else if ($col{0} == 6) { 
  610. $stop['opacity'] = ord($col{5}) / 100; 
  611. } // transparency from cmyka() 
  612. else if ($col{0} == 1 && $col{2} == 1) { 
  613. $stop['opacity'] = ord($col{3}) / 100; 
  614. } // transparency converted from rgba or cmyka() 
  615.  
  616. if (isset($el[1]) && preg_match('/(\d+)[%]/', $el[1], $m)) { 
  617. $stop['offset'] = $m[1] / 100; 
  618. if ($stop['offset'] > 1) { 
  619. unset($stop['offset']); 
  620. } else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $el[1], $m)) { 
  621. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  622. if ($tmp) { 
  623. $stop['offset'] = $m[1]; 
  624. $g['stops'][] = $stop; 
  625. if (count($g['stops'])) { 
  626. return $g; 
  627. } else if (preg_match('/radial-gradient\((.*)\)/', $bg, $m)) { 
  628. $g = array(); 
  629. $g['type'] = 3; 
  630. $g['colorspace'] = 'RGB'; 
  631. $g['extend'] = array('true', 'true'); 
  632. $v = trim($m[1]); 
  633. // Change commas inside e.g. rgb(x, x, x) 
  634. while (preg_match('/(\([^\)]*?), /', $v)) { 
  635. $v = preg_replace('/(\([^\)]*?), /', '\\1@', $v); 
  636. // Remove spaces inside e.g. rgb(x, x, x) 
  637. while (preg_match('/(\([^\)]*?)[ ]/', $v)) { 
  638. $v = preg_replace('/(\([^\)]*?)[ ]/', '\\1', $v); 
  639. $bgr = preg_split('/\s*, \s*/', $v); 
  640. for ($i = 0; $i < count($bgr); $i++) { 
  641. $bgr[$i] = preg_replace('/@/', ', ', $bgr[$i]); 
  642.  
  643. // Is first part $bgr[0] a valid point/angle? 
  644. $startStops = 0; 
  645. $pos_angle = false; 
  646. $shape_size = false; 
  647. $first = preg_split('/\s+/', trim($bgr[0])); 
  648. $checkCol = $this->mpdf->ConvertColor($first[0]); 
  649. if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i', $bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i', $bgr[0])) { 
  650. $startStops = 1; 
  651. $pos_angle = $bgr[0]; 
  652. } else if (trim($first[(count($first) - 1)]) === "0") { 
  653. $startStops = 1; 
  654. $pos_angle = $bgr[0]; 
  655. } else if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $bgr[0])) { 
  656. $startStops = 1; 
  657. $shape_size = $bgr[0]; 
  658. } else if (!$checkCol) { 
  659. $startStops = 1; 
  660. $pos_angle = $bgr[0]; 
  661. if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $bgr[1])) { 
  662. $startStops = 2; 
  663. $shape_size = $bgr[1]; 
  664.  
  665. // If valid point/angle? 
  666. if ($pos_angle) { // default values 
  667. // [<point> || <angle>, ] = [<% em px left center right bottom top> || <deg grad rad 0>, ] 
  668. if (preg_match('/left/i', $pos_angle)) { 
  669. $startx = 0; 
  670. } else if (preg_match('/right/i', $pos_angle)) { 
  671. $startx = 1; 
  672. if (preg_match('/top/i', $pos_angle)) { 
  673. $starty = 1; 
  674. } else if (preg_match('/bottom/i', $pos_angle)) { 
  675. $starty = 0; 
  676. // Check for %? ?% or %% 
  677. if (preg_match('/(\d+)[%]/i', $first[0], $m)) { 
  678. $startx = $m[1] / 100; 
  679. } else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[0], $m)) { 
  680. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  681. if ($tmp) { 
  682. $startx = $m[1]; 
  683. if (isset($first[1]) && preg_match('/(\d+)[%]/i', $first[1], $m)) { 
  684. $starty = 1 - ($m[1] / 100); 
  685. } else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[1], $m)) { 
  686. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  687. if ($tmp) { 
  688. $starty = $m[1]; 
  689.  
  690. /** 
  691. // ?? Angle has no effect in radial gradient (does not exist in CSS3 spec.) 
  692. if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i', $pos_angle, $m)) { 
  693. $angle = $m[1] + 0; 
  694. if (strtolower($m[2])=='deg') { $angle = $angle; } 
  695. else if (strtolower($m[2])=='grad') { $angle *= (360/400); } 
  696. else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); } 
  697. while($angle < 0) { $angle += 360; } 
  698. $angle = ($angle % 360); 
  699. */ 
  700. if (!isset($starty)) { 
  701. $starty = 0.5; 
  702. if (!isset($startx)) { 
  703. $startx = 0.5; 
  704. // If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values, the gradient axis starts from the top of the box and runs vertically downwards, ending at the bottom of the box. 
  705. else { // default values Center 
  706. $starty = 0.5; 
  707. $startx = 0.5; 
  708. $endy = 0.5; 
  709. $endx = 0.5; 
  710.  
  711. // If valid shape/size? 
  712. $shape = 'ellipse'; // default 
  713. $size = 'farthest-corner'; // default 
  714. if ($shape_size) { // default values 
  715. if (preg_match('/(circle|ellipse)/i', $shape_size, $m)) { 
  716. $shape = $m[1]; 
  717. if (preg_match('/(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $shape_size, $m)) { 
  718. $size = $m[1]; 
  719. if ($size == 'contain') { 
  720. $size = 'closest-side'; 
  721. } else if ($size == 'cover') { 
  722. $size = 'farthest-corner'; 
  723.  
  724. $coords = array(); 
  725. if (!isset($startx)) { 
  726. $startx = false; 
  727. if (!isset($starty)) { 
  728. $starty = false; 
  729. if (!isset($endx)) { 
  730. $endx = false; 
  731. if (!isset($endy)) { 
  732. $endy = false; 
  733. if (!isset($radius)) { 
  734. $radius = false; 
  735. if (!isset($angle)) { 
  736. $angle = 0; 
  737. $g['coords'] = array($startx, $starty, $endx, $endy, $radius, $angle, $shape, $size, $repeat); 
  738.  
  739. $g['stops'] = array(); 
  740. for ($i = $startStops; $i < count($bgr); $i++) { 
  741. $stop = array(); 
  742. // parse stops 
  743. $el = preg_split('/\s+/', trim($bgr[$i])); 
  744. // mPDF 5.3.74 
  745. $col = $this->mpdf->ConvertColor($el[0]); 
  746. if ($col) { 
  747. $stop['col'] = $col; 
  748. } else { 
  749. $stop['col'] = $col = $this->mpdf->ConvertColor(255); 
  750. if ($col{0} == 1) 
  751. $g['colorspace'] = 'Gray'; 
  752. else if ($col{0} == 4 || $col{0} == 6) 
  753. $g['colorspace'] = 'CMYK'; 
  754. if ($col{0} == 5) { 
  755. $stop['opacity'] = ord($col{4}) / 100; 
  756. } // transparency from rgba() 
  757. else if ($col{0} == 6) { 
  758. $stop['opacity'] = ord($col{5}) / 100; 
  759. } // transparency from cmyka() 
  760. else if ($col{0} == 1 && $col{2} == 1) { 
  761. $stop['opacity'] = ord($col{3}) / 100; 
  762. } // transparency converted from rgba or cmyka() 
  763.  
  764. if (isset($el[1]) && preg_match('/(\d+)[%]/', $el[1], $m)) { 
  765. $stop['offset'] = $m[1] / 100; 
  766. if ($stop['offset'] > 1) { 
  767. unset($stop['offset']); 
  768. } else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $el[1], $m)) { 
  769. $tmp = $this->mpdf->ConvertSize($m[1], $this->mpdf->w, $this->mpdf->FontSize, false); 
  770. $stop['offset'] = $el[1]; 
  771. $g['stops'][] = $stop; 
  772. if (count($g['stops'])) { 
  773. return $g; 
  774. return array(); 
  775.  
  776. function parseBackgroundGradient($bg) 
  777. // background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5; or 
  778. // background-gradient: radial #00FFFF #FFFF00 0.5 0.5 1 1 1.2; 
  779.  
  780. $v = trim($bg); 
  781. $bgr = preg_split('/\s+/', $v); 
  782. $g = array(); 
  783. if (count($bgr) > 6) { 
  784. if (strtoupper(substr($bgr[0], 0, 1)) == 'L' && count($bgr) == 7) { // linear 
  785. $g['type'] = 2; 
  786. //$coords = array(0, 0, 1, 1 ); // 0 0 1 0 or 0 1 1 1 is L 2 R; 1, 1, 0, 1 is R2L; 1, 1, 1, 0 is T2B; 1, 0, 1, 1 is B2T 
  787. // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). 
  788. // The default value is from left to right (x1=0, y1=0, x2=1, y2=0). 
  789. $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6]); 
  790. } else if (count($bgr) == 8) { // radial 
  791. $g['type'] = 3; 
  792. // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,  
  793. // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). 
  794. // (fx, fy) should be inside the circle, otherwise some areas will not be defined 
  795. $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6], $bgr[7]); 
  796. $g['colorspace'] = 'RGB'; 
  797. // mPDF 5.3.74 
  798. $cor = $this->mpdf->ConvertColor($bgr[1]); 
  799. if ($cor{0} == 1) 
  800. $g['colorspace'] = 'Gray'; 
  801. else if ($cor{0} == 4 || $cor{0} == 6) 
  802. $g['colorspace'] = 'CMYK'; 
  803. if ($cor) { 
  804. $g['col'] = $cor; 
  805. } else { 
  806. $g['col'] = $this->mpdf->ConvertColor(255); 
  807. $cor = $this->mpdf->ConvertColor($bgr[2]); 
  808. if ($cor) { 
  809. $g['col2'] = $cor; 
  810. } else { 
  811. $g['col2'] = $this->mpdf->ConvertColor(255); 
  812. $g['extend'] = array('true', 'true'); 
  813. $g['stops'] = array(array('col' => $g['col'], 'opacity' => 1, 'offset' => 0), array('col' => $g['col2'], 'opacity' => 1, 'offset' => 1)); 
  814. return $g; 
  815. return false; 
  816.