Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: Fantablup on June 20, 2021, 06:42:44 pm

Title: Two pixels vertical line in canvas becomes one pixel.
Post by: Fantablup 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.




Title: Re: Two pixels vertical line in canvas becomes one pixel.
Post by: speter 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.
Title: Re: Two pixels vertical line in canvas becomes one pixel.
Post by: Fantablup 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