Re: [Lazarus] Canvas.Rectangle question

2019-08-16 Thread Graeme Geldenhuys via lazarus
On 16/08/2019 8:01 pm, Bo Berglund via lazarus wrote:
> Seems like if one does not draw the border at all (pen.width = 0) the
> resulting rectangle will be painted within a pixel correctly placed
> and sized.


If I recall correctly, both Win32 and XLib will render a line with the
thinnest possible width, when you set Pen.Width = 0.  But it's been a
while since I read those docs, so don't hold me to it. ;-)
I don't know what OSX does.


Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Canvas.Rectangle question

2019-08-16 Thread Bo Berglund via lazarus
On Fri, 16 Aug 2019 18:27:02 +0100, Graeme Geldenhuys via lazarus
 wrote:

>On 16/08/2019 4:20 pm, Bo Berglund via lazarus wrote:
>> Say the rectangle is (10,4, 30,14) and the Pen.Wdth is set to 2, is
>> the resulting shape 20 x 10 or 24 x 14 in size?
>
>This is why fpGUI uses (x, y, width, height) instead of (x1, y1, x2,
>y2), because the latter is just too confusing.
>
>Anyway, I think LCL follows the following design... See the Qt4
>documentation.
>
>   https://doc.qt.io/archives/qt-4.8/qrect.html#rendering
>

Thanks for the link! It seems like the border line involved by the pen
property is interfering with the sizing of the rectangle...

I tested by doing this:
  Cnv.Pen.Width := 0;

Then I ran my code and the resulting rectangle looks better.
Hard to say for sure since the pixels are so small...

My use case is this:
I have written a video editor where I can navigate a video in steps of
fixed lengths and also by clicking on a progressbar showing the
position in the video. It can also just play the video normally.

I can set markers on the start and end of a cut and add it to an array
of cuts. Then a buttonclick will generate an ffmpeg command to cut and
paste the video to create an edited video with only the cuts included.

What I wanted to do then was to place a thin panel below the
progressbar where I would paint rectangles at the precise positions of
the cuts so far entered to show how the edits are placed.
It would show what parts of the video will be included inside the
final edited video after ffmpeg processing.

I want the display to be as accurate as possible, that is why I
started wondering about the actual rectangle size,

Seems like if one does not draw the border at all (pen.width = 0) the
resulting rectangle will be painted within a pixel correctly placed
and sized.

I love this list/(newsgroup via GMane), here is always someone to give
good advice! :)


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Canvas.Rectangle question

2019-08-16 Thread Graeme Geldenhuys via lazarus
On 16/08/2019 4:20 pm, Bo Berglund via lazarus wrote:
> Say the rectangle is (10,4, 30,14) and the Pen.Wdth is set to 2, is
> the resulting shape 20 x 10 or 24 x 14 in size?

This is why fpGUI uses (x, y, width, height) instead of (x1, y1, x2,
y2), because the latter is just too confusing.

Anyway, I think LCL follows the following design... See the Qt4
documentation.

   https://doc.qt.io/archives/qt-4.8/qrect.html#rendering



Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus