AS3 - Export or save a sprite in SVG or other vector format

I’m working on some generating art projects in AS3, and all the time I have problems with the quality limits of bitmap images. They are not scalable or editable, like vectors. Is there a class or library that I can use to create Sprite object graphics and export them to SVG format? Other common vector formats are possible.

Sample use will also be greatly appreciated.

Edit: Please note that I am using FlashDevelop, not Adobe Flash CS. I am looking for a software solution.

+4
source share
7 answers

I am trying to export to svg myself, and I find it a little surprising that it is so difficult to find an svg exporter, as it is pretty much just xml.

I came across xgraphics , although this may be useful.

in fact, you only need the SVG class. It tries to simulate a graphic class in as3, but I found that I need to add a draw polygons class.

/** * graphics */ public function drawPolygon($points:Array):void { var $pointsString:String = ""; for each (var $pt:Point in $points) { $pointsString += (" " + $pt.x +"," + $pt.y); } var xml:XML = new XML('<polygon points="' + $pointsString + '" fill="' + uintToCSS2Color(fillColor) + '" stroke="' + uintToCSS2Color(lineColor) + '" stroke-width="' + strokeWidth + '"/>'); this.xml.appendChild(xml); } 

this allows me to create triangles and other shapes by passing an array of points

+4
source

If you use generative art using the graphic API (and / or using ready-made sprites with vector art), the easiest way to get them is to print in PDF format. This will save the vectors, and you can subsequently import something like Illustrator to make the finishing touches. I took screenshots of my games this way and it works very well. There may be some cropping problems, but they should be avoided if you are adjusting the scaling of things.

+2
source

as grapefruit suggested, PDF was my first, though too.

if you don't want to use pdf printing (this is a bit of a clumsy export method), there are also livingpdfs that might work.

another option is to use the DEGRAFA library, but I think you will need to generate graphics using the library to start with, but it will give you the ability to import and export ti in SVG format.

+1
source

Check out the AS3 SWF Shape Export - SVGhapeExporter should do it nicely ( sample code here ).

0
source

Unfortunately, once in a raster format, you cannot completely and simply convert a raster graphic object to a vector. There are some tools that try to accomplish this task, but they achieve mixed results. Flash contains the built-in function “Tracing a bitmap image” that will perform this task, with the selected image go to “Edit”> “Bitmap image”> “Trace bitmap”. You will need to play with various parameters in order to try to achieve the best result, but even then manual adjustment may be required to remove artifacts and failures.

This guide has a pretty good overview of what each option will do.

0
source

Source: https://habr.com/ru/post/1401915/


All Articles