| Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/11/12 2:26 PM | Hi All, Mr. Nibbles (mr-nibbles.com) just came out. It was made in Haxe, and Mike used Flash to generate the (vector) art, but also somehow rasterized it, since NME draws vector stuff slowly (no GPU help).
Does anyone know how to do this? Right now, I'm trying to have three sizes of all graphics assets to fit different resolutions. Vector seems more ideal, and I do have access to Flash. But how would I go about turning my Flash vector art into something raster that NME can crunch? Has anyone else done this before? I bugged Mike for more information, so hopefully he'll reveal it when he's less busy.
--Ashiq |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Tarwin Stroh-Spijer | 9/11/12 2:29 PM | I'm guessing he's storing the vector, and drawing everything to bitmaps before the game is started? Can take a second to do, but you get a lot smaller download (as well is making it easier to target different resolution displays). Tarwin Stroh-Spijer _______________________ Touch My Pixel http://www.touchmypixel.com/ cell: +1 650 842 0920 _______________________
|
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/11/12 3:15 PM | @Tarwin how do you draw to bitmaps? And how do you deal with the issue of vectors not having a size? Can you explain, maybe with references to some of the APIs?
I can understand having a large image and drawing a scaled-down version.
--Ashiq |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Raoul Duke | 9/11/12 3:21 PM | maybe somethng like:
each spite has a .graphics, you draw into that. then you could put those into a tilesheet somehow ideally performance-wise. * assume a standard sprite size e.g. 16x16 * make a giant sprite that is (16*16)*(# of sprites) - however you want them laid out, long strip, or 2d grid. * loop through all the vector images and render them into little rectangular sub-regions (i*16, j*16+(i*16)) or whatever the right math is :-) * grab the grapics as bitmap data. * upload the large bitmap into the drawtiles 'storage'. * use drawtiles functions to draw individual sprites out of the whole big thing. |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Joshua Granick | 9/11/12 3:25 PM | Use bitmapData.draw to flatten display objects into a bitmap You should be able to scale the objects first, then draw to a bitmap |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Tarwin Stroh-Spijer | 9/11/12 3:33 PM | If you want animated sprites these might help you:
http://code.google.com/p/touchmypixel/source/browse/#svn%2Ftrunk%2Fhaxe%2Fsrc%2Ftouchmypixel%2Fbitmap They use swapping of bitmaps rather than tilesheets though so may be a little slower ?
|
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Joshua Granick | 9/11/12 3:44 PM | That's the method I use in the "spritesheet" library Depending on what you create, its the fastest rendering method for Flash. It gets good performance on native, similar to the normal display list, but not quite as fast as using a batch rendering method. The primary downside with using separate objects is it requires more memory. This isn't a problem on most platforms, but Apple gives a significantly smaller amount of allowed memory on their mobile devices, so it can become an issue if you need a lot of animations |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Bruno Garcia | 9/11/12 5:00 PM | On 09/11/2012 02:26 PM, Ashiq A. wrote:You might be interested in Flump, which converts FLAs into texture atlases (not sprite sheets): https://github.com/threerings/flump We're using it for a few different games at Three Rings. Here are a couple Haxe demos that use it: https://github.com/aduros/flambe-demos/tree/master/monster https://github.com/aduros/flambe-demos/tree/master/horses There's no NME lib for it, but it should be pretty easy to port the one from Flambe or Starling. Bruno |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/12/12 2:04 PM | @Joshua where are the docs for it? I can't find anything on it on Google. I assume I still need some other mechanism to load the SWF -- or whatever vector format -- into NME/Haxe in the first place.
--Ashiq |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/12/12 7:58 PM | I figured out the SWF stuff (using the SWF library). I just need to rasterize to a bitmap somehow. |
| unk...@googlegroups.com | 9/13/12 4:49 AM | <This message has been deleted.> | |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | JLM | 9/13/12 5:15 AM | Cheers Justin |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/13/12 5:27 AM | Hi Justin, Your init function has an instance of SWF from swf.creteMovieClip (in mc), and your copy method takes a parameter that's a Sprite instance. Is this an implicit typecast? Does this actually work?
I have similar code, I'm just trying to figure out how to make it work. I have type issues right now (SWF is not IBitmapDrawable, nor is the bitmap data for some reason).
--Ashiq |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Tom | 9/13/12 7:16 AM | Hi! I just tried the similar things - maybe with some more complicated swf. :) - for windows, and flash target. I found one problem in nme 3.4.3 (windows target): nme.net.URLLoader with Event.COMPLETE event crash on windows 7, 64 bit. (Progress event does not work.) Workaround: in ENTER_FRAME event check the URRLoader.data.length, and if it not change, then it is loaded. The solution what I used to convert one mc from the loaded SWF into bitmap: (i did not use any extra function, 'coz this was a fast code, sorry) |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Tom | 9/13/12 9:01 AM | One more thing. Can be improved the closed path rendering? Because any path with hole is fully filled. |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | JLM | 9/13/12 9:22 AM | But the kitty does not seem to render properly in windows. |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | JLM | 9/13/12 9:36 AM | Ashiq and NME community. The code I posted will work, just it seems the swf parser is not working as well as I hoped, I tried balloon test and the fills were separated by a one pixel gap and in this kitty example half the lines are not rendered properly? Can someone take a look in windows target, the kitty does not seem to render correctly, most of the lines do not seem to render only the fills? I will upgrade my copy of NME if the kitty renders fine in latest but suspect it won't and I prefer not to risk changing if still broken. |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/13/12 11:29 AM | @JLM The lines seem to be rendering ultra-thin. Here's what it looks like rasterized at 2.25x magnification: Flash looks okay. My lines showed up okay, but I used a line width of three, not 1; maybe that has something to do with it? I did see very slight artifacts, but it's nothing unforgivable.
--Ashiq -- |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/17/12 9:16 AM | Hi Justin, What do you need to use CopyPixels for? I use a matrix which I scale/rotate (code I got from Mike Cann -- thanks Mike!), and only call draw, passing in the matrix as the second parameter.
Are there any real differences here, other than syntax? Performance maybe? I'm not familiar enough with the drawing API to know. --Ashiq
|
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Emiliano Angelini | 9/17/12 7:46 PM | Hi guys, You may find some inspiration in this Starling extension I made quite a while. It's AS3 and Starling Texture Atlasses, but should be easy enough to be ported to Haxe / Spritesheet or TileLayer Cheers, Emi |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Michael Cann | 9/18/12 12:14 AM | You're welcome Ashiq ;) Yes Emiliano that sort of thing is what I would have gone for with a little more time, plus the SWF rasteriser is rather slow at the moment so it could take quite a long time to generate entire sprite sheets dynamically. It was good enough for the occasional menu screen, to generate lots of animation frames however, it probably would have taken a long time.
Mike
|
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/18/12 7:23 AM | Wait, what? Slow? I'm planning to use it to generate a bunch of images, but I don't think atlasing will work, because I need to rasterize based on the actual screen size of the hardware at runtime -- I can't detect this at compile-time. --Ashiq |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Emiliano Angelini | 9/18/12 7:27 AM | The code I shared creates a TextureAtlas at runtime. Of course it takes some time depending on the ammount and size of the swf assets. |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Michael Cann | 9/18/12 7:36 AM | Yes, unfortunately in my testing, the SWF rasterisation was rather slow, hence why I had to generate and cache my menu screens before the game loads. You may want to run a few tests first before you go full-ball at it. Failing that you can just do what I did and generate the sprite sheets pre-runtime via a tool like TexturePacker or perhaps by some clever macro usage ;)
Mike |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Tony Polinelli | 9/18/12 9:27 PM | im using spriteloq - a la : http://www.joshuagranick.com/blog/2011/08/27/export-swf-animation-to-nme-using-sprite-sheets/ works well |
| Re: [haxe] Rasterizing/Drawing Vector in Haxe/NME | Ashiq A. | 9/19/12 4:01 AM | @Tony SpriteLoq rasterizes or retains the symbols as vectors? On Wed, Sep 19, 2012 at 12:27 AM, Tony Polinelli <to...@touchmypixel.com> wrote: im using spriteloq - a la : http://www.joshuagranick.com/blog/2011/08/27/export-swf-animation-to-nme-using-sprite-sheets/ |