static cxInt cxNumberLuaNewFloat(lua_State *L) { cxFloat value = luaL_checknumber(L, 1); cxNumber this = cxNumberFloat(value); lua_pushlightuserdata(L, this); CX_LUA_RET_THIS(cxNumber); }
static cxInt cxRelativeH(lua_State *L) { cxEngine engine = cxEngineInstance(); cxFloat v = luaL_checknumber(L, 2); cxNumber num = cxNumberFloat(v * engine->winsize.h); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxViewMulripleW(lua_State *L) { CX_LUA_DEF_THIS(cxReaderAttrInfo *); cxConstChars v = NULL; cxFloat n = 0; if(!lua_istable(L, 2)){ luaL_error(L, "args error"); return 0; } lua_getfield(L, 2, "v"); v = luaL_checkstring(L, -1); lua_pop(L, 1); lua_getfield(L, 2, "n"); n = luaL_checknumber(L, -1); lua_pop(L, 1); cxView view = cxViewRootGet(this->root, v); CX_ASSERT(view != NULL, "view is null"); cxNumber num = cxNumberFloat(view->size.w * n); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxAny cxReadValues(cxHashRoot root,cxConstChars temp,xmlTextReaderPtr reader) { cxNumberValue vm={0}; cxInt b4[4] = {255,255,255,255}; cxString text = cxXMLReadString(reader); CX_RETURN(text == NULL, NULL); cxConstChars value = cxStringBody(text); cxAny rv = NULL; if(ELEMENT_IS_TYPE(cxPoint) && cxReadFloats(value, &vm.vp.vertices.x) == 9){ rv = cxNumberPoint(vm.vp); }else if(ELEMENT_IS_TYPE(cxBool)){ rv = cxNumberBool(cxConstCharsEqu(value, "true")); }else if(ELEMENT_IS_TYPE(cxInt)){ rv = cxNumberInt(atoi(value)); }else if(ELEMENT_IS_TYPE(cxFloat)){ rv = cxNumberFloat(atof(value)); }else if (ELEMENT_IS_TYPE(cxDouble)){ rv = cxNumberDouble(atof(value)); }else if (ELEMENT_IS_TYPE(cxVec2f) && cxReadFloats(value, &vm.vec2f.x) == 2){ rv = cxNumberVec2f(vm.vec2f); }else if (ELEMENT_IS_TYPE(cxSize2f) && cxReadFloats(value, &vm.size2f.w) == 2){ rv = cxNumberSize2f(vm.size2f); }else if(ELEMENT_IS_TYPE(cxColor4f) && cxReadFloats(value, &vm.color4f.r) >= 3){ rv = cxNumberColor4f(vm.color4f); }else if(ELEMENT_IS_TYPE(cxVec2i) && cxReadInts(value, &vm.vec2i.x) == 2){ rv = cxNumberVec2i(vm.vec2i); }else if(ELEMENT_IS_TYPE(cxColor4b) && cxReadInts(value, b4) >= 3){ vm.color4f.r = ((cxFloat)b4[0])/255.0f; vm.color4f.g = ((cxFloat)b4[1])/255.0f; vm.color4f.b = ((cxFloat)b4[2])/255.0f; vm.color4f.a = ((cxFloat)b4[3])/255.0f; rv = cxNumberColor4f(vm.color4f); }else if(ELEMENT_IS_TYPE(cxHash)){ rv = cxHashRootReadHash(root,reader); } return rv; }
void cxTimeLineSet(cxAny pav,cxFloat time) { cxTimeLine this = pav; cxArrayAppend(this->times, cxNumberFloat(time)); }