本文整理汇总了C++中CAImage类的典型用法代码示例。如果您正苦于以下问题:C++ CAImage类的具体用法?C++ CAImage怎么用?C++ CAImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAImage类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setImageCoords
void CAView::setImageCoords(DRect rect)
{
CAImage* image = m_pobBatchView ? m_pobImageAtlas->getImage() : m_pobImage;
CC_RETURN_IF(! image);
float atlasWidth = (float)image->getPixelsWide();
float atlasHeight = (float)image->getPixelsHigh();
float left, right, top, bottom;
if (m_bRectRotated)
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2 * rect.origin.x + 1) / (2 * atlasWidth);
right = left + (rect.size.height * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.origin.y + 1) / (2 * atlasHeight);
bottom = top + (rect.size.width * 2 - 2) / (2 * atlasHeight);
#else
left = rect.origin.x / atlasWidth;
right = (rect.origin.x + rect.size.height) / atlasWidth;
top = rect.origin.y / atlasHeight;
bottom = (rect.origin.y + rect.size.width) / atlasHeight;
#endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if (m_bFlipX)
{
CC_SWAP(top, bottom, float);
}
if (m_bFlipY)
{
CC_SWAP(left, right, float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = top;
m_sQuad.br.texCoords.u = left;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = right;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = bottom;
}
else
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2 * rect.origin.x + 1) / (2 * atlasWidth);
right = left + (rect.size.width * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.origin.y + 1) / (2 * atlasHeight);
bottom = top + (rect.size.height * 2 - 2) / (2 * atlasHeight);
#else
left = rect.origin.x / atlasWidth;
right = (rect.origin.x + rect.size.width) / atlasWidth;
top = rect.origin.y / atlasHeight;
bottom = (rect.origin.y + rect.size.height) / atlasHeight;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if(m_bFlipX)
{
CC_SWAP(left, right, float);
}
if(m_bFlipY)
{
CC_SWAP(top, bottom, float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = bottom;
m_sQuad.br.texCoords.u = right;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = left;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = top;
}
}
示例2: CAImage
bool CABatchView::init()
{
CAImage * texture = new CAImage();
texture->autorelease();
return this->initWithImage(texture, 0);
}
示例3: password
void CATextField::updateImage()
{
std::string text = "";
if (m_sText.empty())
{
text = m_sPlaceHolder;
this->setColor(m_cSpaceHolderColor);
}
else
{
text = m_sText;
this->setColor(m_cTextColor);
}
std::string password("");
if (m_nInputType == KEY_BOARD_INPUT_PASSWORD)
{
for (std::string::size_type i = 0; i<m_sText.length(); i++)
{
password.append("*");
}
if (m_sText.empty())
{
text = m_sPlaceHolder;
}
else
{
text = password;
}
}
float dt = 1.0f;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
dt = 1.1f;
#endif
CCSize size = CCSizeMake(0, m_iFontHeight*dt);
CAImage* image = CAImage::createWithString(text.c_str(),
m_nfontName.c_str(),
m_iFontSize,
size,
CATextAlignmentLeft,
CAVerticalTextAlignmentCenter,
true);
CCRect rect = CCRectZero;
if (m_sPlaceHolder.length() == 0)
{
this->setImage(image);
this->setImageRect(rect);
}
CC_RETURN_IF(image == NULL);
rect.size.height = image->getContentSize().height;
rect.size.width = MIN(m_iLabelWidth, image->getContentSize().width);
if (text.empty())
{
m_cImageSize = CCSizeZero;
}
else
{
m_cImageSize = image->getContentSize();
}
this->setImage(image);
rect.origin.x = -m_iString_o_length;
this->setImageRect(rect);
}