Mercurial > hg > rc2
comparison skins/larry/svggradient.php @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
| author | Charlie Root |
|---|---|
| date | Thu, 04 Jan 2018 15:52:31 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4681f974d28b |
|---|---|
| 1 <?php | |
| 2 | |
| 3 /** | |
| 4 * Render SVG gradients for IE 9 | |
| 5 * | |
| 6 * Copyright (c) 2012, The Roundcube Dev Team | |
| 7 * | |
| 8 * The contents are subject to the Creative Commons Attribution-ShareAlike | |
| 9 * License. It is allowed to copy, distribute, transmit and to adapt the work | |
| 10 * by keeping credits to the original autors in the README file. | |
| 11 * See http://creativecommons.org/licenses/by-sa/3.0/ for details. | |
| 12 */ | |
| 13 | |
| 14 ini_set('error_reporting', E_ALL &~ (E_NOTICE | E_STRICT)); | |
| 15 | |
| 16 header('Content-Type: image/svg+xml'); | |
| 17 header("Expires: ".gmdate("D, d M Y H:i:s", time()+864000)." GMT"); | |
| 18 header("Cache-Control: max-age=864000"); | |
| 19 header("Pragma: "); | |
| 20 | |
| 21 $svg_stops = ''; | |
| 22 $color_stops = explode(';', preg_replace('/[^a-f0-9,;%]/i', '', $_GET['c'])); | |
| 23 $gradient_coords = !empty($_GET['h']) ? 'x1="0%" y1="0%" x2="100%" y2="0%"' : 'x1="0%" y1="0%" x2="0%" y2="100%"'; | |
| 24 $last = count($color_stops) - 1; | |
| 25 foreach ($color_stops as $i => $stop) { | |
| 26 list($color, $offset) = explode(',', $stop); | |
| 27 if ($offset) | |
| 28 $offset = intval($offset); | |
| 29 else | |
| 30 $offset = $i == $last ? 100 : 0; | |
| 31 | |
| 32 $svg_stops .= '<stop offset="' . $offset . '%" stop-color="#' . $color . '" stop-opacity="1"/>'; | |
| 33 } | |
| 34 | |
| 35 ?> | |
| 36 <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" version="1.0" width="100%" height="100%"> | |
| 37 <defs> | |
| 38 <linearGradient id="LG1" <?php echo $gradient_coords; ?> spreadMethod="pad"> | |
| 39 <?php echo $svg_stops; ?> | |
| 40 </linearGradient> | |
| 41 </defs> | |
| 42 <rect width="100%" height="100%" style="fill:url(#LG1);"/> | |
| 43 </svg> |
