@@ -72,6 +72,8 @@ class GraphicsLibrary
7272
7373 public:
7474 static int newMask ( lua_State *L );
75+ static int newHitTestOnlyMask ( lua_State *L );
76+ static int newHitTestOnlyMaskFromPaint ( lua_State *L );
7577 static int newGradient ( lua_State *L );
7678 static int newImageSheet ( lua_State *L );
7779 static int defineEffect ( lua_State *L );
@@ -114,6 +116,8 @@ GraphicsLibrary::Open( lua_State *L )
114116 const luaL_Reg kVTable [] =
115117 {
116118 { " newMask" , newMask },
119+ { " newHitTestOnlyMask" , newHitTestOnlyMask },
120+ { " newHitTestOnlyMaskFromPaint" , newHitTestOnlyMaskFromPaint },
117121// { "newVertexArray", newVertexArray },
118122 { " newGradient" , newGradient },
119123 { " newImageSheet" , newImageSheet },
@@ -203,6 +207,43 @@ GraphicsLibrary::newMask( lua_State *L )
203207 return result;
204208}
205209
210+ // graphics.newHitTestOnlyMask( filename [, baseDir] )
211+ int
212+ GraphicsLibrary::newHitTestOnlyMask ( lua_State *L )
213+ {
214+ int result = GraphicsLibrary::newMask ( L );
215+
216+ if ( result )
217+ {
218+ lua_getfield ( L, LUA_REGISTRYINDEX, BitmapMask::kHitTestOnlyTable );
219+
220+ if ( lua_istable ( L, -1 ) )
221+ {
222+ lua_pushvalue ( L, -2 );
223+ lua_pushboolean ( L, 1 );
224+ lua_rawset ( L, -3 );
225+ lua_pop ( L, 1 );
226+ }
227+
228+ else
229+ {
230+ result = 0 ;
231+ }
232+ }
233+
234+ return result;
235+ }
236+
237+ // graphics.newHitTestOnlyMaskFromPaint( [opts] )
238+ int
239+ GraphicsLibrary::newHitTestOnlyMaskFromPaint ( lua_State *L )
240+ {
241+ lua_settop ( L, 0 ); // TODO: any options?
242+ lua_pushliteral ( L, " " );
243+
244+ return newHitTestOnlyMask ( L );
245+ }
246+
206247// graphics.newVertexArray( x1, y1 [,x2, y2, ... ] )
207248/*
208249static int
@@ -921,6 +962,13 @@ LuaLibGraphics::Initialize( lua_State *L, Display& display )
921962
922963 CoronaLuaPushModule ( L, GraphicsLibrary::kName );
923964 lua_setglobal ( L, GraphicsLibrary::kName ); // graphics = library
965+
966+ lua_newtable ( L );
967+ lua_createtable ( L, 0 , 1 );
968+ lua_pushliteral ( L, " k" );
969+ lua_setfield ( L, -2 , " __mode" );
970+ lua_setmetatable ( L, -2 );
971+ lua_setfield ( L, LUA_REGISTRYINDEX, BitmapMask::kHitTestOnlyTable );
924972}
925973
926974// ----------------------------------------------------------------------------
0 commit comments