本文整理汇总了C++中sf::Shape::GetPointPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Shape::GetPointPosition方法的具体用法?C++ Shape::GetPointPosition怎么用?C++ Shape::GetPointPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Shape
的用法示例。
在下文中一共展示了Shape::GetPointPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool RectangleBlock::RectangleEquality(const sf::Shape& a, const sf::Shape& b) {
if(a.GetNbPoints() != b.GetNbPoints() ) return false;
for(int i=0;i<a.GetNbPoints();i++) { //egyesével megvizsgáljuk
if(a.GetPointPosition(i) != b.GetPointPosition(i)) {
return false;
}
}
return true;
}
示例2: ApplyGradient
void sf::ApplyGradient(sf::Shape& shape, Orientation::Type orientation, const sf::Color& color1, const sf::Color& color2, bool applyOnBorder)
{
if(orientation != sf::Orientation::NONE)
{
sf::FloatRect shapeRect(shape.GetPointPosition(0), sf::Vector2f(0.f,0.f));
sf::Vector2f rectRightBottomCorner(0.f,0.f);
// Define left and top limits
for(unsigned int i = 0; i < shape.GetPointsCount(); ++i)
{
sf::Vector2f pointPosition = shape.GetPointPosition(i);
shapeRect.Left = (pointPosition.x < shapeRect.Left) ? pointPosition.x : shapeRect.Left;
shapeRect.Top = (pointPosition.y < shapeRect.Top) ? pointPosition.y : shapeRect.Top;
rectRightBottomCorner.x = (pointPosition.x > rectRightBottomCorner.x) ? pointPosition.x : rectRightBottomCorner.x;
rectRightBottomCorner.y = (pointPosition.y > rectRightBottomCorner.y) ? pointPosition.y : rectRightBottomCorner.y;
}
shapeRect.Width = rectRightBottomCorner.x-shapeRect.Left;
shapeRect.Height = rectRightBottomCorner.y-shapeRect.Top;
// Apply gradient
for(unsigned int i = 0; i < shape.GetPointsCount(); ++i)
{
float factor = 0.f;
sf::Vector2f pointPosition = shape.GetPointPosition(i);
switch(orientation)
{
case Orientation::TOPTOBOTTOM :
factor = 1-(pointPosition.y-shapeRect.Top)/shapeRect.Height;
break;
case Orientation::BOTTOMTOTOP :
factor = (pointPosition.y-shapeRect.Top)/shapeRect.Height;
break;
case Orientation::LEFTTORIGHT :
factor = 1-(pointPosition.x-shapeRect.Left)/shapeRect.Width;
break;
case Orientation::RIGHTTOLEFT :
factor = (pointPosition.x-shapeRect.Left)/shapeRect.Width;
break;
default :
factor = 1;
break;
}
if(applyOnBorder)
shape.SetPointOutlineColor(i, sf::Color(factor*color1.r+(1-factor)*color2.r, factor*color1.g+(1-factor)*color2.g, factor*color1.b+(1-factor)*color2.b, factor*color1.a+(1-factor)*color2.a));
else
shape.SetPointColor(i, sf::Color(factor*color1.r+(1-factor)*color2.r, factor*color1.g+(1-factor)*color2.g, factor*color1.b+(1-factor)*color2.b, factor*color1.a+(1-factor)*color2.a));
}
}
}
示例3: GetShapeSize
sf::Vector2f GetShapeSize(sf::Shape& s){
sf::Vector2f Min={0.f,0.f},Max=Min;
for(unsigned int a=0;a<s.GetNbPoints();a++){
auto it=s.GetPointPosition(a);
if(it.x<Min.x)Min.x=it.x;
if(it.y<Min.y)Min.y=it.y;
if(it.x>Max.x)Max.x=it.x;
if(it.y>Max.y)Max.y=it.y;
}
return Max-Min;
}
示例4: pointIntersectsShape
bool pointIntersectsShape(int x, int y, sf::Shape shape) {
// TODO: Hardcoding this is pretty much the dumbest
// thing in the history of forever.
sf::Vector2<float> ltop = shape.GetPointPosition(0);
sf::Vector2<float> rbot = shape.GetPointPosition(2);
sf::Rect<float> hitbox(ltop.x, ltop.y, rbot.x, rbot.y);
return hitbox.Contains(x, y);
}