Using inkscape graphics in Haxe

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using inkscape graphics in Haxe

Jon...
Hi again 8-)
One more quick techie question (thanks for all the help BTW on the bitmap front - I now have the basis for quite a nice flash game making setup which I'll be happy to post a tutorial about when it's done).  Whilst using haxe and a text editor to replace flash is great for programming, it does leave one rather short in the vector graphics department.  Generating art programatically is great for basic stuff but it'd be nice to be able to import layouts, shapes etc from a package like Inkscape.
 
I know Inkscape can export Illustrator files (which can be imported via flash), and I'm guessing SWFMill could probably handle putting the data into a library SWF, but I can't see how I'd actually reference the data either in the XML or the code (and actually render it) from inside Haxe, and if there would be any considerations regarding layout / properties that I'd have to be aware of.
 
Anybody got any advice (AS3 / Flash 9+ code only)
 
Thanks in advance
 
Jon...
 

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using inkscape graphics in Haxe

Daniel Daley

On Nov 18, 2008, at 10:05 AM, Jon... wrote:

> Hi again 8-)
> One more quick techie question (thanks for all the help BTW on the  
> bitmap front - I now have the basis for quite a nice flash game  
> making setup which I'll be happy to post a tutorial about when it's  
> done).  Whilst using haxe and a text editor to replace flash is  
> great for programming, it does leave one rather short in the vector  
> graphics department.  Generating art programatically is great for  
> basic stuff but it'd be nice to be able to import layouts, shapes  
> etc from a package like Inkscape.
>
> I know Inkscape can export Illustrator files (which can be imported  
> via flash), and I'm guessing SWFMill could probably handle putting  
> the data into a library SWF, but I can't see how I'd actually  
> reference the data either in the XML or the code (and actually  
> render it) from inside Haxe, and if there would be any  
> considerations regarding layout / properties that I'd have to be  
> aware of.
>
> Anybody got any advice (AS3 / Flash 9+ code only)
>

Hi Jon,

I have done a lot in this area so maybe I can help out. The latest  
version of SWFMill does import inkscape svg graphics very well. So all  
you need to do is use an swfmill template something like this with all  
your clips inside.

<?xml version="1.0" encoding="iso-8859-1" ?>
<movie width="320" height="240" framerate="12" version="9">
   <background color="#ffffff"/>
   <frame>
     <library>
       <clip id="MyGraphic" import="mygraphic.svg"/>
     </library>
   </frame>
</movie>

Then in haxe use the -swf-lib parameter to include the swfmill  
generated swf and reference them inside haxe with code such as this  
(taken from the haxe doc page).

class Test {
    static function main() {
          var s = flash.Lib.attach("MyGraphic");
          flash.Lib.current.addChild(s);
    }
}

You can read a little more about using library assets on the haxe doc  
site here http://haxe.org/doc/flash/0_start. One final note regarding  
layout would be to make sure your inkscape graphics are placed at the  
top left of the document. That way when they are rendered into the  
stage that will be their x/y point. I made the mistake of not doing  
that thinking it would strip away the white space and was very  
confused where this extra 200 pixels of padding was coming in.

Hope that helps, and if you're looking to load the swfmill files on  
demand with the as3 loader I can help out there as well.

--Daniel Daley--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using inkscape graphics in Haxe

jlm@justinfront.net
In reply to this post by Jon...
Jon

you can use flex sdk to turn inkscape into bitmaps, that was quite  
awhile ago so might be worth seeing if sdk4 can make them vectors if  
you fiddle with the mimeType.  Then load your movie into haxe at  
runtime when I get a chance I will give it ago and let you know.  I  
don't know swfmill but it is fairly cool so I imagine it is also  
worth researching properly.

Here's the flash code...

eg:
                [ Embed( source = 'circle.svg', mimeType = 'image/svg' ) ]
                protected const EmbeddedSVG: Class;


public function Main()
{
var sym: MovieClip = MovieClip( new EmbeddedSVG() );
addChild(sys);
}

you may be able to do this directly in CS4 as I know there have been  
changes that allow the Embed tags.

The circle that i tried that worked

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
    version="1.0"
    width="744.09448"
    height="1052.3622"
    id="svg2">
   <defs
      id="defs4" />
   <g
      id="layer1">
     <path
        d="M 257.14285 146.6479 A 110 97.14286 0 1 1  
37.142853,146.6479 A 110 97.14286 0 1 1  257.14285 146.6479 z"
        style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-
width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
        id="path2160" />
   </g>
</svg>

Hope that inpart helps

Cheers

;j



On 18 Nov 2008, at 17:05, Jon... wrote:

> Hi again 8-)
> One more quick techie question (thanks for all the help BTW on the  
> bitmap front - I now have the basis for quite a nice flash game  
> making setup which I'll be happy to post a tutorial about when it's  
> done).  Whilst using haxe and a text editor to replace flash is  
> great for programming, it does leave one rather short in the vector  
> graphics department.  Generating art programatically is great for  
> basic stuff but it'd be nice to be able to import layouts, shapes  
> etc from a package like Inkscape.
>
> I know Inkscape can export Illustrator files (which can be imported  
> via flash), and I'm guessing SWFMill could probably handle putting  
> the data into a library SWF, but I can't see how I'd actually  
> reference the data either in the XML or the code (and actually  
> render it) from inside Haxe, and if there would be any  
> considerations regarding layout / properties that I'd have to be  
> aware of.
>
> Anybody got any advice (AS3 / Flash 9+ code only)
>
> Thanks in advance
>
> Jon...
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using inkscape graphics in Haxe

Buggy
Hi All,

I run Inkscape on the command line (e.g.
http://zkwarl.blogspot.com/2006/08/inkscape-tip-use-inkscape-on-command.html).

If I am working on a project that needs a lot of icons I usually do
them all in inkscape and batch export them all to PNGs using
Inkscape's command line mode. I batch export to PNG because in the
past I found certain advanced Inkscape SVG features to be missing when
loaded directly into Flash (like blurring). As said above this might
not be the case if you're using swfmill.

I make sure all my icon canvases are the same size (or at least
square), so I can then generate 16*16, 32*32, 48*48 and 128*128s for
all of them by parameterising the batch export.

I happen to wrap this all up in an ant script (I can send you an
example if you like) but you could of course script this with anything
you like.

For haXe projects I usually then make a SWFMill library and include
the generated swf.

Best,
Giles



On Tue, Nov 18, 2008 at 5:45 PM, Justin Lawerance Mills
<[hidden email]> wrote:

> Jon
>
> you can use flex sdk to turn inkscape into bitmaps, that was quite awhile
> ago so might be worth seeing if sdk4 can make them vectors if you fiddle
> with the mimeType.  Then load your movie into haxe at runtime when I get a
> chance I will give it ago and let you know.  I don't know swfmill but it is
> fairly cool so I imagine it is also worth researching properly.
>
> Here's the flash code...
>
> eg:
>                [ Embed( source = 'circle.svg', mimeType = 'image/svg' ) ]
>                protected const EmbeddedSVG: Class;
>
>
> public function Main()
> {
> var sym: MovieClip              = MovieClip( new EmbeddedSVG() );
> addChild(sys);
> }
>
> you may be able to do this directly in CS4 as I know there have been changes
> that allow the Embed tags.
>
> The circle that i tried that worked
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!-- Created with Inkscape (http://www.inkscape.org/) -->
> <svg
>   xmlns:svg="http://www.w3.org/2000/svg"
>   xmlns="http://www.w3.org/2000/svg"
>   version="1.0"
>   width="744.09448"
>   height="1052.3622"
>   id="svg2">
>  <defs
>     id="defs4" />
>  <g
>     id="layer1">
>    <path
>       d="M 257.14285 146.6479 A 110 97.14286 0 1 1  37.142853,146.6479 A 110
> 97.14286 0 1 1  257.14285 146.6479 z"
>
> style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
>       id="path2160" />
>  </g>
> </svg>
>
> Hope that inpart helps
>
> Cheers
>
> ;j
>
>
>
> On 18 Nov 2008, at 17:05, Jon... wrote:
>
>> Hi again 8-)
>> One more quick techie question (thanks for all the help BTW on the bitmap
>> front - I now have the basis for quite a nice flash game making setup which
>> I'll be happy to post a tutorial about when it's done).  Whilst using haxe
>> and a text editor to replace flash is great for programming, it does leave
>> one rather short in the vector graphics department.  Generating art
>> programatically is great for basic stuff but it'd be nice to be able to
>> import layouts, shapes etc from a package like Inkscape.
>>
>> I know Inkscape can export Illustrator files (which can be imported via
>> flash), and I'm guessing SWFMill could probably handle putting the data into
>> a library SWF, but I can't see how I'd actually reference the data either in
>> the XML or the code (and actually render it) from inside Haxe, and if there
>> would be any considerations regarding layout / properties that I'd have to
>> be aware of.
>>
>> Anybody got any advice (AS3 / Flash 9+ code only)
>>
>> Thanks in advance
>>
>> Jon...
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org