Skip to content

Instantly share code, notes, and snippets.

@desttinghim
Created June 27, 2016 18:13
Show Gist options
  • Save desttinghim/94e30d59a1ec60c62f46fbd434958716 to your computer and use it in GitHub Desktop.
Save desttinghim/94e30d59a1ec60c62f46fbd434958716 to your computer and use it in GitHub Desktop.
Loading SVGs in Haxeflixel
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