本文整理汇总了C++中Rect2::topLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect2::topLeft方法的具体用法?C++ Rect2::topLeft怎么用?C++ Rect2::topLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect2
的用法示例。
在下文中一共展示了Rect2::topLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Line2::intersect(const Rect2& r) const
{
if (intersect(Segment2(r.bottomLeft(), r.topLeft())))
return true;
if (intersect(Segment2(r.topLeft(), r.topRight())))
return true;
if (intersect(Segment2(r.bottomLeft(), r.bottomRight())))
return true;
if (intersect(Segment2(r.bottomRight(), r.topRight())))
return true;
return false;
}
示例2: intersect
bool intersect(const Rect2& rect, ConstPointIterator2 begin, ConstPointIterator2 end)
{
Segment2 bottom(rect.bottomLeft(), rect.bottomRight());
Segment2 top(rect.topLeft(), rect.topRight());
Segment2 left(rect.bottomLeft(), rect.topLeft());
Segment2 right(rect.bottomRight(), rect.topRight());
ConstPointIterator2 it;
for (it = begin+1; it != end; ++it) {
Segment2 seg(*it, *(it-1));
if (seg.intersect(bottom)) return true;
if (seg.intersect(top)) return true;
if (seg.intersect(left)) return true;
if (seg.intersect(right)) return true;
}
return false;
}
示例3: iPoints
/*!
The collision polygon calculated isn't optimal. We do it because it is used
for drawing. For collision handling it is poor.
\todo Refactor so collision and drawing polygon don't need to be the same
*/
PointsView::PointsView(Points2::iterator begin, Points2::iterator end) : iPoints(begin, end)
{
// Find rectangular polygon that will enclose all
// added points
Rect2 r;
Points2::iterator it;
for (it = begin; it != end; ++it) {
r = r.surround(*it);
}
Polygon2 p;
p.push_back(r.bottomLeft());
p.push_back(r.bottomRight());
p.push_back(r.topRight());
p.push_back(r.topLeft());
setCollisionPolygon(p);
}