Icon openfl.svg

Got a problem when render the svg icon, it just render the top left corner of the inskape image:

this is a new project, the same problem…

What version of OpenFL and Lime?

Lime 3.1.0
Openfl 4.1.0

Could you try the following?

  1. Create an empty project
  2. Add <haxelib name="svg" /> to the project.xml
  3. Add your icon SVG to the assets
  4. Try this:
var svg = new format.SVG (openfl.Assets.getText ("assets/icon.svg"));
var sprite = new Sprite ();
svg.render (sprite.graphics);
addChild (sprite);

How does it look? If it looks the same (and incorrect), try targeting Flash. Does it look better?

This will help identify whether the issue is an SVG parsing issue (which will affect Flash) or an OpenFL rendering issue

it just give a black stage on flash target… nothing shows…

is the openfl.svg icon default

This works for me:

package;


import openfl.display.Sprite;
import openfl.Assets;
import format.SVG;


class Main extends Sprite {
	
	
	public function new () {
		
		super ();
		
		var sprite = new Sprite ();
		var svg = new SVG (Assets.getText ("assets/openfl.svg"));
		svg.render (sprite.graphics);
		addChild (sprite);
		
	}
	
	
}

Create an empty project using openfl create project SVGIcon

Copy the above source into the generated “Main.hx”

Save this file as “openfl.svg” under “Assets”

Let me know if it works. You can try other SVG files after you get this one running

Oh, the SVG library on haxelib was old, try updating to the new version I just submitted, as well

I make new project, with the main you send and the svg file text, with the svg lib update:

C:/HaxeToolkit/haxe/lib/svg/1,1,0/format/svg/SVGData.hx:139: characters 29-33 : On static platforms, null can’t be used as basic type Float
C:/HaxeToolkit/haxe/lib/svg/1,1,0/format/svg/SVGData.hx:143: characters 29-33 : On static platforms, null can’t be used as basic type Float
Build halted with errors.
Done(1)

well, in neko compile and give a black stage and the icon works well now in the top left of the window, but in flash give this error:

C:/HaxeToolkit/haxe/lib/svg/1,1,0/format/svg/SVGData.hx:139: characters 29-33 : On static platforms, null can’t be used as basic type Float
C:/HaxeToolkit/haxe/lib/svg/1,1,0/format/svg/SVGData.hx:143: characters 29-33 : On static platforms, null can’t be used as basic type Float
Build halted with errors.

Hmm, it worked here on Haxe 3.2.1