void KeepAspectMaskSubSkin::setMask(Sandbox::Graphics& g,const TexturePtr& texture,const MyGUI::FloatRect& uv) { if (!texture) return; Sandbox::Transform2d mTr = Sandbox::Transform2d(); int x = mCroppedParent->getAbsoluteLeft(); int y = mCroppedParent->getAbsoluteTop(); int w = mCroppedParent->getWidth(); int h = mCroppedParent->getHeight(); float tw = uv.width() * texture->GetWidth(); float th = uv.height() * texture->GetHeight(); float sx = float(w) / tw; float sy = float(h) / th; float s = (sx > sy) ? sx : sy; float uvdx = (tw - float(w)/s) * 0.5f / texture->GetWidth(); float uvdy = (th - float(h)/s) * 0.5f / texture->GetHeight(); float uvsw = (1.0f/(s * texture->GetWidth() ) ); float uvsh = (1.0f/(s * texture->GetHeight() ) ); mTr.translate(uv.left+uvdx,uv.top+uvdy); mTr.scale(uvsw, uvsh); mTr.translate(-x,-y); g.SetMask(MASK_MODE_ALPHA, texture, mTr); }
void CopySubSkin::_setUVSet(const MyGUI::FloatRect &_rect) { MyGUI::FloatRect r; if (!mRenderItem) return; MyGUI::ITexture* tex = getTexture(); if (tex) { int left = mCoord.left; int top = mCoord.top; r.set(float(left)/tex->getWidth(), float(top)/tex->getHeight(), float(left+mCoord.width)/tex->getWidth(), float(top+mCoord.height)/tex->getHeight()); Base::_setUVSet(r); } }
void KeepAspectSkin::_setUVSet(const MyGUI::FloatRect& _rect) { updateRect(_rect.width(),_rect.height()); Base::_setUVSet(_rect); }