Exemple #1
0
static cxInt cxNumberLuaNewColor4f(lua_State *L)
{
    cxInt top = lua_gettop(L);
    cxFloat r = (top >=1 && lua_isnumber(L, 1)) ? lua_tonumber(L, 1) : 1.0f;
    cxFloat g = (top >=2 && lua_isnumber(L, 2)) ? lua_tonumber(L, 2) : 1.0f;
    cxFloat b = (top >=3 && lua_isnumber(L, 3)) ? lua_tonumber(L, 3) : 1.0f;
    cxFloat a = (top >=4 && lua_isnumber(L, 4)) ? lua_tonumber(L, 4) : 1.0f;
    cxNumber this = cxNumberColor4f(cxColor4bv(r, g, b, a));
    lua_pushlightuserdata(L, this);
    CX_LUA_RET_THIS(cxNumber);
}
Exemple #2
0
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;
}