当前位置: 首页>>代码示例>>C++>>正文


C++ Box::GetEdge方法代码示例

本文整理汇总了C++中Box::GetEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ Box::GetEdge方法的具体用法?C++ Box::GetEdge怎么用?C++ Box::GetEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Box的用法示例。


在下文中一共展示了Box::GetEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenerateBorder

// Generates the border geometry for a single box.
void ElementBorder::GenerateBorder(Vertex*& vertices, Index*& indices, Index& index_offset, const Box& box, const Colourb* colours)
{
	// The axis of extrusion for each of the edges.
	Vector2f box_extrusions[4] =
	{
		Vector2f(0, -1 * box.GetEdge(Box::BORDER, Box::TOP)),
		Vector2f(box.GetEdge(Box::BORDER, Box::RIGHT), 0),
		Vector2f(0, box.GetEdge(Box::BORDER, Box::BOTTOM)),
		Vector2f(-1 * box.GetEdge(Box::BORDER, Box::LEFT), 0)
	};

	// The position of each of the corners of the inner border.
	Vector2f box_corners[4];
	box_corners[0] = box.GetPosition(Box::PADDING);
	box_corners[2] = box_corners[0] + box.GetSize(Box::PADDING);
	box_corners[1] = Vector2f(box_corners[2].x, box_corners[0].y);
	box_corners[3] = Vector2f(box_corners[0].x, box_corners[2].y);

	for (int i = 0; i < 4; i++)
	{
		float border_width = box.GetEdge(Box::BORDER, (Box::Edge) i);
		if (border_width <= 0)
			continue;

		vertices[0].position = box_corners[i];
		vertices[1].position = box_corners[i] + box_extrusions[i] + box_extrusions[i == 0 ? 3 : i - 1];
		vertices[2].position = box_corners[i == 3 ? 0 : i + 1];
		vertices[3].position = vertices[2].position + box_extrusions[i] + box_extrusions[i == 3 ? 0 : i + 1];

		vertices[0].colour = colours[i];
		vertices[1].colour = colours[i];
		vertices[2].colour = colours[i];
		vertices[3].colour = colours[i];

		indices[0] = index_offset;
		indices[1] = index_offset + 3;
		indices[2] = index_offset + 1;
		indices[3] = index_offset;
		indices[4] = index_offset + 2;
		indices[5] = index_offset + 3;

		vertices += 4;
		indices += 6;
		index_offset += 4;
	}
}
开发者ID:keynslug,项目名称:librocket,代码行数:47,代码来源:ElementBorder.cpp

示例2: GetSpacing

static float GetSpacing(const Box& box, Box::Edge edge)
{
	return box.GetEdge(Box::PADDING, edge) +
		   box.GetEdge(Box::BORDER, edge) +
		   box.GetEdge(Box::MARGIN, edge);
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:6,代码来源:LayoutLineBox.cpp


注:本文中的Box::GetEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。