예제 #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
/**
 * 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();
}
예제 #4
0
파일: brush.cpp 프로젝트: gotomypc/Drawpile
bool Brush::operator==(const Brush& brush) const
{
	return radius1() == brush.radius1() && radius2() == brush.radius2() &&
			qAbs(hardness1() - brush.hardness1()) <= 1.0/256.0 &&
			qAbs(hardness2() - brush.hardness2()) <= 1.0/256.0 &&
			qAbs(opacity1() - brush.opacity1()) <= 1.0/256.0 &&
			qAbs(opacity2() - brush.opacity2()) <= 1.0/256.0 &&
			color1() == brush.color1() &&
			color2() == brush.color2() &&
			spacing() == brush.spacing() &&
			subpixel() == brush.subpixel() &&
			incremental() == brush.incremental() &&
			blendingMode() == brush.blendingMode();
}