如何水平翻转svg中的图像?
我有下面的svg图像,我想水平翻转图像。我该怎么做?已经尝试将scale(-1,1)添加到一些transform语句中,但似乎不起作用 注意:svg是从sketch导出的,所以它的格式可能有点奇怪如何水平翻转svg中的图像?,svg,Svg,我有下面的svg图像,我想水平翻转图像。我该怎么做?已经尝试将scale(-1,1)添加到一些transform语句中,但似乎不起作用 注意:svg是从sketch导出的,所以它的格式可能有点奇怪 <?xml version="1.0" encoding="UTF-8"?> <svg width="645px" height="470px" viewBox="0 0 645 470" version="1.1" xmlns="http://www.w3.org/2000/svg
<?xml version="1.0" encoding="UTF-8"?>
<svg width="645px" height="470px" viewBox="0 0 645 470" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M38.5969948,-2.22080132e-11 C16.8456745,30.2125678 3.07305242,70.3781435 0.923015792,123.840504 C-7.15396842,324.681101 174,465.890038 341,469.890015 C508,473.889991 658.942386,367.295224 643.971193,180.147362 C637.875363,103.946248 607.401187,44.0482171 563.7625,-2.35331754e-11 L38.5969948,-1.42108547e-14 Z" id="path-1"></path>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Bitmap">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<image mask="url(#mask-2)" x="-800" y="0" width="1867.94872" height="470" xlink:href="http://www.castleknockhotel.com/cmsGallery/imagerow/5904/resized/1600x400/cycling_passion_of_life_high_resolution_wallpaper_for_desktop_background_download_cycling_images_free.jpg">
</image>
</g>
</g>
</svg>
注意:我只想翻转图像,不想翻转遮罩。啊。。。我找到了解决办法。我需要包装图像并将遮罩添加到容器中。然后变换图像
<?xml version="1.0" encoding="UTF-8"?>
<svg width="645px" height="470px" viewBox="0 0 645 470" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M38.5969948,-2.22080132e-11 C16.8456745,30.2125678 3.07305242,70.3781435 0.923015792,123.840504 C-7.15396842,324.681101 174,465.890038 341,469.890015 C508,473.889991 658.942386,367.295224 643.971193,180.147362 C637.875363,103.946248 607.401187,44.0482171 563.7625,-2.35331754e-11 L38.5969948,-1.42108547e-14 Z" id="path-1"></path>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Bitmap">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<g mask="url(#mask-2)">
<image x="-800" y="0" width="1867.94872" height="470" xlink:href="http://www.castleknockhotel.com/cmsGallery/imagerow/5904/resized/1600x400/cycling_passion_of_life_high_resolution_wallpaper_for_desktop_background_download_cycling_images_free.jpg" transform="scale(-1 1)">
</image>
</g>
</g>
</g>
</svg>
比例使用坐标系的原点。 如果要在图像中心对其进行缩放,则必须将图像的中间部分平移到原点,然后进行缩放,然后再平移回原点: 添加属性:
transform="translate(tx,0) scale(-1,1) translate(-tx,0)"
tx=图像位置+图像宽度/2
注意:转换过程从右向左,因此它从translate(-tx,0)开始