在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
使用PHP动态生成SVGZ图片(gzip压缩的SVG) 经测试SVG的动画性能很差,简单的动画CPU都能占到 30%左右。 可能的用途:
<?php header('Content-Type:image/svg+xml'); header('Content-Encoding:gzip'); $image_width = @$_GET['w'] ?: 800; $image_height = @$_GET['h'] ?: 600; $svg = <<<EOF <svg version="1.1" width="{$image_width}" height="{$image_height}" viewBox="0 0 {$image_width} {$image_height}" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <defs> <g > <circle cx="340" cy="90" r="15" fill="blue" /> <path /> <circle cx="0" cy="0" r="5" fill="white" stroke="black" stroke-width="1" > <animateMotion dur="30s" repeatCount="indefinite"> <mpath xlink:href="#path2" /> </animateMotion> </circle> </g> <radialGradient > <stop stop-color="#FF0000" offset="0%" stop-opacity="1"/> <stop stop-color="#FBF900" offset="95%" stop-opacity="1"/> <stop stop-color="#FFFFFF" offset="100%" stop-opacity="1"/> </radialGradient> </defs> <rect x="0" y="0" width="100%" height="100%" fill="black" /> <circle cx="50%" cy="50%" r="10%" fill="url(#sunfill)" /> <path /> <use x="0" y="0" xlink:href="#E"> <animateMotion dur="365s" repeatCount="indefinite" > <mpath xlink:href="#path1" /> </animateMotion> </use> EOF; $err = 'svg 生成错误!' . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']; if ($err != '') { $svg .= '<text x="10" y="20" font-size="12" text-anchor="start" fill="#f00">' . $err . '</text>'; } $svg .= '</svg>'; $svg = gzencode($svg, 9); echo $svg;
|
2022-08-16
2022-11-06
2022-08-18
2022-08-15
2022-08-15
请发表评论