Skip to content

Instantly share code, notes, and snippets.

@tynril
Created May 25, 2012 12:00
Show Gist options
  • Save tynril/2787613 to your computer and use it in GitHub Desktop.
Save tynril/2787613 to your computer and use it in GitHub Desktop.
[NME Patch] Enables the neash/nme.display.Graphics.drawPath instruction
Index: nme/display/GraphicsPathCommand.hx
===================================================================
--- nme/display/GraphicsPathCommand.hx (revision 0)
+++ nme/display/GraphicsPathCommand.hx (working copy)
@@ -0,0 +1,22 @@
+package nme.display;
+#if code_completion
+
+
+@:fakeEnum(Int) extern enum GraphicsPathCommand {
+ NO_OP;
+ MOVE_TO;
+ LINE_TO;
+ CURVE_TO;
+ WIDE_MOVE_TO;
+ WIDE_LINE_TO;
+ CUBIC_CURVE_TO;
+}
+
+
+#elseif (cpp || neko)
+typedef GraphicsPathCommand = neash.display.GraphicsPathCommand;
+#elseif js
+typedef GraphicsPathCommand = jeash.display.GraphicsPathCommand;
+#else
+typedef GraphicsPathCommand = flash.display.GraphicsPathCommand;
+#end
\ No newline at end of file
Index: neash/display/GraphicsPathCommand.hx
===================================================================
--- neash/display/GraphicsPathCommand.hx (revision 0)
+++ neash/display/GraphicsPathCommand.hx (working copy)
@@ -0,0 +1,15 @@
+package neash.display;
+
+
+class GraphicsPathCommand
+{
+
+ public static inline var NO_OP = 0;
+ public static inline var MOVE_TO = 1;
+ public static inline var LINE_TO = 2;
+ public static inline var CURVE_TO = 3;
+ public static inline var WIDE_MOVE_TO = 4;
+ public static inline var WIDE_LINE_TO = 5;
+ public static inline var CUBIC_CURVE_TO = 6;
+
+}
\ No newline at end of file
Index: neash/display/Graphics.hx
===================================================================
--- neash/display/Graphics.hx (revision 1607)
+++ neash/display/Graphics.hx (working copy)
@@ -118,7 +118,12 @@
nme_gfx_draw_round_rect(nmeHandle, inX, inY, inWidth, inHeight, inRadX, inRadY == null ? inRadX : inRadY);
}
+ public function drawPath(commands:Array<Int>, data:Array<Float>, winding:String = GraphicsPathWinding.EVEN_ODD)
+ {
+ nme_gfx_draw_path(nmeHandle, commands, data, winding == GraphicsPathWinding.EVEN_ODD);
+ }
+
/**
* @private
*/
@@ -213,6 +218,7 @@
private static var nme_gfx_draw_data = Loader.load("nme_gfx_draw_data", 2);
private static var nme_gfx_draw_datum = Loader.load("nme_gfx_draw_datum", 2);
private static var nme_gfx_draw_rect = Loader.load("nme_gfx_draw_rect", 5);
+ private static var nme_gfx_draw_path = Loader.load("nme_gfx_draw_path", 4);
private static var nme_gfx_draw_tiles = Loader.load("nme_gfx_draw_tiles", 4);
private static var nme_gfx_draw_points = Loader.load("nme_gfx_draw_points", -1);
private static var nme_gfx_draw_round_rect = Loader.load("nme_gfx_draw_round_rect", -1);
Index: project/common/ExternalInterface.cpp
===================================================================
--- project/common/ExternalInterface.cpp (revision 1607)
+++ project/common/ExternalInterface.cpp (working copy)
@@ -1999,6 +1999,25 @@
}
DEFINE_PRIM(nme_gfx_draw_rect,5);
+value nme_gfx_draw_path(value inGfx, value inCommands, value inData, value inWinding)
+{
+ Graphics *gfx;
+ if (AbstractToObject(inGfx,gfx))
+ {
+ QuickVec<uint8> commands;
+ QuickVec<float> data;
+
+ FillArrayInt(commands, inCommands);
+ FillArrayDouble(data, inData);
+
+ if (!val_bool(inWinding))
+ gfx->drawPath(commands, data, wrNonZero);
+ else
+ gfx->drawPath(commands, data, wrOddEven);
+ }
+ return alloc_null();
+}
+DEFINE_PRIM(nme_gfx_draw_path, 4);
value nme_gfx_draw_round_rect(value *arg, int args)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment