Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Canvas question
Fri, May 26 2017 11:57 AMPermanent Link

Uli Becker

Hi,

I've never used a TPaint control and its canvas. Maybe I'm missing
something very basic.
Just to test I draw some lines on the canvas with this code:

   with PaintSurface.Canvas do
   begin
      StrokeStyle := dsColor;
      StrokeColor := clRed;
      FillStyle := dsColor;
      LineWidth := 1;
      for i := 1 to 10 do
      begin
         MoveTo(20,i*50);
         LineTo(500,i*50);
         Stroke;
      end;
   end;

But the lines don't have a LineWidth = 1 (attached a screenshot with a
transparent BasicPanel and a red border at the right side with LineWidth
= 1 to compare).

What am I doing wrong?

Thanks Uli



Attachments: Clip1.png
Fri, May 26 2017 1:01 PMPermanent Link

Walter Matte

Tactical Business Corporation

See ClosePath;  BeginPath;

     with PaintSurface.Canvas do
        begin
        closepath;
        beginpath;
        StrokeStyle:=dsColor;
        StrokeColor:=clGray;
        LineWidth:=1;
        MoveTo(0,0);
        LineTo(500,100);
        Stroke;
        end;

     with PaintSurface.Canvas do
        begin
        closepath;
        beginpath;
        StrokeStyle:=dsColor;
        StrokeColor:=clGray;
        LineWidth:=5;
        MoveTo(0,0);
        LineTo(500,500);
        Stroke;
        end;


Walter
Sat, May 27 2017 3:47 AMPermanent Link

Uli Becker

Walter,

> See ClosePath;  BeginPath;

Thanks, but that doesn't change anything.

Uli
Sat, May 27 2017 5:07 AMPermanent Link

Uli Becker

Addition:

also in the TPaint example which is shipped with EWB there is no
difference between

LineWidth = 1 or LineWidth = 2
--
LineWidth = 3 or LineWidth = 4

etc.

Sat, May 27 2017 5:34 AMPermanent Link

Matthew Jones

Uli Becker <johnmuller54@gmail.com> wrote:
> Addition:
>
> also in the TPaint example which is shipped with EWB there is no
> difference between
>
> LineWidth = 1 or LineWidth = 2
> --
> LineWidth = 3 or LineWidth = 4
>
> etc.
>
>
>

This is all standard JavaScript stuff so the answers will be out there
ready to find. It's how I find such things out - anything not EWB will be
already answered elsewhere.

--
Matthew Jones
Sat, May 27 2017 6:11 AMPermanent Link

Uli Becker

Matthew,

> This is all standard JavaScript stuff so the answers will be out there
> ready to find. It's how I find such things out - anything not EWB will be
> already answered elsewhere.

Thanks for this hint:

https://stackoverflow.com/questions/13879322/drawing-a-1px-thick-line-in-canvas-creates-a-2px-thick-line

Uli
Wed, May 31 2017 12:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

Actually, what you want is this, a global translation of the canvas:

https://stackoverflow.com/questions/20140145/a-good-way-to-offset-all-thats-drawn-to-the-canvas-0-5-px

The EWB equivalent:

http://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TCanvasElement&method=Translate

EWB actually does something similar in the IDE in order to draw borders with different corner radii/colors using GDI+.

Tim Young
Elevate Software
www.elevatesoft.com
Image