Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Draw a smooth line on canvas


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0 Threads: [ Previous | Next ]
Lex Dean

Posts: 132
Registered: 3/26/07
Draw a smooth line on canvas  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2018 2:39 PM
TMoveCanvas has a FTopLeft that everything inside the object references to and draws on the original canvas
I wanting to make a procedure smoothLineTo(
FMoved is the Pointer of last position moved to
"If (cEnd.X > cEnd.Y) then" is to separate and identify the longest side of the vector
as cEnd is the Line vector to be drawn
aColor gives me access to the colour faster

a) I need a quick way to identify the colour strength of the pixel and the pixel above it or below it may be to give the smooth line effect.
I need a faster way to paint the pixel than through the TCanvas object. Is their a way to go back to the handle or DC or something and point to the pixel in raw memory that is faster.

Code:
Type
aColor = record
case Integer of
0: (Y, B, G, R: byte);
1: (C: TColor);
end;

procedure TMoveCanvas.SmoothLineTo(X, Y: Integer);
Var
cEnd: TPoint;
I, G, R, S: Integer;
C1, C2: TColor;

Function GetColour(Colour: TColor; Strength: Word): TColor;
Var Y, B, G, R: byte;
begin
aColor(Colour).B * (Strength div 1000)

end;

begin
If (X = FMoved.X) or (Y = FMoved.Y) then
Begin
FCanvas.LineTo(X - TFTopLeft.X, Y - TFTopLeft.Y);
FMoved := Point(X, Y);
Exit;
end;
cEnd.X := X - FMoved.X;// - TFTopLeft.X;
cEnd.Y := Y - FMoved.Y;

If (cEnd.X <> cEnd.Y) then
If (cEnd.X > cEnd.Y) then
begin
G := 1000 * cEnd.X div cEnd.Y;
For I := 0 to cEnd.X do
Begin
R := I * G;
S := R and 1000;

end

end else
begin

end;
end;

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02