Recent

Author Topic: Two pixels vertical line in canvas becomes one pixel.  (Read 2171 times)

Fantablup

  • Full Member
  • ***
  • Posts: 139
Two pixels vertical line in canvas becomes one pixel.
« on: June 20, 2021, 06:42:44 pm »
I was trying to create borders with lines in a TImage canvas.
I also tried with drawing rectangle with insideFrame, but with same result.

Also, using insideFrame is destroying everything else. The StretchDraw result in the canvas is not working then.

The left line is always one pixel. Just can't make it two pixels.
The pen with is 2.

I read about it is a problem, but i can't find any solution. So, i dropped the border totally, because it is not sowing up nice.




« Last Edit: June 20, 2021, 07:02:27 pm by Fantablup »

speter

  • Full Member
  • ***
  • Posts: 217
Re: Two pixels vertical line in canvas becomes one pixel.
« Reply #1 on: June 21, 2021, 01:33:32 am »
Is it possible that you are too close to an edge of the canvas?

If you use code something like:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.PaintBox1Paint(Sender: TObject);
  2. const
  3.   x = 10;
  4. begin
  5.   with paintbox1.canvas do
  6.     begin
  7.       pen.width := 2;
  8.       line(x,10, x,100);
  9.     end;
  10. end;
  11.  
You will get a 2 pixel wide line.

Note that if your X value is less than half the pen.width, the line will be clipped. For example something like:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.PaintBox1Paint(Sender: TObject);
  2. const
  3.   x = 10;
  4. begin
  5.   with paintbox1.canvas do
  6.     begin
  7.       pen.width := 25;
  8.       line(x,10, x,100);
  9.     end;
  10. end;
  11.  
the code above will produce a clipped line...

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)

Fantablup

  • Full Member
  • ***
  • Posts: 139
Re: Two pixels vertical line in canvas becomes one pixel.
« Reply #2 on: June 21, 2021, 01:41:30 am »
Thanks speter ;)

I will test it out.

I don't need it right now, but can do some testing anyway.

 

TinyPortal © 2005-2018