KoShape *EllipseShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
{
    EllipseShape *ellipse = new EllipseShape();

    ellipse->setStroke(new KoShapeStroke(1.0));
    ellipse->setShapeId(KoPathShapeId);

    QRadialGradient *gradient = new QRadialGradient(QPointF(0.5,0.5), 0.5, QPointF(0.25,0.25));
    gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient->setColorAt(0.0, Qt::white);
    gradient->setColorAt(1.0, Qt::green);
    ellipse->setBackground(new KoGradientBackground(gradient));

    return ellipse;
}
예제 #2
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);
}
예제 #3
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));
}