1<?php
2
3namespace Mpdf\Tag;
4
5class Progress extends Meter
6{
7	protected function makeSVG($type, $value, $max, $min, $optimum, $low, $high)
8	{
9		$svg = '';
10
11		if ($type == '2') {
12			/////////////////////////////////////////////////////////////////////////////////////
13			///////// CUSTOM <progress type="2">
14			/////////////////////////////////////////////////////////////////////////////////////
15		} else {
16			/////////////////////////////////////////////////////////////////////////////////////
17			///////// DEFAULT <progress>
18			/////////////////////////////////////////////////////////////////////////////////////
19			$h = 10;
20			$w = 100;
21			$border_radius = 0.143;  // Factor of Height
22
23			if ($value or $value === '0') {
24				$fill = 'url(#GrGRAY)';
25			} else {
26				$fill = '#f8f8f8';
27			}
28
29			$svg = '<svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '"><g>
30
31<defs>
32<linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
33<stop offset="0%" stop-color="rgb(222, 222, 222)" />
34<stop offset="20%" stop-color="rgb(232, 232, 232)" />
35<stop offset="25%" stop-color="rgb(232, 232, 232)" />
36<stop offset="100%" stop-color="rgb(182, 182, 182)" />
37</linearGradient>
38
39<linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
40<stop offset="0%" stop-color="rgb(102, 230, 102)" />
41<stop offset="20%" stop-color="rgb(218, 255, 218)" />
42<stop offset="25%" stop-color="rgb(218, 255, 218)" />
43<stop offset="100%" stop-color="rgb(0, 148, 0)" />
44</linearGradient>
45
46</defs>
47
48<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="' . $fill . '" stroke="none" />
49';
50
51			if ($value) {
52				$barw = (($value - $min) / ($max - $min) ) * $w;
53				$barcol = 'url(#GrGREEN)';
54				$svg .= '<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $barw . '" height="' . $h . '" fill="' . $barcol . '" stroke="none" />';
55			}
56
57
58			// Borders
59			$svg .= '<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />';
60			if ($value) {
61				//  $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />';
62			}
63
64
65			$svg .= '</g></svg>';
66		}
67
68
69		return $svg;
70	}
71
72}
73