本文整理汇总了C++中rect::origin方法的典型用法代码示例。如果您正苦于以下问题:C++ rect::origin方法的具体用法?C++ rect::origin怎么用?C++ rect::origin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rect
的用法示例。
在下文中一共展示了rect::origin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createColorVertices
void GuiRenderer::createColorVertices(GuiVertexList& vertices, const rect& p, const vec4& color,
const mat4& transform)
{
vec2 topLeft = p.origin();
vec2 topRight = topLeft + vec2(p.width, 0.0f);
vec2 bottomLeft = topLeft + vec2(0.0f, p.height);
vec2 bottomRight = bottomLeft + vec2(p.width, 0.0f);
vec4 texCoord(0.0f, 0.0f, 0.0f, 1.0f);
buildQuad(vertices, GuiVertex(transform * topLeft, texCoord, color),
GuiVertex(transform * topRight, texCoord, color), GuiVertex(transform * bottomLeft, texCoord, color),
GuiVertex(transform * bottomRight, texCoord, color));
}
示例2: createImageVertices
void GuiRenderer::createImageVertices(GuiVertexList& vertices, const Texture& tex, const ImageDescriptor& desc,
const rect& p, const vec4& color, const mat4& transform, RenderLayer layer)
{
if (!tex.valid()) return;
if (_saveFillRate)
layer = RenderLayer_Layer0;
bool hasLeftSafe = desc.contentOffset.left > 0;
bool hasTopSafe = desc.contentOffset.top > 0;
bool hasRightSafe = desc.contentOffset.right > 0;
bool hasBottomSafe = desc.contentOffset.bottom > 0;
bool hasLeftTopCorner = hasLeftSafe && hasTopSafe;
bool hasRightTopCorner = hasRightSafe && hasTopSafe;
bool hasLeftBottomCorner = hasLeftSafe && hasBottomSafe;
bool hasRightBottomCorner = hasRightSafe && hasBottomSafe;
size_t numBorders = hasLeftSafe + hasTopSafe + hasRightSafe + hasBottomSafe;
size_t numCorners = hasLeftTopCorner + hasRightTopCorner + hasLeftBottomCorner + hasRightBottomCorner;
vertices.fitToSize(6 * (1 + numCorners + numBorders));
vec2 mask(layer == RenderLayer_Layer0 ? 0.0f : 1.0f, 0.0f);
float width = std::abs(p.width);
float height = std::abs(p.height);
vec2 topLeft = (p.origin());
vec2 topRight = (topLeft + vec2(width, 0.0f));
vec2 bottomLeft = (topLeft + vec2(0.0f, height));
vec2 bottomRight = (bottomLeft + vec2(width, 0.0f));
vec2 centerTopLeft = (p.origin() + desc.contentOffset.origin());
vec2 centerTopRight = (p.origin() + vec2(width - desc.contentOffset.right, desc.contentOffset.top));
vec2 centerBottomLeft = (p.origin() + vec2(desc.contentOffset.left, height - desc.contentOffset.bottom));
vec2 centerBottomRight = (p.origin() + vec2(width - desc.contentOffset.right, height - desc.contentOffset.bottom));
vec2 topCenterTopLeft = (topLeft + vec2(desc.contentOffset.left, 0.0f));
vec2 topCenterTopRight = (topLeft + vec2(width - desc.contentOffset.right, 0));
vec2 leftCenterTopLeft = (topLeft + vec2(0, desc.contentOffset.top));
vec2 rightCenterTopRight = (topLeft + vec2(width, desc.contentOffset.top));
vec2 leftCenterBottomLeft = (topLeft + vec2(0, height - desc.contentOffset.bottom));
vec2 bottomCenterBottomLeft = (topLeft + vec2(desc.contentOffset.left, height));
vec2 bottomCenterBottomRigth = (topLeft + vec2(width - desc.contentOffset.right, height));
vec2 rightCenterBottomRigth = (topLeft + vec2(width, height - desc.contentOffset.bottom));
vec2 topLeftUV = tex->getTexCoord( desc.origin );
vec2 topRightUV = tex->getTexCoord( desc.origin + vec2(desc.size.x, 0.0f) );
vec2 bottomLeftUV = tex->getTexCoord( desc.origin + vec2(0.0f, desc.size.y) );
vec2 bottomRightUV = tex->getTexCoord( desc.origin + desc.size );
vec2 centerTopLeftUV = tex->getTexCoord( desc.centerPartTopLeft() );
vec2 centerBottomLeftUV = tex->getTexCoord( desc.centerPartBottomLeft() );
vec2 centerTopRightUV = tex->getTexCoord( desc.centerPartTopRight() );
vec2 centerBottomRightUV = tex->getTexCoord( desc.centerPartBottomRight() );
vec2 topCenterTopLeftUV = tex->getTexCoord( desc.origin + vec2(desc.contentOffset.left, 0) );
vec2 topCenterTopRightUV = tex->getTexCoord( desc.origin + vec2(desc.size.x - desc.contentOffset.right, 0) );
vec2 leftCenterTopLeftUV = tex->getTexCoord( desc.origin + vec2(0, desc.contentOffset.top) );
vec2 rightCenterTopRightUV = tex->getTexCoord( desc.origin + vec2(desc.size.x, desc.contentOffset.top) );
vec2 leftCenterBottomLeftUV = tex->getTexCoord( desc.origin + vec2(0, desc.size.y - desc.contentOffset.bottom) );
vec2 bottomCenterBottomLeftUV = tex->getTexCoord( desc.origin + vec2(desc.contentOffset.left, desc.size.y) );
vec2 bottomCenterBottomRigthUV = tex->getTexCoord( desc.origin + vec2(desc.size.x - desc.contentOffset.right, desc.size.y) );
vec2 rightCenterBottomRigthUV = tex->getTexCoord( desc.origin + vec2( desc.size.x, desc.size.y - desc.contentOffset.bottom));
buildQuad(vertices,
GuiVertex(transform * centerTopLeft, vec4(centerTopLeftUV, mask), color ),
GuiVertex(transform * centerTopRight, vec4(centerTopRightUV, mask), color ),
GuiVertex(transform * centerBottomLeft, vec4(centerBottomLeftUV, mask), color ),
GuiVertex(transform * centerBottomRight, vec4(centerBottomRightUV, mask), color ) );
if (hasLeftTopCorner)
{
buildQuad(vertices,
GuiVertex(transform * topLeft, vec4(topLeftUV, mask), color),
GuiVertex(transform * topCenterTopLeft, vec4(topCenterTopLeftUV, mask), color),
GuiVertex(transform * leftCenterTopLeft, vec4(leftCenterTopLeftUV, mask), color),
GuiVertex(transform * centerTopLeft, vec4(centerTopLeftUV, mask), color) );
}
if (hasRightTopCorner)
{
buildQuad(vertices,
GuiVertex(transform * topCenterTopRight, vec4(topCenterTopRightUV, mask), color),
GuiVertex(transform * topRight, vec4(topRightUV, mask), color),
GuiVertex(transform * centerTopRight, vec4(centerTopRightUV, mask), color),
GuiVertex(transform * rightCenterTopRight, vec4(rightCenterTopRightUV, mask), color) );
}
if (hasLeftBottomCorner)
{
buildQuad(vertices,
GuiVertex(transform * leftCenterBottomLeft, vec4(leftCenterBottomLeftUV, mask), color),
GuiVertex(transform * centerBottomLeft, vec4(centerBottomLeftUV, mask), color),
GuiVertex(transform * bottomLeft, vec4(bottomLeftUV, mask), color),
GuiVertex(transform * bottomCenterBottomLeft, vec4(bottomCenterBottomLeftUV, mask), color) );
}
if (hasRightBottomCorner)
{
buildQuad(vertices,
GuiVertex(transform * centerBottomRight, vec4(centerBottomRightUV, mask), color),
GuiVertex(transform * rightCenterBottomRigth, vec4(rightCenterBottomRigthUV, mask), color),
GuiVertex(transform * bottomCenterBottomRigth, vec4(bottomCenterBottomRigthUV, mask), color),
//.........这里部分代码省略.........