SVG support in NATFlixel. Close #165
This commit is contained in:
@@ -73,5 +73,5 @@
|
|||||||
(method fullString [:Entry e]
|
(method fullString [:Entry e]
|
||||||
(haxe.Json.stringify e null "\t"))
|
(haxe.Json.stringify e null "\t"))
|
||||||
|
|
||||||
(method filePath [file]
|
(method :String filePath [file]
|
||||||
(joinPath archiveDir "files" file))
|
(joinPath archiveDir "files" file))
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
(defNew []
|
(defNew []
|
||||||
(super
|
(super
|
||||||
["jpg" "jpeg" "png"]
|
["jpg" "jpeg" "png" "svg"]
|
||||||
->[archive e imageFiles &opt ui]
|
->[archive e imageFiles &opt ui]
|
||||||
(unless (upgradeToVersion2 archive e)
|
(unless (upgradeToVersion2 archive e)
|
||||||
// TODO an edge case exists when more image files are added to an Entry
|
// TODO an edge case exists when more image files are added to an Entry
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<!-- _______________________________ Libraries ______________________________ -->
|
<!-- _______________________________ Libraries ______________________________ -->
|
||||||
|
|
||||||
<haxelib name="flixel" />
|
<haxelib name="flixel" />
|
||||||
|
<haxelib name="svg" />
|
||||||
|
|
||||||
<haxelib name="kiss" />
|
<haxelib name="kiss" />
|
||||||
<haxelib name="kiss-tools" />
|
<haxelib name="kiss-tools" />
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package;
|
|||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import kiss.List;
|
import kiss.List;
|
||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
|
import openfl.display.Sprite;
|
||||||
|
import format.SVG;
|
||||||
import kiss_flixel.KissExtendedSprite;
|
import kiss_flixel.KissExtendedSprite;
|
||||||
import flixel.text.FlxText;
|
import flixel.text.FlxText;
|
||||||
import flixel.util.FlxSpriteUtil;
|
import flixel.util.FlxSpriteUtil;
|
||||||
@@ -13,7 +15,9 @@ import nat.BoolExpInterp;
|
|||||||
import nat.components.Images;
|
import nat.components.Images;
|
||||||
import nat.components.Position;
|
import nat.components.Position;
|
||||||
import nat.components.Scale;
|
import nat.components.Scale;
|
||||||
|
import sys.io.File;
|
||||||
using kiss_flixel.CameraTools;
|
using kiss_flixel.CameraTools;
|
||||||
|
using haxe.io.Path;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class EntrySprite extends KissExtendedSprite {}
|
class EntrySprite extends KissExtendedSprite {}
|
||||||
|
|||||||
@@ -16,11 +16,17 @@
|
|||||||
|
|
||||||
(cond
|
(cond
|
||||||
((hasComponent e Images2)
|
((hasComponent e Images2)
|
||||||
(let [images (readComponent e Images2)]
|
(let [images (readComponent e Images2)
|
||||||
(.onComplete (BitmapData.loadFromFile (archive.filePath (nth images.imageFiles images.pinnedImageIndex)))
|
pinnedImage (archive.filePath (nth images.imageFiles images.pinnedImageIndex))]
|
||||||
->bitmapData {
|
(case (pinnedImage.extension)
|
||||||
(loadGraphic bitmapData)
|
("svg" (let [sprite (new Sprite)]
|
||||||
})))
|
(.render (new SVG (File.getContent pinnedImage)) sprite.graphics)
|
||||||
|
(let [bitmapData (new BitmapData (Std.int sprite.width) (Std.int sprite.height))]
|
||||||
|
(bitmapData.draw sprite)
|
||||||
|
(loadGraphic bitmapData))))
|
||||||
|
(otherwise
|
||||||
|
(.onComplete (BitmapData.loadFromFile pinnedImage)
|
||||||
|
->bitmapData (loadGraphic bitmapData))))))
|
||||||
((hasComponent e Circle)
|
((hasComponent e Circle)
|
||||||
(set isCircle true)
|
(set isCircle true)
|
||||||
(let [c (readComponent e Circle)
|
(let [c (readComponent e Circle)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ then
|
|||||||
haxelib install flixel-addons --quiet
|
haxelib install flixel-addons --quiet
|
||||||
haxelib install flixel-ui --quiet
|
haxelib install flixel-ui --quiet
|
||||||
haxelib install hxcpp --quiet
|
haxelib install hxcpp --quiet
|
||||||
|
haxelib install svg --quiet
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if "desktop-" is in the project name, only test for C++
|
# if "desktop-" is in the project name, only test for C++
|
||||||
|
|||||||
Reference in New Issue
Block a user