| 136 | return 1; |
| 137 | } |
| 138 | static int Meta_Mul(lua_State* L)LNOEXCEPT |
| 139 | { |
| 140 | lua_Number tFactor; |
| 141 | fcyColor *p = nullptr, *pResult = nullptr; |
| 142 | if (lua_isnumber(L, 1)) // arg1为数字,则arg2必为lstgColor |
| 143 | { |
| 144 | tFactor = luaL_checknumber(L, 1); |
| 145 | p = static_cast<fcyColor*>(luaL_checkudata(L, 2, TYPENAME_COLOR)); |
| 146 | } |
| 147 | else if (lua_isnumber(L, 2)) // arg2为数字,则arg1必为lstgColor |
| 148 | { |
| 149 | tFactor = luaL_checknumber(L, 2); |
| 150 | p = static_cast<fcyColor*>(luaL_checkudata(L, 1, TYPENAME_COLOR)); |
| 151 | } |
| 152 | else // arg1和arg2都必为lstgColor |
| 153 | { |
| 154 | fcyColor* pA = static_cast<fcyColor*>(luaL_checkudata(L, 1, TYPENAME_COLOR)); |
| 155 | fcyColor* pB = static_cast<fcyColor*>(luaL_checkudata(L, 2, TYPENAME_COLOR)); |
| 156 | pResult = CreateAndPush(L); |
| 157 | pResult->Set( |
| 158 | ::min((int)pA->a * pB->a, 255), |
| 159 | ::min((int)pA->r * pB->r, 255), |
| 160 | ::min((int)pA->g * pB->g, 255), |
| 161 | ::min((int)pA->b * pB->b, 255) |
| 162 | ); |
| 163 | return 1; |
| 164 | } |
| 165 | pResult = CreateAndPush(L); |
| 166 | pResult->Set( |
| 167 | (int)::min((double)p->a * tFactor, 255.), |
| 168 | (int)::min((double)p->r * tFactor, 255.), |
| 169 | (int)::min((double)p->g * tFactor, 255.), |
| 170 | (int)::min((double)p->b * tFactor, 255.) |
| 171 | ); |
| 172 | return 1; |
| 173 | } |
| 174 | static int Meta_ToString(lua_State* L)LNOEXCEPT |
| 175 | { |
| 176 | fcyColor* p = static_cast<fcyColor*>(luaL_checkudata(L, 1, TYPENAME_COLOR)); |
nothing calls this directly
no outgoing calls
no test coverage detected