paintops

Cyrille Berger cberger at cberger.net
Tue May 29 22:57:29 CEST 2007


On Tuesday 29 May 2007, Boudewijn Rempt wrote:
> Hi,
>
> Thanks to Hulmanen's patience we've uncovered a design flaw in our
> paintops. When I designed paintops way back in the old days, I didn't
> realize that when you have pressure settings the spacing of the brush
> footprints would change. Or rather, when you have pressure but don't change
> the size of the brush footprint, the spacing should not change. This is a
> problem, because the spacing of the brush footprints is not under control
> of KisPaintop but of KisPainter::paintLine.
>
> For 2.0, we have to do better. There are other types of paintops (bristle
> simulating brushes spring to mind) where the paintop needs to have control
> over the line that needs to be painted between two mouse/tablet events
> (note that mouse/tablet events never occur at the right spacing: we always
> have to either in-between, hence paintLine, or skip a few, if the brush is
> too large).
>
> paintLine is the only (?) method in KisPainter that is called when doing
> freehand work that involves tablet settings.
>
> The rect, star etc. tools don't do pressure, I believe. So the
> KisPainter::paintLine in-betweening code is fine for those.
>
> I've got the following design proposal, but I don't claim it's the best:
>
> add a KisPaintop::paintLine(QPointF pos1, QpointF pos2, const
> KisPaintInformation& info)
>
> This method _can_ call KisPainter::paintLine, which calls the paintops's
> paintAt method repeatedly. Or it can do something new and wondrous to
> in-between.
>
> The freehand tools then call KisPaintop::paintLine instead.
>
> Any better ideas?

I have been thinking about it since your hack^D fix to 1.6 :) and your comment 
in the message log.

First, I think I had rather see, Freehand tool call KisPainter::paintLine call 
KisPaintOp::paintLine call KisPaintOp::paintAt, that way all the current code 
using KisPainter will benefit from the improvement.

Then back to the question, there are three solutions:
- paintAt(x,y, info) like currently
- paintLine(point1, info1, point2, info2) (or paintLine(point1, point2, info), 
but if the pressure is different at the beginning of the line, no reason why 
not to benefit from it to draw a "gradient" of pressure, if you see what I 
mean)
- paintCurve(point1, tangeant1, info1, point2, tangeant2, info2)

I did not find that any solution was giving me full satisfaction. I will give 
the few thoughts that are tourmenting me on the subject. Lets start with the 
last solution, it add a lot of complexity, but having the tangeants might 
give better control on how the bristles flow.
On the other hand, if you consider the paintAt as way points, it can allready 
do what we want without changing the API, and tangeants information can be 
added throught the KisPaintInformation.

paintLine appears like a balance between the two extrem solution, so maybe 
it's good enought, but I don't think that for the bristles it is that 
usefull. As in fact, at least in the dynamic paint op, for them, I draw a 
line from the last point to the new point (line that might change in the 
future to something more complicated, but somewho the starting point will 
allways be the last position), and the way point system ala pointAt is not 
that bad.

-- 
Cyrille Berger


More information about the kimageshop mailing list