Recent

Author Topic: Slightly confused about Rectangles!  (Read 3965 times)

440bx

  • Hero Member
  • *****
  • Posts: 2504
Re: Slightly confused about Rectangles!
« Reply #15 on: August 26, 2021, 10:13:55 pm »
@skalogryz explained the cause for the rectangle being short one pixel.

if you want to see an example that is specifically created to show how the painting occurs and what affects it, see the "rectangle" example found at https://forum.lazarus.freepascal.org/index.php/topic,53690.msg397420.html#msg397420

That post is more than just about rectangles but you might find the example and the additional explanations helpful.

HTH.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

OldAndTired

  • New member
  • *
  • Posts: 9
Re: Slightly confused about Rectangles!
« Reply #16 on: August 26, 2021, 10:33:00 pm »

This is for the historical reasons. (Delphi compatility)
and Delphi itself draws rectangles following WinAPI rules
Quote
When an application calls the Rectangle function, the system draws the rectangle, excluding the right and lower sides if no world transformation is set for the given device context.

Thanks! This finally explains what I've been experiencing.

Actually, I was attempting to use a Copyrect in order to copy a 1-pixel wide area from the image to a buffer bitmap and it wasn't working. After many hours of messing about not sure if my code was wrong I tried drawing some lines & rectangles and got to where I was when I posted here. It sort of became a X-Y problem for a while.

Now I can hopefully move forward... I'll look to moving things to onPaint while I'm at it. I'm not too concerned about cross-platform & compatability as this is just a one-off hobby project for me.



speter

  • Full Member
  • ***
  • Posts: 223
Re: Slightly confused about Rectangles!
« Reply #17 on: August 27, 2021, 04:18:48 am »
I was attempting to use a Copyrect in order to copy a 1-pixel wide area

Are you aiming to create a crosshair (cursor)?

If so, have a look at the attached project. It uses "xor" mode to create a cursor.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

OldAndTired

  • New member
  • *
  • Posts: 9
Re: Slightly confused about Rectangles!
« Reply #18 on: August 27, 2021, 02:36:50 pm »
Are you aiming to create a crosshair (cursor)?

If so, have a look at the attached project. It uses "xor" mode to create a cursor.

Thanks - I'll take a look at that, as it sounds like it might be simpler anyway. No I wasn't planning a crosshair, just a vertical line to sweep across a graph as a sort of visual progress indicator. It's for an arduino-controlled oven which will follow a defined time/temperature profile, the profile is pre-plotted and the actual temperature plotted over time.

I may well decide I don't like it once I get it working  :-\ But I can't leave it until I fix it....

 

TinyPortal © 2005-2018