Пример #1
0
void ColorPicker::motion(const paintcore::Point& point, bool constrain, bool center)
{
	Q_UNUSED(constrain);
	Q_UNUSED(center);
	int layer=0;
	if(settings().getColorPickerSettings()->pickFromLayer()) {
		layer = this->layer();
	}
	scene().pickColor(point.x(), point.y(), layer, _bg);
}
Пример #2
0
void ColorPicker::motion(const paintcore::Point& point, bool constrain, bool center)
{
    Q_UNUSED(constrain);
    Q_UNUSED(center);
    int layer=0;
    if(owner.toolSettings()->getColorPickerSettings()->pickFromLayer()) {
        layer = owner.activeLayer();
    }
    int size = owner.toolSettings()->getColorPickerSettings()->getSize();

    owner.model()->pickColor(point.x(), point.y(), layer, size);
}
Пример #3
0
void FloodFill::begin(const paintcore::Point &point, float zoom)
{
	// TODO do this in the layer thread?
	Q_UNUSED(zoom);
	FillSettings *ts = owner.toolSettings()->getFillSettings();
	QColor color = owner.toolSettings()->foregroundColor();

	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

	owner.model()->layerStack()->lock();
	paintcore::FillResult fill = paintcore::floodfill(
		owner.model()->layerStack(),
		QPoint(point.x(), point.y()),
		color,
		ts->fillTolerance(),
		owner.activeLayer(),
		ts->sampleMerged()
	);
	owner.model()->layerStack()->unlock();

	fill = paintcore::expandFill(fill, ts->fillExpansion(), color);

	if(fill.image.isNull()) {
		QApplication::restoreOverrideCursor();
		return;
	}

	// If the target area is transparent, use the BEHIND compositing mode.
	// This results in nice smooth blending with soft outlines, when the
	// outline has different color than the fill.
	paintcore::BlendMode::Mode mode = paintcore::BlendMode::MODE_NORMAL;
	if(ts->underFill() && (fill.layerSeedColor & 0xff000000) == 0)
		mode = paintcore::BlendMode::MODE_BEHIND;

	// Flood fill is implemented using PutImage rather than a native command.
	// This has the following advantages:
	// - backward and forward compatibility: changes in the algorithm can be made freely
	// - tolerates out-of-sync canvases (shouldn't normally happen, but...)
	// - bugs don't crash/freeze other clients
	//
	// The disadvantage is increased bandwith consumption. However, this is not as bad
	// as one might think: the effective bit-depth of the bitmap is 1bpp and most fills
	// consist of large solid areas, meaning they should compress ridiculously well.
	QList<protocol::MessagePtr> msgs;
	msgs << protocol::MessagePtr(new protocol::UndoPoint(0));
	msgs << net::command::putQImage(0, owner.activeLayer(), fill.x, fill.y, fill.image, mode);
	owner.client()->sendMessages(msgs);

	QApplication::restoreOverrideCursor();
}
Пример #4
0
void CanvasView::onPenDown(const paintcore::Point &p, bool right)
{
	if(_scene->hasImage() && !_locked) {

		if(_specialpenmode) {
			// quick color pick mode
			_scene->pickColor(p.x(), p.y(), 0, right);
		} else {
			if(_smoothing>0 && _current_tool->allowSmoothing())
				_smoother.addPoint(p);
			else
				_current_tool->begin(p, right, _zoom);
		}
	}
}
Пример #5
0
void CanvasView::onPenMove(const paintcore::Point &p, bool right, bool shift, bool alt)
{
	if(_scene->hasImage() && !_locked) {
		if(_specialpenmode) {
			// quick color pick mode
			_scene->pickColor(p.x(), p.y(), 0, right);
		} else {
			if(_smoothing>0 && _current_tool->allowSmoothing()) {
				_smoother.addPoint(p);
				if(_smoother.hasSmoothPoint()) {
					if(_smoother.isFirstSmoothPoint())
						_current_tool->begin(_smoother.smoothPoint(), right, _zoom);
					else
						_current_tool->motion(_smoother.smoothPoint(), shift, alt);
				}
			} else {
				_current_tool->motion(p, shift, alt);
			}
		}
	}
}