Example #1
0
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();
}
Example #2
0
void BrushMaskGenerator::buildLUT(const Brush &brush)
{
	// First, determine if the brush shape depends on pressure
	_usepressure =
		brush.radius1() != brush.radius2() ||
		qAbs(brush.hardness1() - brush.hardness2()) >= (1/256.0) ||
		qAbs(brush.opacity1() - brush.opacity2()) >= (1/256.0)
		;

	if(_usepressure) {
		// Build a lookup table for all pressure levels
		uint len = 0;
		_index.reserve(PRESSURE_LEVELS + 1);
		_radius.reserve(PRESSURE_LEVELS);
		_index.append(0);

		for(int i=0;i<PRESSURE_LEVELS;++i) {
			float p = int2pressure(i);
			float radius = brush.fradius(p);
			_radius.append(radius);
			len += ceil(radius*radius);
			_index.append(len);

		}
		_lut.resize(len);

		for(int i=0;i<PRESSURE_LEVELS;++i) {
			float p = int2pressure(i);
			_buildLUT(_radius.at(i), brush.opacity(p), brush.hardness(p), _index.at(i+1)-_index.at(i), _lut.data() + _index.at(i));
		}
	} else {
		// Shape not affected by pressure: only lookup table needed
		float radius = brush.fradius(1.0);
		int len = ceil(radius*radius);
		_lut.resize(len);
		_index.append(len);
		_radius.append(radius);
		_buildLUT(radius, brush.opacity1(), brush.hardness1(), len, _lut.data());
	}
}