koffice/krita/ui/canvas
Adrian Page
adrian at pagenet.plus.com
Sun Jan 31 00:53:42 CET 2010
Dmitry Kazakov wrote:
> I thing this should be reverted according to Qt's QRect tradition, i.e.
> (5,7)->(5.0,7.0). Or change ALL the Krita's code that uses
> QRectF::toAlignedRect() or QRectF(intRect) to a new type of conversion.
> Other way we'll dig a deep grave for ourselves using two completely
> different coordinate systems throughout the code.
This is the way krita has worked for the last however many years. The
standard in graphics is that when you convert int to floating point you
add 0.5, and you truncate when converting float to int. (5, 7) -> (5.5,
7.5) -> (5, 7). We use subpixel positioning, so a 1x1 pixel brush
painted to cover the top-left pixel is rendered at (0.5, 0.5), the
centre of that pixel. Rendering it at (0.0, 0.0) will divide the brush
over the 4 pixels (-1, -1), (-1, 0), (0, -1) and (0, 0).
krita already has functions that perform these conversions, see
KisImage::pixelToDocument(const QPoint &) and KisTool::*. And krita was
doing this before QPointF/QRectF even existed, so we're hardly breaking
with their tradition. ;-)
Adrian
More information about the kimageshop
mailing list