Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook (preview only)

Author Topic: Canvas, TShape ... Rectangle with pointed corners (no missing pixels)  (Read 252 times)

RAW

• Hero Member
• Posts: 794
Canvas, TShape ... Rectangle with pointed corners (no missing pixels)
« on: August 12, 2019, 08:12:07 pm »
Obviously I'm missing something ... Can someone explain how to get real pointed corners (Canvas, TShape: Rectangle)?

Code: Pascal  [Select]
1. unit Unit1;
2. {\$mode objfpc}{\$H+}
3.
4. interface
5.
6. uses
7.   Classes,
8.   SysUtils,
9.   Forms,
10.   Controls,
11.   Graphics,
12.   ExtCtrls;
13.
14. type
15.   TForm1 = class(TForm)
16.     procedure FormPaint  (Sender: TObject);
17.     procedure FormCreate (Sender: TObject);
18.   end;
19.
20. var
21.   Form1: TForm1;
22.
23. implementation
24. {\$R *.lfm}
25.
26. procedure TForm1.FormPaint(Sender: TObject);
27. begin
28.   Canvas.Pen.Width:= 6;
29.   Canvas.Pen.Color:= RGBToColor(0, 80, 255);
30.   Canvas.Rectangle(400, 100, 800, 400);
31.   Canvas.Pen.Color:= clRed;
32.   Canvas.Frame(300, 300, 600, 600);
33. end;
34.
35. procedure TForm1.FormCreate(Sender: TObject);
36. var
37.  shp: TShape;
38. begin
39.   Color:= clWhite;
40.
41.   shp:= TShape.Create(Self);
42.   shp.Shape:= stRectangle;
43.   shp.Pen.Color:= RGBToColor(0, 80, 255);
44.   shp.Pen.Width:= 6;
45.   shp.SetBounds(100, 100, 200, 100);
46.   shp.Parent:= Self;
47. end;
48.
49. end.
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 2.0.4 FPC 3.0.4 - TRUNK 2.1.0 FPC 3.3.1

wp

• Hero Member
• Posts: 6491
Re: Canvas, TShape ... Rectangle with pointed corners (no missing pixels)
« Reply #1 on: August 12, 2019, 09:50:25 pm »
Set the pen's JoinStyle to pjsMiter
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

RAW

• Hero Member
• Posts: 794
Re: Canvas, TShape ... Rectangle with pointed corners (no missing pixels)
« Reply #2 on: August 12, 2019, 10:22:01 pm »
Ah, JoinStyle ... Thank you very much, next time I need to take a closer look!
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 2.0.4 FPC 3.0.4 - TRUNK 2.1.0 FPC 3.3.1