Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Graphics    [ Add a report in this area ]  
Report #:  106211   Status: Reported
add TCanvas....(TPoint) and ....(TSize) methods please.
Project:  Delphi Build #:  any
Version:    16.4 Submitted By:   Dmitry Burov
Report Type:  Suggestion / Enhancement Request Date Reported:  6/6/2012 1:43:23 AM
Severity:    Commonly encountered problem Last Updated: 6/6/2012 7:03:45 PM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Standard VCL.Graphics.TCanvas has two methods:
    procedure LineTo(X, Y: Integer);
    procedure MoveTo(X, Y: Integer);

But in my code it maybe more natural to use TPoint or TSize (those two types are almost the same)

I bind semantically-connected vars together into TPoint and work with it, using .Offset methods and such.

But then i have to interop with TCanvas.

I mademyself such a helper as below, but i am pretty sure that is to be part of core functionality

---------

type TCanvasPt = class helper for TCanvas
     procedure LineTo(const XY: TPoint); overload; inline;
     procedure MoveTo(const XY: TPoint); overload; inline;
end;

procedure TCanvasPt.LineTo(const XY: TPoint);
begin
   Self.LineTo(XY.X, XY.Y);
end;

procedure TCanvasPt.MoveTo(const XY: TPoint);
begin
   Self.MoveTo(XY.X, XY.Y);
end;

------------

Now i can call any of  Canvas.MoveTo(1,1) and Canvas.MoveTo(Point(1,1)).
Compiler would figure out what to call;

Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01