�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`�
Warning: session_start(): Session cannot be started after headers have already been sent in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 131

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 135
0x0x
PHP 8.2.31
Preview: Gradient.php Size: 34.06 KB
/home/m/c/i/mciraet/www/wp-content/plugins/complianz-gdpr/assets/vendor/mpdf/mpdf/src/Gradient.php
<?php

namespace Mpdf;

use Mpdf\Color\ColorConverter;
use Mpdf\Writer\BaseWriter;

class Gradient
{

	const TYPE_LINEAR = 2;
	const TYPE_RADIAL = 3;

	/**
	 * @var \Mpdf\Mpdf
	 */
	private $mpdf;

	/**
	 * @var \Mpdf\SizeConverter
	 */
	private $sizeConverter;

	/**
	 * @var \Mpdf\Color\ColorConverter
	 */
	private $colorConverter;

	/**
	 * @var \Mpdf\Writer\BaseWriter
	 */
	private $writer;

	public function __construct(Mpdf $mpdf, SizeConverter $sizeConverter, ColorConverter $colorConverter, BaseWriter $writer)
	{
		$this->mpdf = $mpdf;
		$this->sizeConverter = $sizeConverter;
		$this->colorConverter = $colorConverter;
		$this->writer = $writer;
	}

	// mPDF 5.3.A1
	public function CoonsPatchMesh($x, $y, $w, $h, $patch_array = [], $x_min = 0, $x_max = 1, $y_min = 0, $y_max = 1, $colspace = 'RGB', $return = false)
	{
		$s = ' q ';
		$s.=sprintf(' %.3F %.3F %.3F %.3F re W n ', $x * Mpdf::SCALE, ($this->mpdf->h - $y) * Mpdf::SCALE, $w * Mpdf::SCALE, -$h * Mpdf::SCALE);
		$s.=sprintf(' %.3F 0 0 %.3F %.3F %.3F cm ', $w * Mpdf::SCALE, $h * Mpdf::SCALE, $x * Mpdf::SCALE, ($this->mpdf->h - ($y + $h)) * Mpdf::SCALE);
		$n = count($this->mpdf->gradients) + 1;
		$this->mpdf->gradients[$n]['type'] = 6; //coons patch mesh
		$this->mpdf->gradients[$n]['colorspace'] = $colspace; //coons patch mesh
		$bpcd = 65535; //16 BitsPerCoordinate
		$trans = false;
		$this->mpdf->gradients[$n]['stream'] = '';

		for ($i = 0; $i < count($patch_array); $i++) {
			$this->mpdf->gradients[$n]['stream'] .= chr($patch_array[$i]['f']); //start with the edge flag as 8 bit

			for ($j = 0; $j < count($patch_array[$i]['points']); $j++) {

				// each point as 16 bit
				if (($j % 2) == 1) { // Y coordinate (adjusted as input is From top left)
					$patch_array[$i]['points'][$j] = (($patch_array[$i]['points'][$j] - $y_min) / ($y_max - $y_min)) * $bpcd;
					$patch_array[$i]['points'][$j] = $bpcd - $patch_array[$i]['points'][$j];
				} else {
					$patch_array[$i]['points'][$j] = (($patch_array[$i]['points'][$j] - $x_min) / ($x_max - $x_min)) * $bpcd;
				}
				if ($patch_array[$i]['points'][$j] < 0) {
					$patch_array[$i]['points'][$j] = 0;
				}
				if ($patch_array[$i]['points'][$j] > $bpcd) {
					$patch_array[$i]['points'][$j] = $bpcd;
				}

				$this->mpdf->gradients[$n]['stream'] .= chr(floor($patch_array[$i]['points'][$j] / 256));
				$this->mpdf->gradients[$n]['stream'] .= chr(floor(round($patch_array[$i]['points'][$j]) % 256));
			}

			for ($j = 0; $j < count($patch_array[$i]['colors']); $j++) {
				//each color component as 8 bit
				if ($colspace === 'RGB') {
					$this->mpdf->gradients[$n]['stream'] .= $patch_array[$i]['colors'][$j][1];
					$this->mpdf->gradients[$n]['stream'] .= $patch_array[$i]['colors'][$j][2];
					$this->mpdf->gradients[$n]['stream'] .= $patch_array[$i]['colors'][$j][3];
					if (isset($patch_array[$i]['colors'][$j][4]) && ord($patch_array[$i]['colors'][$j][4]) < 100) {
						$trans = true;
					}
				} elseif ($colspace === 'CMYK') {
					$this->mpdf->gradients[$n]['stream'] .= chr(ord($patch_array[$i]['colors'][$j][1]) * 2.55);
					$this->mpdf->gradients[$n]['stream'] .= chr(ord($patch_array[$i]['colors'][$j][2]) * 2.55);
					$this->mpdf->gradients[$n]['stream'] .= chr(ord($patch_array[$i]['colors'][$j][3]) * 2.55);
					$this->mpdf->gradients[$n]['stream'] .= chr(ord($patch_array[$i]['colors'][$j][4]) * 2.55);
					if (isset($patch_array[$i]['colors'][$j][5]) && ord($patch_array[$i]['colors'][$j][5]) < 100) {
						$trans = true;
					}
				} elseif ($colspace === 'Gray') {
					$this->mpdf->gradients[$n]['stream'] .= $patch_array[$i]['colors'][$j][1];
					if ($patch_array[$i]['colors'][$j][2] == 1) {
						$trans = true;
					} // transparency converted from rgba or cmyka()
				}
			}
		}

		// TRANSPARENCY
		if ($trans) {
			$this->mpdf->gradients[$n]['stream_trans'] = '';

			for ($i = 0; $i < count($patch_array); $i++) {

				$this->mpdf->gradients[$n]['stream_trans'] .= chr($patch_array[$i]['f']);

				for ($j = 0; $j < count($patch_array[$i]['points']); $j++) {
					// each point as 16 bit
					$this->mpdf->gradients[$n]['stream_trans'] .= chr(floor($patch_array[$i]['points'][$j] / 256));
					$this->mpdf->gradients[$n]['stream_trans'] .= chr(floor(round($patch_array[$i]['points'][$j]) % 256));
				}

				for ($j = 0; $j < count($patch_array[$i]['colors']); $j++) {
					// each color component as 8 bit // OPACITY
					if ($colspace === 'RGB') {
						$this->mpdf->gradients[$n]['stream_trans'] .= chr((int) (ord($patch_array[$i]['colors'][$j][4]) * 2.55));
					} elseif ($colspace === 'CMYK') {
						$this->mpdf->gradients[$n]['stream_trans'] .= chr((int) (ord($patch_array[$i]['colors'][$j][5]) * 2.55));
					} elseif ($colspace === 'Gray') {
						$this->mpdf->gradients[$n]['stream_trans'] .= chr((int) (ord($patch_array[$i]['colors'][$j][3]) * 2.55));
					}
				}
			}

			$this->mpdf->gradients[$n]['trans'] = true;
			$s .= ' /TGS' . $n . ' gs ';
		}

		// paint the gradient
		$s .= '/Sh' . $n . ' sh' . "\n";

		// restore previous Graphic State
		$s .= 'Q' . "\n";

		if ($return) {
			return $s;
		}

		$this->writer->write($s);
	}

	// type = linear:2; radial: 3;
	// Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
	//    The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
	// Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
	//    (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
	//    (fx, fy) should be inside the circle, otherwise some areas will not be defined
	// $col = array(R,G,B/255); or array(G/255); or array(C,M,Y,K/100)
	// $stops = array('col'=>$col [, 'opacity'=>0-1] [, 'offset'=>0-1])
	public function Gradient($x, $y, $w, $h, $type, $stops = [], $colorspace = 'RGB', $coords = '', $extend = '', $return = false, $is_mask = false)
	{
		if ($type && stripos($type, 'L') === 0) {
			$type = self::TYPE_LINEAR;
		} elseif ($type && stripos($type, 'R') === 0) {
			$type = self::TYPE_RADIAL;
		}

		if ($colorspace !== 'CMYK' && $colorspace !== 'Gray') {
			$colorspace = 'RGB';
		}

		$bboxw = $w;
		$bboxh = $h;
		$usex = $x;
		$usey = $y;
		$usew = $bboxw;
		$useh = $bboxh;

		if ($type < 1) {
			$type = self::TYPE_LINEAR;
		}

		if ($coords[0] !== false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $coords[0], $m)) {
			$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
			if ($tmp) {
				$coords[0] = $tmp / $w;
			}
		}

		if ($coords[1] !== false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $coords[1], $m)) {
			$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
			if ($tmp) {
				$coords[1] = 1 - ($tmp / $h);
			}
		}

		if ($type == self::TYPE_LINEAR) {
			$angle = (isset($coords[4]) ? $coords[4] : false);
			$repeat = (isset($coords[5]) ? $coords[5] : false);
			// ALL POINTS SET (default for custom mPDF linear gradient) - no -moz
			if ($coords[0] !== false && $coords[1] !== false && $coords[2] !== false && $coords[3] !== false) {
				// do nothing - coords used as they are
			} elseif ($angle !== false && $coords[0] !== false && $coords[1] !== false && $coords[2] === false && $coords[3] === false) {
				// If both a <point> and <angle> are defined, the gradient axis starts from the point and runs along the angle. The end point is
				// defined as before - in this case start points may not be in corners, and axis may not correctly fall in the right quadrant.
				// NO end points (Angle defined & Start points)
				if ($angle == 0 || $angle == 360) {
					$coords[3] = $coords[1];
					if ($coords[0] == 1) {
						$coords[2] = 2;
					} else {
						$coords[2] = 1;
					}
				} elseif ($angle == 90) {
					$coords[2] = $coords[0];
					$coords[3] = 1;
					if ($coords[1] == 1) {
						$coords[3] = 2;
					} else {
						$coords[3] = 1;
					}
				} elseif ($angle == 180) {
					if ($coords[4] == 0) {
						$coords[2] = -1;
					} else {
						$coords[2] = 0;
					}
					$coords[3] = $coords[1];
				} elseif ($angle == 270) {
					$coords[2] = $coords[0];
					if ($coords[1] == 0) {
						$coords[3] = -1;
					} else {
						$coords[3] = 0;
					}
				} else {
					$endx = 1;
					$endy = 1;
					if ($angle <= 90) {
						if ($angle <= 45) {
							$endy = tan(deg2rad($angle));
						} else {
							$endx = tan(deg2rad(90 - $angle));
						}
						$b = atan2($endy * $bboxh, $endx * $bboxw);
						$ny = 1 - $coords[1] - (tan($b) * (1 - $coords[0]));
						$tx = sin($b) * cos($b) * $ny;
						$ty = cos($b) * cos($b) * $ny;
						$coords[2] = 1 + $tx;
						$coords[3] = 1 - $ty;
					} elseif ($angle <= 180) {
						if ($angle <= 135) {
							$endx = tan(deg2rad($angle - 90));
						} else {
							$endy = tan(deg2rad(180 - $angle));
						}
						$b = atan2($endy * $bboxh, $endx * $bboxw);
						$ny = 1 - $coords[1] - (tan($b) * $coords[0]);
						$tx = sin($b) * cos($b) * $ny;
						$ty = cos($b) * cos($b) * $ny;
						$coords[2] = -$tx;
						$coords[3] = 1 - $ty;
					} elseif ($angle <= 270) {
						if ($angle <= 225) {
							$endy = tan(deg2rad($angle - 180));
						} else {
							$endx = tan(deg2rad(270 - $angle));
						}
						$b = atan2($endy * $bboxh, $endx * $bboxw);
						$ny = $coords[1] - (tan($b) * $coords[0]);
						$tx = sin($b) * cos($b) * $ny;
						$ty = cos($b) * cos($b) * $ny;
						$coords[2] = -$tx;
						$coords[3] = $ty;
					} else {
						if ($angle <= 315) {
							$endx = tan(deg2rad($angle - 270));
						} else {
							$endy = tan(deg2rad(360 - $angle));
						}
						$b = atan2($endy * $bboxh, $endx * $bboxw);
						$ny = $coords[1] - (tan($b) * (1 - $coords[0]));
						$tx = sin($b) * cos($b) * $ny;
						$ty = cos($b) * cos($b) * $ny;
						$coords[2] = 1 + $tx;
						$coords[3] = $ty;
					}
				}
			} elseif ($angle !== false && $coords[0] === false && $coords[1] === false) {
				// -moz If the first parameter is only an <angle>, the gradient axis starts from the box's corner that would ensure the
				// axis goes through the box. The axis runs along the specified angle. The end point of the axis is defined such that the
				// farthest corner of the box from the starting point is perpendicular to the gradient axis at that point.
				// NO end points or Start points (Angle defined)
				if ($angle == 0 || $angle == 360) {
					$coords[0] = 0;
					$coords[1] = 0;
					$coords[2] = 1;
					$coords[3] = 0;
				} elseif ($angle == 90) {
					$coords[0] = 0;
					$coords[1] = 0;
					$coords[2] = 0;
					$coords[3] = 1;
				} elseif ($angle == 180) {
					$coords[0] = 1;
					$coords[1] = 0;
					$coords[2] = 0;
					$coords[3] = 0;
				} elseif ($angle == 270) {
					$coords[0] = 0;
					$coords[1] = 1;
					$coords[2] = 0;
					$coords[3] = 0;
				} else {
					if ($angle <= 90) {
						$coords[0] = 0;
						$coords[1] = 0;
						if ($angle <= 45) {
							$endx = 1;
							$endy = tan(deg2rad($angle));
						} else {
							$endx = tan(deg2rad(90 - $angle));
							$endy = 1;
						}
					} elseif ($angle <= 180) {
						$coords[0] = 1;
						$coords[1] = 0;
						if ($angle <= 135) {
							$endx = tan(deg2rad($angle - 90));
							$endy = 1;
						} else {
							$endx = 1;
							$endy = tan(deg2rad(180 - $angle));
						}
					} elseif ($angle <= 270) {
						$coords[0] = 1;
						$coords[1] = 1;
						if ($angle <= 225) {
							$endx = 1;
							$endy = tan(deg2rad($angle - 180));
						} else {
							$endx = tan(deg2rad(270 - $angle));
							$endy = 1;
						}
					} else {
						$coords[0] = 0;
						$coords[1] = 1;
						if ($angle <= 315) {
							$endx = tan(deg2rad($angle - 270));
							$endy = 1;
						} else {
							$endx = 1;
							$endy = tan(deg2rad(360 - $angle));
						}
					}
					$b = atan2($endy * $bboxh, $endx * $bboxw);
					$h2 = $bboxh - ($bboxh * tan($b));
					$px = $bboxh + ($h2 * sin($b) * cos($b));
					$py = ($bboxh * tan($b)) + ($h2 * sin($b) * sin($b));
					$x1 = $px / $bboxh;
					$y1 = $py / $bboxh;
					if ($angle <= 90) {
						$coords[2] = $x1;
						$coords[3] = $y1;
					} elseif ($angle <= 180) {
						$coords[2] = 1 - $x1;
						$coords[3] = $y1;
					} elseif ($angle <= 270) {
						$coords[2] = 1 - $x1;
						$coords[3] = 1 - $y1;
					} else {
						$coords[2] = $x1;
						$coords[3] = 1 - $y1;
					}
				}
			} elseif ((!isset($angle) || $angle === false) && $coords[0] !== false && $coords[1] !== false) {
				// -moz If the first parameter to the gradient function is only a <point>, the gradient axis starts from the specified point,
				// 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
				// gradient is to be applied to.
				// NO angle and NO end points (Start points defined)
				$coords[2] = 1 - $coords[0];
				$coords[3] = 1 - $coords[1];
				$angle = rad2deg(atan2($coords[3] - $coords[1], $coords[2] - $coords[0]));
				if ($angle < 0) {
					$angle += 360;
				} elseif ($angle > 360) {
					$angle -= 360;
				}
				if ($angle != 0 && $angle != 360 && $angle != 90 && $angle != 180 && $angle != 270) {
					if ($w >= $h) {
						$coords[1] *= $h / $w;
						$coords[3] *= $h / $w;
						$usew = $useh = $bboxw;
						$usey -= ($w - $h);
					} else {
						$coords[0] *= $w / $h;
						$coords[2] *= $w / $h;
						$usew = $useh = $bboxh;
					}
				}
			} else {
				// default values T2B
				// -moz 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.
				// All values are set in parseMozGradient - so won't appear here
				$coords = [0, 0, 1, 0]; // default for original linear gradient (L2R)
			}
		} elseif ($type == self::TYPE_RADIAL) {
			$radius = (isset($coords[4]) ? $coords[4] : false);
			$shape = (isset($coords[6]) ? $coords[6] : false);
			$size = (isset($coords[7]) ? $coords[7] : false);
			$repeat = (isset($coords[8]) ? $coords[8] : false);
			// ALL POINTS AND RADIUS SET (default for custom mPDF radial gradient) - no -moz
			if ($coords[0] !== false && $coords[1] !== false && $coords[2] !== false && $coords[3] !== false && $coords[4] !== false) {
				// If a <point> is defined
				// do nothing - coords used as they are
			} elseif ($shape !== false && $size !== false) {
				if ($coords[2] == false) {
					$coords[2] = $coords[0];
				}
				if ($coords[3] == false) {
					$coords[3] = $coords[1];
				}
				// ELLIPSE
				if ($shape === 'ellipse') {
					$corner1 = sqrt(($coords[0] ** 2) + ($coords[1] ** 2));
					$corner2 = sqrt(($coords[0] ** 2) + ((1 - $coords[1]) ** 2));
					$corner3 = sqrt(((1 - $coords[0]) ** 2) + ($coords[1] ** 2));
					$corner4 = sqrt(((1 - $coords[0]) ** 2) + ((1 - $coords[1]) ** 2));
					if ($size === 'closest-side') {
						$radius = min($coords[0], $coords[1], 1 - $coords[0], 1 - $coords[1]);
					} elseif ($size === 'closest-corner') {
						$radius = min($corner1, $corner2, $corner3, $corner4);
					} elseif ($size === 'farthest-side') {
						$radius = max($coords[0], $coords[1], 1 - $coords[0], 1 - $coords[1]);
					} else {
						$radius = max($corner1, $corner2, $corner3, $corner4);
					} // farthest corner (default)
				} elseif ($shape === 'circle') {
					if ($w >= $h) {
						$coords[1] = $coords[3] = ($coords[1] * $h / $w);
						$corner1 = sqrt(($coords[0] ** 2) + ($coords[1] ** 2));
						$corner2 = sqrt(($coords[0] ** 2) + ((($h / $w) - $coords[1]) ** 2));
						$corner3 = sqrt(((1 - $coords[0]) ** 2) + ($coords[1] ** 2));
						$corner4 = sqrt(((1 - $coords[0]) ** 2) + ((($h / $w) - $coords[1]) ** 2));
						if ($size === 'closest-side') {
							$radius = min($coords[0], $coords[1], 1 - $coords[0], ($h / $w) - $coords[1]);
						} elseif ($size === 'closest-corner') {
							$radius = min($corner1, $corner2, $corner3, $corner4);
						} elseif ($size === 'farthest-side') {
							$radius = max($coords[0], $coords[1], 1 - $coords[0], ($h / $w) - $coords[1]);
						} elseif ($size === 'farthest-corner') {
							$radius = max($corner1, $corner2, $corner3, $corner4);
						} // farthest corner (default)
						$usew = $useh = $bboxw;
						$usey -= ($w - $h);
					} else {
						$coords[0] = $coords[2] = ($coords[0] * $w / $h);
						$corner1 = sqrt(($coords[0] ** 2) + ($coords[1] ** 2));
						$corner2 = sqrt(($coords[0] ** 2) + ((1 - $coords[1]) ** 2));
						$corner3 = sqrt(((($w / $h) - $coords[0]) ** 2) + ($coords[1] ** 2));
						$corner4 = sqrt(((($w / $h) - $coords[0]) ** 2) + ((1 - $coords[1]) ** 2));
						if ($size === 'closest-side') {
							$radius = min($coords[0], $coords[1], ($w / $h) - $coords[0], 1 - $coords[1]);
						} elseif ($size === 'closest-corner') {
							$radius = min($corner1, $corner2, $corner3, $corner4);
						} elseif ($size === 'farthest-side') {
							$radius = max($coords[0], $coords[1], ($w / $h) - $coords[0], 1 - $coords[1]);
						} elseif ($size === 'farthest-corner') {
							$radius = max($corner1, $corner2, $corner3, $corner4);
						} // farthest corner (default)
						$usew = $useh = $bboxh;
					}
				}
				if ($radius == 0) {
					$radius = 0.001;
				} // to prevent error
				$coords[4] = $radius;
			} else {
				// -moz If entire function consists of only <stop> values
				// All values are set in parseMozGradient - so won't appear here
				$coords = [0.5, 0.5, 0.5, 0.5]; // default for radial gradient (centred)
			}
		}
		$s = ' q';
		$s .= sprintf(' %.3F %.3F %.3F %.3F re W n', $x * Mpdf::SCALE, ($this->mpdf->h - $y) * Mpdf::SCALE, $w * Mpdf::SCALE, -$h * Mpdf::SCALE) . "\n";
		$s .= sprintf(' %.3F 0 0 %.3F %.3F %.3F cm', $usew * Mpdf::SCALE, $useh * Mpdf::SCALE, $usex * Mpdf::SCALE, ($this->mpdf->h - ($usey + $useh)) * Mpdf::SCALE) . "\n";

		$n = count($this->mpdf->gradients) + 1;
		$this->mpdf->gradients[$n]['type'] = $type;
		$this->mpdf->gradients[$n]['colorspace'] = $colorspace;
		$trans = false;
		$this->mpdf->gradients[$n]['is_mask'] = $is_mask;
		if ($is_mask) {
			$trans = true;
		}
		if (count($stops) == 1) {
			$stops[1] = $stops[0];
		}
		if (!isset($stops[0]['offset'])) {
			$stops[0]['offset'] = 0;
		}
		if (!isset($stops[count($stops) - 1]['offset'])) {
			$stops[count($stops) - 1]['offset'] = 1;
		}

		// Fix stop-offsets set as absolute lengths
		if ($type == self::TYPE_LINEAR) {
			$axisx = ($coords[2] - $coords[0]) * $usew;
			$axisy = ($coords[3] - $coords[1]) * $useh;
			$axis_length = sqrt(($axisx ** 2) + ($axisy ** 2));
		} else {
			$axis_length = $coords[4] * $usew;
		} // Absolute lengths are meaningless for an ellipse - Firefox uses Width as reference

		for ($i = 0; $i < count($stops); $i++) {
			if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $stops[$i]['offset'], $m)) {
				$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
				$stops[$i]['offset'] = $axis_length ? $tmp / $axis_length : 0;
			}
		}


		if (isset($stops[0]['offset']) && $stops[0]['offset'] > 0) {
			$firststop = $stops[0];
			$firststop['offset'] = 0;
			array_unshift($stops, $firststop);
		}
		if (!$repeat && isset($stops[count($stops) - 1]['offset']) && $stops[count($stops) - 1]['offset'] < 1) {
			$endstop = $stops[count($stops) - 1];
			$endstop['offset'] = 1;
			$stops[] = $endstop;
		}
		if ($stops[0]['offset'] > $stops[count($stops) - 1]['offset']) {
			$stops[0]['offset'] = 0;
			$stops[count($stops) - 1]['offset'] = 1;
		}

		for ($i = 0; $i < count($stops); $i++) {
			// mPDF 5.3.74
			if ($colorspace === 'CMYK') {
				$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);
			} elseif ($colorspace === 'Gray') {
				$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F', ord($stops[$i]['col'][1]) / 255);
			} else {
				$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);
			}
			if (!isset($stops[$i]['opacity'])) {
				$stops[$i]['opacity'] = 1;
			} elseif ($stops[$i]['opacity'] > 1 || $stops[$i]['opacity'] < 0) {
				$stops[$i]['opacity'] = 1;
			} elseif ($stops[$i]['opacity'] < 1) {
				$trans = true;
			}
			$this->mpdf->gradients[$n]['stops'][$i]['opacity'] = $stops[$i]['opacity'];
			// OFFSET
			if ($i > 0 && $i < (count($stops) - 1)) {
				if (!isset($stops[$i]['offset']) || (isset($stops[$i + 1]['offset']) && $stops[$i]['offset'] > $stops[$i + 1]['offset']) || $stops[$i]['offset'] < $stops[$i - 1]['offset']) {
					if (isset($stops[$i - 1]['offset']) && isset($stops[$i + 1]['offset'])) {
						$stops[$i]['offset'] = ($stops[$i - 1]['offset'] + $stops[$i + 1]['offset']) / 2;
					} else {
						for ($j = ($i + 1); $j < count($stops); $j++) {
							if (isset($stops[$j]['offset'])) {
								break;
							}
						}
						$int = ($stops[$j]['offset'] - $stops[$i - 1]['offset']) / ($j - $i + 1);
						for ($f = 0; $f < ($j - $i - 1); $f++) {
							$stops[$i + $f]['offset'] = $stops[$i + $f - 1]['offset'] + $int;
						}
					}
				}
			}
			$this->mpdf->gradients[$n]['stops'][$i]['offset'] = $stops[$i]['offset'];
		}

		if ($repeat) {
			$ns = count($this->mpdf->gradients[$n]['stops']);
			$offs = [];
			for ($i = 0; $i < $ns; $i++) {
				$offs[$i] = $this->mpdf->gradients[$n]['stops'][$i]['offset'];
			}
			$gp = 0;
			$inside = true;
			while ($inside) {
				$gp++;
				for ($i = 0; $i < $ns; $i++) {
					$this->mpdf->gradients[$n]['stops'][($ns * $gp) + $i] = $this->mpdf->gradients[$n]['stops'][($ns * ($gp - 1)) + $i];
					$tmp = $this->mpdf->gradients[$n]['stops'][($ns * ($gp - 1)) + ($ns - 1)]['offset'] + $offs[$i];
					if ($tmp < 1) {
						$this->mpdf->gradients[$n]['stops'][($ns * $gp) + $i]['offset'] = $tmp;
					} else {
						$this->mpdf->gradients[$n]['stops'][($ns * $gp) + $i]['offset'] = 1;
						$inside = false;
						break;
					}
				}
			}
		}

		if ($trans) {
			$this->mpdf->gradients[$n]['trans'] = true;
			$s .= ' /TGS' . $n . ' gs ';
		}
		if (!is_array($extend) || count($extend) < 1) {
			$extend = ['true', 'true']; // These are supposed to be quoted - appear in PDF file as text
		}
		$this->mpdf->gradients[$n]['coords'] = $coords;
		$this->mpdf->gradients[$n]['extend'] = $extend;
		//paint the gradient
		$s .= '/Sh' . $n . ' sh ' . "\n";
		//restore previous Graphic State
		$s .= ' Q ' . "\n";
		if ($return) {
			return $s;
		}

		$this->writer->write($s);
	}

	private function parseMozLinearGradient($m, $repeat)
	{
		$g = [];
		$g['type'] = self::TYPE_LINEAR;
		$g['colorspace'] = 'RGB';
		$g['extend'] = ['true', 'true'];
		$v = trim($m[1]);

		// Change commas inside e.g. rgb(x,x,x)
		while (preg_match('/(\([^\)]*?),/', $v)) {
			$v = preg_replace('/(\([^\)]*?),/', '\\1@', $v);
		}

		// Remove spaces inside e.g. rgb(x, x, x)
		while (preg_match('/(\([^\)]*?)[ ]/', $v)) {
			$v = preg_replace('/(\([^\)]*?)[ ]/', '\\1', $v);
		}

		$bgr = preg_split('/\s*,\s*/', $v);

		for ($i = 0; $i < count($bgr); $i++) {
			$bgr[$i] = preg_replace('/@/', ',', $bgr[$i]);
		}
		// Is first part $bgr[0] a valid point/angle?
		$first = preg_split('/\s+/', trim($bgr[0]));
		if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i', $bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i', $bgr[0])) {
			$startStops = 1;
		} elseif (trim($first[count($first) - 1]) === '0') {
			$startStops = 1;
		} else {
			$check = $this->colorConverter->convert($first[0], $this->mpdf->PDFAXwarnings);
			$startStops = 1;
			if ($check) {
				$startStops = 0;
			}
		}

		// first part a valid point/angle?
		if ($startStops === 1) { // default values

			// [<point> || <angle>,] = [<% em px left center right bottom top> || <deg grad rad 0>,]
			if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i', $bgr[0], $m)) {
				$angle = $m[1] + 0;
				if (strtolower($m[2]) === 'grad') {
					$angle *= (360 / 400);
				} elseif (strtolower($m[2]) === 'rad') {
					$angle = rad2deg($angle);
				}
				while ($angle < 0) {
					$angle += 360;
				}
				$angle %= 360;
			} elseif (trim($first[count($first) - 1]) === '0') {
				$angle = 0;
			}

			if (stripos($bgr[0], 'left') !== false) {
				$startx = 1;
			} elseif (stripos($bgr[0], 'right') !== false) {
				$startx = 0;
			}

			if (stripos($bgr[0], 'top') !== false) {
				$starty = 1;
			} elseif (stripos($bgr[0], 'bottom') !== false) {
				$starty = 0;
			}

			// Check for %? ?% or %%
			if (preg_match('/(\d+)[%]/i', $first[0], $m)) {
				$startx = $m[1] / 100;
			} elseif (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[0], $m)) {
				$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
				if ($tmp) {
					$startx = $m[1];
				}
			}

			if (isset($first[1]) && preg_match('/(\d+)[%]/i', $first[1], $m)) {
				$starty = 1 - ($m[1] / 100);
			} elseif (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[1], $m)) {
				$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
				if ($tmp) {
					$starty = $m[1];
				}
			}

			if (isset($startx) && !isset($starty)) {
				$starty = 0.5;
			}

			if (!isset($startx) && isset($starty)) {
				$startx = 0.5;
			}

		} else {
			// 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.
			$starty = 1;
			$startx = 0.5;
			$endy = 0;
			$endx = 0.5;
		}

		if (!isset($startx)) {
			$startx = false;
		}

		if (!isset($starty)) {
			$starty = false;
		}

		if (!isset($endx)) {
			$endx = false;
		}

		if (!isset($endy)) {
			$endy = false;
		}

		if (!isset($angle)) {
			$angle = false;
		}

		$g['coords'] = [$startx, $starty, $endx, $endy, $angle, $repeat];
		$g['stops'] = [];

		for ($i = $startStops; $i < count($bgr); $i++) {

			// parse stops
			$el = preg_split('/\s+/', trim($bgr[$i]));
			// mPDF 5.3.74
			$col = $this->colorConverter->convert($el[0], $this->mpdf->PDFAXwarnings);

			if (!$col) {
				$col = $this->colorConverter->convert(255, $this->mpdf->PDFAXwarnings);
			}

			if ($col[0] == 1) {
				$g['colorspace'] = 'Gray';
			} elseif ($col[0] == 4 || $col[0] == 6) {
				$g['colorspace'] = 'CMYK';
			}

			$g['stops'][] = $this->getStop($col, $el, true);
		}

		return $g;
	}

	private function parseMozRadialGradient($m, $repeat)
	{
		$g = [];
		$g['type'] = self::TYPE_RADIAL;
		$g['colorspace'] = 'RGB';
		$g['extend'] = ['true', 'true'];
		$v = trim($m[1]);
		// Change commas inside e.g. rgb(x,x,x)
		while (preg_match('/(\([^\)]*?),/', $v)) {
			$v = preg_replace('/(\([^\)]*?),/', '\\1@', $v);
		}
		// Remove spaces inside e.g. rgb(x, x, x)
		while (preg_match('/(\([^\)]*?)[ ]/', $v)) {
			$v = preg_replace('/(\([^\)]*?)[ ]/', '\\1', $v);
		}
		$bgr = preg_split('/\s*,\s*/', $v);
		for ($i = 0; $i < count($bgr); $i++) {
			$bgr[$i] = preg_replace('/@/', ',', $bgr[$i]);
		}

		// Is first part $bgr[0] a valid point/angle?
		$startStops = 0;
		$pos_angle = false;
		$shape_size = false;
		$first = preg_split('/\s+/', trim($bgr[0]));
		$checkCol = $this->colorConverter->convert($first[0], $this->mpdf->PDFAXwarnings);
		if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i', $bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i', $bgr[0])) {
			$startStops = 1;
			$pos_angle = $bgr[0];
		} elseif (trim($first[count($first) - 1]) === '0') {
			$startStops = 1;
			$pos_angle = $bgr[0];
		} elseif (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $bgr[0])) {
			$startStops = 1;
			$shape_size = $bgr[0];
		} elseif (!$checkCol) {
			$startStops = 1;
			$pos_angle = $bgr[0];
		}
		if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $bgr[1])) {
			$startStops = 2;
			$shape_size = $bgr[1];
		}

		// If valid point/angle?
		if ($pos_angle) { // default values
			// [<point> || <angle>,] = [<% em px left center right bottom top> || <deg grad rad 0>,]
			if (stripos($pos_angle, 'left') !== false) {
				$startx = 0;
			} elseif (stripos($pos_angle, 'right') !== false) {
				$startx = 1;
			}
			if (stripos($pos_angle, 'top') !== false) {
				$starty = 1;
			} elseif (stripos($pos_angle, 'bottom') !== false) {
				$starty = 0;
			}
			// Check for %? ?% or %%
			if (preg_match('/(\d+)[%]/i', $first[0], $m)) {
				$startx = $m[1] / 100;
			} elseif (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[0], $m)) {
				$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
				if ($tmp) {
					$startx = $m[1];
				}
			}
			if (isset($first[1]) && preg_match('/(\d+)[%]/i', $first[1], $m)) {
				$starty = 1 - ($m[1] / 100);
			} elseif (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $first[1], $m)) {
				$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
				if ($tmp) {
					$starty = $m[1];
				}
			}

			if (!isset($starty)) {
				$starty = 0.5;
			}
			if (!isset($startx)) {
				$startx = 0.5;
			}
		} else {
			// 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. default values Center
			$starty = 0.5;
			$startx = 0.5;
			$endy = 0.5;
			$endx = 0.5;
		}

		// If valid shape/size?
		$shape = 'ellipse'; // default
		$size = 'farthest-corner'; // default
		if ($shape_size) { // default values
			if (preg_match('/(circle|ellipse)/i', $shape_size, $m)) {
				$shape = $m[1];
			}
			if (preg_match('/(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i', $shape_size, $m)) {
				$size = $m[1];
				if ($size === 'contain') {
					$size = 'closest-side';
				} elseif ($size === 'cover') {
					$size = 'farthest-corner';
				}
			}
		}

		if (!isset($startx)) {
			$startx = false;
		}
		if (!isset($starty)) {
			$starty = false;
		}
		if (!isset($endx)) {
			$endx = false;
		}
		if (!isset($endy)) {
			$endy = false;
		}
		$radius = false;
		$angle = 0;
		$g['coords'] = [$startx, $starty, $endx, $endy, $radius, $angle, $shape, $size, $repeat];

		$g['stops'] = [];
		for ($i = $startStops; $i < count($bgr); $i++) {
			// parse stops
			$el = preg_split('/\s+/', trim($bgr[$i]));
			// mPDF 5.3.74
			$col = $this->colorConverter->convert($el[0], $this->mpdf->PDFAXwarnings);
			if (!$col) {
				$col = $this->colorConverter->convert(255, $this->mpdf->PDFAXwarnings);
			}
			if ($col[0] == 1) {
				$g['colorspace'] = 'Gray';
			} elseif ($col[0] == 4 || $col[0] == 6) {
				$g['colorspace'] = 'CMYK';
			}
			$g['stops'][] = $this->getStop($col, $el);
		}
		return $g;
	}

	private function getStop($col, $el, $convertOffset = false)
	{
		$stop = [
			'col' => $col,
		];

		if ($col[0] == 5) {
			// transparency from rgba()
			$stop['opacity'] = ord($col[4]) / 100;
		} elseif ($col[0] == 6) {
			// transparency from cmyka()
			$stop['opacity'] = ord($col[5]) / 100;
		} elseif ($col[0] == 1 && $col[2] == 1) {
			// transparency converted from rgba or cmyka()
			$stop['opacity'] = ord($col[3]) / 100;
		}

		if (isset($el[1])) {
			if (preg_match('/(\d+)[%]/', $el[1], $m)) {
				$stop['offset'] = $m[1] / 100;
				if ($stop['offset'] > 1) {
					unset($stop['offset']);
				}
			} elseif (preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i', $el[1], $m)) {
				if ($convertOffset) {
					$tmp = $this->sizeConverter->convert($m[1], $this->mpdf->w, $this->mpdf->FontSize, false);
					if ($tmp) {
						$stop['offset'] = $m[1];
					}
				} else {
					$stop['offset'] = $el[1];
				}
			}
		}

		return $stop;
	}

	public function parseMozGradient($bg)
	{
		//	background[-image]: -moz-linear-gradient(left, #c7Fdde 20%, #FF0000 );
		//	background[-image]: linear-gradient(left, #c7Fdde 20%, #FF0000 ); // CSS3
		$repeat = strpos($bg, 'repeating-') !== false;

		if (preg_match('/linear-gradient\((.*)\)/', $bg, $m)) {
			$g = $this->parseMozLinearGradient($m, $repeat);
			if (count($g['stops'])) {
				return $g;
			}
		} elseif (preg_match('/radial-gradient\((.*)\)/', $bg, $m)) {
			$g = $this->parseMozRadialGradient($m, $repeat);
			if (count($g['stops'])) {
				return $g;
			}
		}
		return [];
	}

	public function parseBackgroundGradient($bg)
	{
		// background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5;  or
		// background-gradient: radial #00FFFF #FFFF00 0.5 0.5 1 1 1.2;

		$v = trim($bg);
		$bgr = preg_split('/\s+/', $v);
		$count_bgr = count($bgr);
		$g = [];
		if ($count_bgr > 6) {
			if (stripos($bgr[0], 'L') === 0 && $count_bgr === 7) {  // linear
				$g['type'] = self::TYPE_LINEAR;
				//$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
				// Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
				//    The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
				$g['coords'] = [$bgr[3], $bgr[4], $bgr[5], $bgr[6]];
			} elseif ($count_bgr === 8) { // radial
				$g['type'] = self::TYPE_RADIAL;
				// Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
				//    (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
				//    (fx, fy) should be inside the circle, otherwise some areas will not be defined
				$g['coords'] = [$bgr[3], $bgr[4], $bgr[5], $bgr[6], $bgr[7]];
			}
			$g['colorspace'] = 'RGB';
			// mPDF 5.3.74
			$cor = $this->colorConverter->convert($bgr[1], $this->mpdf->PDFAXwarnings);
			if ($cor[0] == 1) {
				$g['colorspace'] = 'Gray';
			} elseif ($cor[0] == 4 || $cor[0] == 6) {
				$g['colorspace'] = 'CMYK';
			}
			if ($cor) {
				$g['col'] = $cor;
			} else {
				$g['col'] = $this->colorConverter->convert(255, $this->mpdf->PDFAXwarnings);
			}
			$cor = $this->colorConverter->convert($bgr[2], $this->mpdf->PDFAXwarnings);
			if ($cor) {
				$g['col2'] = $cor;
			} else {
				$g['col2'] = $this->colorConverter->convert(255, $this->mpdf->PDFAXwarnings);
			}
			$g['extend'] = ['true', 'true'];
			$g['stops'] = [['col' => $g['col'], 'opacity' => 1, 'offset' => 0], ['col' => $g['col2'], 'opacity' => 1, 'offset' => 1]];
			return $g;
		}
		return false;
	}
}

Directory Contents

Dirs: 20 × Files: 30
Name Size Perms Modified Actions
Barcode DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Color DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Config DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Container DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Css DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Exception DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
File DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Fonts DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Gif DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Http DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Image DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Language DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Log DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Output DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Pdf DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Shaper DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Tag DIR
- drwxr-xr-x 2026-09-26 10:16:49
Edit Download
Utils DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
Writer DIR
- drwxr-xr-x 2026-08-19 22:05:56
Edit Download
3.54 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
5.92 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
2.32 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
76.41 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
14.58 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
67.39 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
11.59 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
165 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
521 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
34.06 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
731 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
4.97 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
938.82 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
73 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
82 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
248.46 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
163.10 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
1.02 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
2.33 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
5.79 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
3.31 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
1.50 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
32.67 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
7.23 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
169.31 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
14.22 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
128.86 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
49 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
1.17 KB lrw-r--r-- 2026-08-19 22:05:56
Edit Download
887 B lrw-r--r-- 2026-08-19 22:05:56
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI