将坐标设置为SVG图像的中心
通常,坐标(0,0)位于图像的左上角,但我希望它位于图像的中心,图像为128像素128像素,因此应在64像素到64像素。我不知道该怎么做,你们能帮我吗?
下面的代码是用Aseprite创建的,我将其导出为SVG文件。另外,这不是完整的代码,矩形X和Y值为128像素。
<?xml version="1.0" encoding="UTF-8" ?>
<svg version="1.1" width="128" height="128" xmlns="http://www.w3.org/2000/svg" shape-rendering="crispEdges">
<rect x="0" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="1" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="2" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="3" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="4" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="5" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="6" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="7" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="8" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="9" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="10" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="11" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="12" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="13" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="14" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="15" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="16" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="17" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="18" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="19" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="20" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="21" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="22" y="0" width="1" height="1" fill="#C2F8FF" />
<rect x="23" y="0" width="1" height="1" fill="#C2F8FF" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就像评论建议您可以使用 0,0 ViewBox“ rel =” nofollow noreferrer”> ViewBox 。前两个数字是左上角的坐标,最后一个数字是宽度和高度。他们正在说明如何设置内部坐标系 - 不是在“实际”宽度和高度上表达(在第一个示例中,即使视图框的宽度为128,宽度也是300) - 这些可以用宽度和宽度和高度属性。
另一种选择是使用a
/code>
用于移动所有子元素的
0,0
的元素:Like the comments suggest you can "move around"
0,0
by using the viewBox. The first two numbers are the coordinate for the top left corner and that last to numbers are the width and the height. They are stating how the inner coordinate system is set up – not an expressing on the "actual" width and height (in this first example the width is 300 even though the viewBox is 128 in width) – these can be set with the width and height attributes.An alternative is to use a
<g>
element for moving the0,0
for all the child elements: