On-canvas preview of the brushes
LukasT.dev@gmail.com
lukast.dev at gmail.com
Fri May 1 11:47:02 CEST 2009
Hi,
There are some nice commits from Cyrille in trunk about the preview of the
brush on the canvas. So far it is little buggy. When you select the Pixel
Brush and select the diameter e.g. 25 and try to paint, you will get the wrong
result.
I have some questions about the code as I don't understand it a bit:
The code is in PaintOpSettings object.Will it be possible to change the state
of the shape of the preview throught stroke painting? The way I see it now
would be : add some variable to Settings Object and call setter in the
paintAt? There is reference to settings object in the constructor, so paintop
would have to make member with reference.
This returns the area of KisImage that should be recomposited? If so I would
propose to just return the QRectF which would represent the size of the brush
and handle the pixelToDocument higher in the API as I'm really confused with
it.
You create QRectF of the brush, which is transformed into pixelToDocument and
the result is then translated to the position of the centre of the brush? Is
it right?
QRectF KisBrushOpSettings::paintOutlineRect(const QPointF& pos, KisImageSP
image) const
{
...
return image->
pixelToDocument(
QRect(0,0, brush->width(), brush->height() )
).translated( pos - hotSpot + QPoint(1,1)
);
}
Here is drawOutline, which draws outline. I would again propose just to paint
on the pos which would be transformed before this method is called higher in
the API. So that you don't have to handle the transformation process in the
paintop as it leads to code duplication and mistakes.
Let me guess what this is doing:
documentToView convert from pt to pixels. Why do you need it?
pixelToDocument transform the translated QRect area of the brush and result is
converted from pt to pixels?
void KisBrushOpSettings::paintOutline(const QPointF& pos, KisImageSP image,
QPainter &painter, const KoViewConverter &converter) const
{
...
painter.drawEllipse( converter.documentToView( image-
>pixelToDocument(QRect(0,0, brush->width(), brush->height()) ).translated( pos
- hotSpot + QPoint(1,1) ) ) );
}
I really like the preview of the brush. It is really nice and important
feature.
Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20090501/18277a09/attachment.htm
More information about the kimageshop
mailing list