Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

Exporting designs in apps as vector (XML/svg) file?

My ultimate goal is to export designs created in mobile apps as vector graphics. Say I have a list of points of corners of shapes and the respective color that goes inside each shape and this design is being displayed on a mobile app (iOS and Android because cocos2d-x is being used). Is it possible to convert this information into a vector file (SVG file which is essentially an XML file)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

SVG contains a path element that stores the lines that make up a shape's path. The d attribute stores a path string, and the style attribute stores the path's styling, such as stroke and fill. To export a shape to SVG there are several things you should care about:

  • The size of the SVG in pixels (the width and height attributes).

Example:<svg width='640px' height='640px'

  • The size of the shape in pixels (the viewBox attribute: left, right, width, height).

Example:viewBox='0 0 100 100'

  • The color used to stroke the shape and the stroke width.

Example:style='stroke:red;stroke-width:1px' or style='stroke:none;'

  • The color used to fill each shape.

Example:style='fill:blue;' or style='fill:none;'

  • The shape of the path.

Example:d='M10 10L20 20 L30 10Z'

  • Each path is divided into commands. The M command moves the pen, the L command draws to a new position, and the Z command closes the shape.

There can be any number of paths in a single SVG file.

Example SVG file:

<svg width='640px' height='640px' viewBox='0 0 100 100' 
  xmlns='http://www.w3.org/2000/svg'>
     <path style='stroke:red;fill:none'  d='M10 10L20 20 L30 10Z'/>
</svg>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...