コード例 #1
0
    private UISpriteData ClipAtlasSprite(UISpriteData originSprite)
    {
        if (isLoadHeroHead)
        {
            return(null);
        }

        if (originSprite == null)
        {
            return(null);
        }

        if (mClipType != eClipType.None && type == Type.Simple)
        {
            UISpriteData clip_sprite = mSwapSprite;
            clip_sprite.CopyFrom(originSprite);
            clip_sprite.SetBorder(0, 0, 0, 0);
            clip_sprite.SetPadding(0, 0, 0, 0);
            if (mClipType == eClipType.Horizontally)
            {
                int keep_aspect_width = Mathf.RoundToInt((float)width / height * clip_sprite.height);
                int w = clip_sprite.width - keep_aspect_width;
                if (w < 0)
                {
                    clip_sprite.SetRect(clip_sprite.x, clip_sprite.y, clip_sprite.width, clip_sprite.height);
                    int padding = -w / 2;
                    clip_sprite.SetPadding(padding, 0, padding, 0);
                }
                else
                {
                    clip_sprite.SetRect(clip_sprite.x + w / 2, clip_sprite.y, keep_aspect_width, clip_sprite.height);
                }
            }
            else if (mClipType == eClipType.Vertically)
            {
                int keep_aspect_height = Mathf.RoundToInt((float)height / width * clip_sprite.width);
                int h = clip_sprite.height - keep_aspect_height;
                if (h < 0)
                {
                    clip_sprite.SetRect(clip_sprite.x, clip_sprite.y, clip_sprite.width, clip_sprite.height);
                    int padding = -h / 2;
                    clip_sprite.SetPadding(padding, 0, padding, 0);
                }
                else
                {
                    clip_sprite.SetRect(clip_sprite.x, clip_sprite.y + h / 2, clip_sprite.width, keep_aspect_height);
                }
            }

            return(clip_sprite);
        }
        else
        {
            UISpriteData clip_sprite = mSwapSprite;
            clip_sprite.CopyFrom(originSprite);
            return(clip_sprite);
        }
    }
コード例 #2
0
    public static int SetPadding(IntPtr l)
    {
        int result;

        try
        {
            UISpriteData uISpriteData = (UISpriteData)LuaObject.checkSelf(l);
            int          left;
            LuaObject.checkType(l, 2, out left);
            int bottom;
            LuaObject.checkType(l, 3, out bottom);
            int right;
            LuaObject.checkType(l, 4, out right);
            int top;
            LuaObject.checkType(l, 5, out top);
            uISpriteData.SetPadding(left, bottom, right, top);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
コード例 #3
0
 static int SetPadding(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         UISpriteData obj  = (UISpriteData)ToLua.CheckObject(L, 1, typeof(UISpriteData));
         int          arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         int          arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         int          arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
         int          arg3 = (int)LuaDLL.luaL_checknumber(L, 5);
         obj.SetPadding(arg0, arg1, arg2, arg3);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #4
0
 static public int SetPadding(IntPtr l)
 {
     try {
         UISpriteData self = (UISpriteData)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         System.Int32 a4;
         checkType(l, 5, out a4);
         self.SetPadding(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }