Created
June 27, 2016 18:13
-
-
Save desttinghim/94e30d59a1ec60c62f46fbd434958716 to your computer and use it in GitHub Desktop.
Loading SVGs in Haxeflixel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import format.SVG; | |
import openfl.Assets; | |
import openfl.display.BitmapData; | |
import openfl.display.Shape; | |
class LoadSVG { | |
var svg:SVG; | |
public function new( loadpath:String ) { | |
svg = new SVG(Assets.getText(loadpath)); | |
} | |
public function bitmap( width, height ) { | |
var shape = new Shape(); | |
svg.render(shape.graphics, 0, 0, width, height); | |
var bmp = new BitmapData( width, height, true, 0xFFFFFF ); | |
bmp.draw(shape); | |
return bmp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment