示例#1
0
void Ellipse::drawEllipse(sf::RenderTarget &target,
    const sf::Vector2i &start, const sf::Vector2i &end,
    const PaintParameters &param)
{
    int h = target.getSize().y;
    sf::Vector2f size{ static_cast<float>(end.x - start.x),
                       -static_cast<float>(end.y - start.y) };
    EllipseShape ellipse;
    auto getCorrectWidth = [](const int width, const sf::Vector2f &size)
    {
        int minWidth = std::min(fabsf(size.x), fabsf(size.y)) / 2.f;
        return width > minWidth ? minWidth : width;
    };
    ellipse.setOutlineThickness(-getCorrectWidth(param.width, size));
    ellipse.setOutlineColor(param.color);
    ellipse.setFillColor(sf::Color(0, 0, 0, 0));
    ellipse.setPosition(start.x, h - start.y);
    ellipse.setRadius(size / 2.f);
    target.draw(ellipse);
}
示例#2
0
void Region::addEllipse(rectangle frame) {
	EllipseShape* ellipse = new EllipseShape(sf::Vector2f(frame.width(), frame.height()));
	ellipse->setFillColor(sf::Color::Black);
	shapes.push_back(std::shared_ptr<sf::Shape>(ellipse));
}