static int _m_GetPixel(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Texture2D gen_to_be_invoked = (UnityEngine.Texture2D)translator.FastGetCSObj(L, 1); { int _x = LuaAPI.xlua_tointeger(L, 2); int _y = LuaAPI.xlua_tointeger(L, 3); UnityEngine.Color gen_ret = gen_to_be_invoked.GetPixel(_x, _y); translator.PushUnityEngineColor(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public Pixel[,] getPixelArray() { //We will work on the "pixels" array if (font == null) { UnityEngine.Debug.LogError("[kOS-Editor->VGA->getPixelArray()] Font is null!"); return(pixels); } //We will go through every character: for (int x = 0; x <= 76 - 1; x++) { for (int y = 0; y <= 76 - 1; y++) { Glyph c = chars[x, y]; //Indexes in the font texture: int fontIndexX = 0; int fontIndexY = 0; //Get these: fontIndexX = c.index % 76; fontIndexY = (c.index - fontIndexX) / 76; //Now we will draw every single pixel //of the character, setting color depending //on the color of the font for (int oX = 0; oX < 10; oX++) { for (int oY = 0; oY < 10; oY++) { //Sample from font: (OMG I'm dumb GetPixel returns floats T_T) if (font.GetPixel(fontIndexX + oX, fontIndexY + oY).r >= 0.3) { //White pixel: pixels[(x * 10) + oX, (y * 10) + oY] = new Pixel(chars[x, y].color); } else { //Black pixel: pixels[(x * 10) + oX, (y * 10) + oY] = new Pixel(chars[x, y].bColor); } } } } } return(pixels); }
public override Color GetPixel(int x, int y) { return((Color)unityTexture.GetPixel(x, y)); }