Image BrushStrokerCustomBrush::drawDabImage(const TabletInputData &data, QRect *rect)
{
    Q_ASSERT(data.pressure > 0);

    Vec2D radiusVec;
    radiusVec.rx() = radiusBase() * data.pressure;
    radiusVec.ry() = radiusVec.x() * (1.0 - _setting.flattening);

    _lastMinorRadius = radiusVec.y();

    //qDebug() << "radius" << radiusVec.x << radiusVec.y;

    QPainterPath ellipse;
    ellipse.addEllipse(data.pos, radiusVec.x(), radiusVec.y());

    QRect dabRect;

    if (_setting.rotation)
    {
        QTransform rotation;
        rotation.rotate(_setting.rotation);
        ellipse = rotation.map(ellipse);

        dabRect = ellipse.boundingRect().toAlignedRect();
    }
    else
    {
        dabRect = QRectF(QPointF(data.pos - radiusVec), QSizeF(2.0 * radiusVec)).toAlignedRect();
    }

    Image dabImage(dabRect.size());
    dabImage.clear();

    Painter dabPainter(&dabImage);

    dabPainter.translateShape(-dabRect.topLeft());

    if (_setting.tableWidth == 1 && _setting.tableHeight == 1)
    {
        // no gradient
        dabPainter.setPixel(pixel());
    }
    else
    {
        ArgbGradient gradient;
        gradient.addStop(0, pixel());
        gradient.addStop(_setting.tableWidth, pixel() * _setting.tableHeight);
        gradient.addStop(1, Pixel(0));

        dabPainter.setBrush(Malachite::Brush::fromRadialGradient(gradient, data.pos, radiusVec));
    }

    dabPainter.drawPath(ellipse);

    dabPainter.end();

    *rect = dabRect;
    return dabImage;
}
Пример #2
0
	mulib::Vec2D mulib::Get2DBezier(const mulib::Vec2D<T>& startPos,
																	const mulib::Vec2D<T>& endPos,
																	const mulib::Vec2D<T>& ctrlPos,
																	const int divNum, const int nowPhase){
		using namespace mulib;
		if(divNum <= 0 || nowPhase > DivNum){
			return Vec2D<T>(0);
		}
		const double u = ( 1.0 / divNum ) * nowPhase;
		const Vec2D<double> psm = (1-u) * startPos + u * ctrlPos;
		const Vec2D<double> pme = (1-u) * ctrlPos + u * endPos;
		return Vec2D<T>(static_cast<T>((1-u) * psm.x() + u * pme.x()),
										static_cast<T>((1-u) * psm.y() + u * pme.y()));
	}
Пример #3
0
 //改行する
void _NewLine(){
	 _nowPoint.Set(_startPoint.x(), _nowPoint.y() + _lineMaxSize + _lineSpace);
	 _lineMaxSize = _nowSize;
	 _strVect.push_back(StrBlock(_nowPoint,_nowColor,_nowSize)); //描画位置を強制指定
 }
Пример #4
0
	mulib::Angle mulib::atan2(Vec2D<double> vec){
		return mulib::atan2(vec.y(),vec.x());
	}
Пример #5
0
void Vec2D::rotate(const Vec2D& point, double theta)
{
  set(x()-point.x(), y()-point.y());
  rotate(theta);
  set(x()+point.x(), y()+point.y());
}