<div class="gmail_quote">On Sun, Jan 31, 2010 at 2:53 AM, Adrian Page <span dir="ltr">&lt;&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
Dmitry Kazakov wrote:<br>
&gt; I thing this should be reverted according to Qt&#39;s QRect tradition, i.e.<br>
&gt; (5,7)-&gt;(5.0,7.0). Or change ALL the Krita&#39;s code that uses<br>
&gt; QRectF::toAlignedRect() or QRectF(intRect) to a new type of conversion.<br>
&gt; Other way we&#39;ll dig a deep grave for ourselves using two completely<br>
&gt; different coordinate systems throughout the code.<br>
<br>
</div>This is the way krita has worked for the last however many years.</blockquote><div><br></div><div>Well, not everywhere. Please take a look into KisImage::documentToIntPixel(). It uses QRectF::toAlignedRect(). So it does just the opposite to what you are saying.</div>
<div>KisPrescaledProjection and KisView are fully based on Qt&#39;s style. (It was based on it even before my refactorings)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 The standard in graphics is that when you convert int to floating point you<br>
add 0.5, and you truncate when converting float to int. (5, 7) -&gt; (5.5,<br>
7.5) -&gt; (5, 7).</blockquote><div><br></div><div>Not sure about &quot;truncating&quot;, as you may get some losses, when converting rects. I think rounding is much more stable. I remember i had many troubles in prescaled projection without rounding.</div>
<div><br></div><div>Anyway, Qt works in the opposite way. Or we work with them, or don&#39;t use QRectF in Krita at all for not confusing coders.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 We use subpixel positioning, so a 1x1 pixel brush<br>
painted to cover the top-left pixel is rendered at (0.5, 0.5), the<br>
centre of that pixel. Rendering it at (0.0, 0.0) will divide the brush<br>
over the 4 pixels (-1, -1), (-1, 0), (0, -1) and (0, 0).<br>
<br>
krita already has functions that perform these conversions, see<br>
KisImage::pixelToDocument(const QPoint &amp;) and KisTool::*. And krita was<br>
doing this before QPointF/QRectF even existed, so we&#39;re hardly breaking<br>
with their tradition. ;-)<br></blockquote><div><br></div><div>Then we shouldn&#39;t use QRectF at all. I&#39;ve already said, we have functions those are very inconsistent and use both. Or we change everything to Qt&#39;s style based on QRectF, or to Krita&#39;s style based on some KisRectF.</div>
<div><br></div></div><br clear="all"><br>-- <br>Dmitry Kazakov<br>