Skip to content

Commit

Permalink
Merge pull request #58 from askmeaboutlo0m/master
Browse files Browse the repository at this point in the history
Use `openfl` instead of `flash` packages
  • Loading branch information
jgranick authored Mar 3, 2017
2 parents 6e266fe + c9f2f53 commit c79edc2
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 105 deletions.
6 changes: 3 additions & 3 deletions format/SVG.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package format;


import flash.display.Graphics;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import openfl.display.Graphics;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;
import format.svg.SVGData;
import format.svg.SVGRenderer;

Expand Down
14 changes: 7 additions & 7 deletions format/gfx/Gfx.hx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package format.gfx;

import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;
import format.svg.Text;

import flash.geom.Matrix;
import openfl.geom.Matrix;

class Gfx
{
Expand Down
14 changes: 7 additions & 7 deletions format/gfx/Gfx2Haxe.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package format.gfx;

import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.geom.Matrix;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;
import openfl.geom.Matrix;


class Gfx2Haxe extends Gfx
Expand Down
18 changes: 9 additions & 9 deletions format/gfx/GfxBytes.hx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package format.gfx;

import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.geom.Matrix;

import flash.utils.ByteArray;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;
import openfl.geom.Matrix;

import openfl.utils.ByteArray;

import haxe.io.Bytes;

Expand Down
4 changes: 2 additions & 2 deletions format/gfx/GfxExtent.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package format.gfx;

import flash.geom.Matrix;
import flash.geom.Rectangle;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;

class GfxExtent extends Gfx
{
Expand Down
18 changes: 9 additions & 9 deletions format/gfx/GfxGraphics.hx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package format.gfx;

import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.display.Graphics;

import flash.geom.Matrix;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;
import openfl.display.Graphics;

import openfl.geom.Matrix;

class GfxGraphics extends Gfx
{
Expand Down
14 changes: 7 additions & 7 deletions format/gfx/Gradient.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package format.gfx;

import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.geom.Matrix;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;

class Gradient
{
Expand Down
6 changes: 3 additions & 3 deletions format/gfx/LineStyle.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package format.gfx;

import flash.display.LineScaleMode;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import openfl.display.LineScaleMode;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;

class LineStyle
{
Expand Down
12 changes: 6 additions & 6 deletions format/svg/BitmapDataManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package format.svg;
//import gm2d.reso.Resources;
import format.svg.SVGRenderer;

import flash.geom.Matrix;
import flash.display.Shape;
import flash.display.Bitmap;
import flash.display.BitmapData;
import openfl.geom.Matrix;
import openfl.display.Shape;
import openfl.display.Bitmap;
import openfl.display.BitmapData;


class BitmapDataManager
Expand Down Expand Up @@ -37,9 +37,9 @@ class BitmapDataManager
var h = Std.int(svg.height*inScale + 0.99);
var bmp = new BitmapData(w,h,true,0x00);
var q = gm2d.Lib.current.stage.quality;
flash.Lib.current.stage.quality = flash.display.StageQuality.BEST;
openfl.Lib.current.stage.quality = flash.display.StageQuality.BEST;
bmp.draw(shape,matrix);
flash.Lib.current.stage.quality = q;
openfl.Lib.current.stage.quality = q;

if (inCache)
bitmaps.set(key,bmp);
Expand Down
16 changes: 8 additions & 8 deletions format/svg/Grad.hx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package format.svg;

import flash.geom.Matrix;
import flash.geom.Rectangle;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;

import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;

class Grad extends /*gm2d.gfx.Gradient*/format.gfx.Gradient
{
Expand Down
14 changes: 7 additions & 7 deletions format/svg/Gradient.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package format.svg;

import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.geom.Matrix;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;

class Gradient
{
Expand Down
14 changes: 7 additions & 7 deletions format/svg/Path.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package format.svg;

import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.geom.Matrix;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;

typedef PathSegments = Array<PathSegment>;

Expand Down
8 changes: 4 additions & 4 deletions format/svg/PathSegment.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package format.svg;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.display.Graphics;
import openfl.geom.Rectangle;
import openfl.geom.Matrix;
import openfl.geom.Point;
import openfl.display.Graphics;
import format.gfx.Gfx;

class PathSegment
Expand Down
4 changes: 2 additions & 2 deletions format/svg/RenderContext.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package format.svg;

import flash.geom.Matrix;
import flash.geom.Rectangle;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;

class RenderContext
{
Expand Down
14 changes: 7 additions & 7 deletions format/svg/SVGData.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package format.svg;

import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.SpreadMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;
import openfl.display.GradientType;
import openfl.display.Graphics;
import openfl.display.SpreadMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import format.svg.Grad;
import format.svg.Group;
import format.svg.FillType;
Expand Down
32 changes: 16 additions & 16 deletions format/svg/SVGRenderer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ package format.svg;
import format.svg.PathParser;
import format.svg.PathSegment;

import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.display.Graphics;

import flash.display.Shape;
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;
import openfl.display.Graphics;

import openfl.display.Shape;
import openfl.display.Sprite;
import openfl.display.DisplayObject;
import openfl.display.GradientType;
import openfl.display.SpreadMethod;
import openfl.display.InterpolationMethod;
import openfl.display.CapsStyle;
import openfl.display.JointStyle;
import openfl.display.LineScaleMode;

import format.svg.Grad;
import format.svg.Group;
import format.svg.FillType;
import format.gfx.Gfx;
import flash.geom.Rectangle;
import openfl.geom.Rectangle;


typedef GroupPath = Array<String>;
Expand Down Expand Up @@ -318,9 +318,9 @@ class SVGRenderer
var w = Std.int(Math.ceil( inRect==null ? width : inRect.width*inScale ));
var h = Std.int(Math.ceil( inRect==null ? width : inRect.height*inScale ));

var bmp = new flash.display.BitmapData(w,h,true,#if (neko && !haxe3) { a: 0x00, rgb: 0x000000 } #else 0x00000000 #end);
var bmp = new openfl.display.BitmapData(w,h,true,#if (neko && !haxe3) { a: 0x00, rgb: 0x000000 } #else 0x00000000 #end);

var shape = new flash.display.Shape();
var shape = new openfl.display.Shape();
mGfx = new format.gfx.GfxGraphics(shape.graphics);

mGroupPath = [];
Expand Down
2 changes: 1 addition & 1 deletion format/svg/Text.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package format.svg;

import flash.geom.Matrix;
import openfl.geom.Matrix;


class Text
Expand Down
24 changes: 24 additions & 0 deletions test/MacroTest.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package;

import massive.munit.Assert;

import format.SVG;

/**
* Tests that using SVGs inside macros actually compiles. If the `flash` package
* is used instead of the `openfl` package.
*/
class MacroTest
{
macro static function makeSvg()
{
// This macro will fail if the `flash` package is used.
return macro new SVG("<svg></svg>");
}

@Test
public function compilesInMacro()
{
Assert.isNotNull(makeSvg());
}
}
2 changes: 2 additions & 0 deletions test/TestSuite.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import massive.munit.TestSuite;

import SvgGenerationTest;
import MacroTest;

/**
* Auto generated Test Suite for MassiveUnit.
Expand All @@ -15,5 +16,6 @@ class TestSuite extends massive.munit.TestSuite
super();

add(SvgGenerationTest);
add(MacroTest);
}
}

0 comments on commit c79edc2

Please sign in to comment.