コード例 #1
0
ファイル: layer.cpp プロジェクト: gotomypc/Drawpile
void Layer::dab(int contextId, const Brush &brush, const Point &point)
{
	Brush effective_brush = brush;
	Layer *l = this;

	if(!brush.incremental()) {
		// Indirect brush: use a sublayer
		l = getSubLayer(contextId, brush.blendingMode(), brush.opacity(1) * 255);

		effective_brush.setOpacity(1.0);
		effective_brush.setOpacity2(brush.isOpacityVariable() ? 0.0 : 1.0);
		effective_brush.setBlendingMode(1);

	} else if(contextId<0) {
		// Special case: negative context IDs are temporary overlay strokes
		l = getSubLayer(contextId, brush.blendingMode(), 255);
		effective_brush.setBlendingMode(1);
	}

	Point p = point;
	if(!effective_brush.subpixel()) {
		p.setX(qFloor(p.x()));
		p.setY(qFloor(p.y()));
	}

	l->directDab(effective_brush, BrushMaskGenerator::cached(effective_brush), p);

	if(_owner)
		_owner->notifyAreaChanged();
}
コード例 #2
0
ファイル: layer.cpp プロジェクト: gotomypc/Drawpile
/**
 * Draw a line using either drawSoftLine or drawHardLine, depending on
 * the subpixel hint of the brush.
 * @param context drawing context id (needed for indirect drawing)
 */
void Layer::drawLine(int contextId, const Brush& brush, const Point& from, const Point& to, qreal &distance)
{
	Brush effective_brush = brush;
	Layer *l = this;

	if(!brush.incremental()) {
		// Indirect brush: use a sublayer
		l = getSubLayer(contextId, brush.blendingMode(), brush.opacity(1) * 255);

		effective_brush.setOpacity(1.0);
		effective_brush.setOpacity2(brush.isOpacityVariable() ? 0.0 : 1.0);
		effective_brush.setBlendingMode(1);

	} else if(contextId<0) {
		// Special case: negative context IDs are temporary overlay strokes
		l = getSubLayer(contextId, brush.blendingMode(), 255);
		effective_brush.setBlendingMode(1);
	}

	const BrushMaskGenerator &bmg = BrushMaskGenerator::cached(effective_brush);

	if(effective_brush.subpixel())
		l->drawSoftLine(effective_brush, bmg, from, to, distance);
	else
		l->drawHardLine(effective_brush, bmg, from, to, distance);

	if(_owner)
		_owner->notifyAreaChanged();
}
コード例 #3
0
ファイル: layer.cpp プロジェクト: LionsPhil/Drawpile
/**
 * Draw a line using either drawSoftLine or drawHardLine, depending on
 * the subpixel hint of the brush.
 * @param context drawing context id (needed for indirect drawing)
 */
void Layer::drawLine(int contextId, const Brush& brush, const Point& from, const Point& to, StrokeState &state)
{
    Brush effective_brush = brush;
    Layer *l = this;

    if(!brush.incremental()) {
        // Indirect brush: use a sublayer
        l = getSubLayer(contextId, brush.blendingMode(), brush.opacity(1) * 255);

        effective_brush.setOpacity(1.0);
        effective_brush.setOpacity2(brush.isOpacityVariable() ? 0.0 : 1.0);
        effective_brush.setBlendingMode(BlendMode::MODE_NORMAL);

    } else if(contextId<0) {
        // Special case: negative context IDs are temporary overlay strokes
        l = getSubLayer(contextId, brush.blendingMode(), 255);
        effective_brush.setBlendingMode(BlendMode::MODE_NORMAL);
    }

    if(effective_brush.subpixel())
        l->drawSoftLine(effective_brush, from, to, state);
    else
        l->drawHardLine(effective_brush, from, to, state);

    if(_owner)
        _owner->notifyAreaChanged();
}