本文整理汇总了C++中PixelRect::width方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::width方法的具体用法?C++ PixelRect::width怎么用?C++ PixelRect::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelRect
的用法示例。
在下文中一共展示了PixelRect::width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawQuad
void Canvas::drawQuad(const PixelRect& rect, const Ogre::FloatRect& texCoords, const Coloring& coloring)
{
PixelRect clipped;
Ogre::FloatRect clippedTexCoords(texCoords);
Coloring clippedColoring = coloring;
if(rect.left > clip.left)
{
clipped.left = rect.left;
}
else
{
clipped.left = clip.left;
Ogre::Real delta = (clipped.left - rect.left) / (float)rect.width();
clippedTexCoords.left += delta * texCoords.width();
if(coloring.hasGradient && coloring.orientation == Coloring::Horizontal)
clippedColoring.colors.first = (coloring.colors.first * (1 - delta)) + (coloring.colors.second * delta);
}
if(rect.top > clip.top)
{
clipped.top = rect.top;
}
else
{
clipped.top = clip.top;
Ogre::Real delta = (clipped.top - rect.top) / (float)rect.height();
clippedTexCoords.top += delta * texCoords.height();
if(coloring.hasGradient && coloring.orientation == Coloring::Vertical)
clippedColoring.colors.first = (coloring.colors.first * (1 - delta)) + (coloring.colors.second * delta);
}
if(rect.right < clip.right)
{
clipped.right = rect.right;
}
else
{
clipped.right = clip.right;
Ogre::Real delta = (clipped.right - rect.right) / (float)rect.width();
clippedTexCoords.right += delta * texCoords.width();
if(coloring.hasGradient && coloring.orientation == Coloring::Horizontal)
clippedColoring.colors.second = (coloring.colors.first * (-delta)) + (coloring.colors.second * (1 + delta));
}
if(rect.bottom < clip.bottom)
{
clipped.bottom = rect.bottom;
}
else
{
clipped.bottom = clip.bottom;
Ogre::Real delta = (clipped.bottom - rect.bottom) / (float)rect.height();
clippedTexCoords.bottom += delta * texCoords.height();
if(coloring.hasGradient && coloring.orientation == Coloring::Vertical)
clippedColoring.colors.second = (coloring.colors.first * (-delta)) + (coloring.colors.second * (1 + delta));
}
Canvas::Quad quad;
quad.vertices = Corners<Ogre::Vector2>(Ogre::Vector2(clipped.left, clipped.top), Ogre::Vector2(clipped.left, clipped.bottom),
Ogre::Vector2(clipped.right, clipped.bottom), Ogre::Vector2(clipped.right, clipped.top));
localize(quad.vertices.topLeft);
localize(quad.vertices.bottomLeft);
localize(quad.vertices.bottomRight);
localize(quad.vertices.topRight);
quad.texCoords.topLeft = Ogre::Vector2(clippedTexCoords.left, clippedTexCoords.top);
quad.texCoords.bottomLeft = Ogre::Vector2(clippedTexCoords.left, clippedTexCoords.bottom);
quad.texCoords.bottomRight = Ogre::Vector2(clippedTexCoords.right, clippedTexCoords.bottom);
quad.texCoords.topRight = Ogre::Vector2(clippedTexCoords.right, clippedTexCoords.top);
if(clippedColoring.hasGradient)
{
if(clippedColoring.orientation == Coloring::Vertical)
quad.colors = Corners<Ogre::ColourValue>(clippedColoring.colors.first, clippedColoring.colors.second, clippedColoring.colors.second, clippedColoring.colors.first);
else
quad.colors = Corners<Ogre::ColourValue>(clippedColoring.colors.first, clippedColoring.colors.first, clippedColoring.colors.second, clippedColoring.colors.second);
}
else
{
quad.colors = Corners<Ogre::ColourValue>(clippedColoring.colors.first);
}
quadList.push_back(quad);
isDirty = true;
}