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


C++ Rect2::topLeft方法代码示例

本文整理汇总了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;
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:16,代码来源:Line2.cpp

示例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;  
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:17,代码来源:PolygonUtils.cpp

示例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);
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:24,代码来源:PointsView.cpp


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