delphi draw antialiased line
procedure DrawAntialisedLine(Canvas: TCanvas; const AX1, AY1, AX2, AY2: real; const LineColor: TColor);

var
  swapped: boolean;

  procedure plot(const x, y, c: real);
  var
    resclr: TColor;
  begin
    if swapped then
      resclr := Canvas.Pixels[round(y), round(x)]
    else
      resclr := Canvas.Pixels[round(x), round(y)];
    resclr := RGB(round(GetRValue(resclr) * (1-c) + GetRValue(LineColor) * c),
                  round(GetGValue(resclr) * (1-c) + GetGValue(LineColor) * c),
                  round(GetBValue(resclr) * (1-c) + GetBValue(LineColor) * c));
    if swapped then
      Canvas.Pixels[round(y), round(x)] := resclr
    else
      Canvas.Pixels[round(x), round(y)] := resclr;
  end;

  function rfrac(const x: real): real; inline;
  begin
    rfrac := 1 - frac(x);
  end;

  procedure swap(var a, b: real);
  var
    tmp: real;
  begin
    tmp := a;
    a := b;
    b := tmp;
  end;

var
  x1, x2, y1, y2, dx, dy, gradient, xend, yend, xgap, xpxl1, ypxl1,
  xpxl2, ypxl2, intery: real;
  x: integer;

begin

  x1 := AX1;
  x2 := AX2;
  y1 := AY1;
  y2 := AY2;

  dx := x2 - x1;
  dy := y2 - y1;
  swapped := abs(dx) < abs(dy);
  if swapped then
  begin
    swap(x1, y1);
    swap(x2, y2);
    swap(dx, dy);
  end;
  if x2 < x1 then
  begin
    swap(x1, x2);
    swap(y1, y2);
  end;

  gradient := dy / dx;

  xend := round(x1);
  yend := y1 + gradient * (xend - x1);
  xgap := rfrac(x1 + 0.5);
  xpxl1 := xend;
  ypxl1 := floor(yend);
  plot(xpxl1, ypxl1, rfrac(yend) * xgap);
  plot(xpxl1, ypxl1 + 1, frac(yend) * xgap);
  intery := yend + gradient;

  xend := round(x2);
  yend := y2 + gradient * (xend - x2);
  xgap := frac(x2 + 0.5);
  xpxl2 := xend;
  ypxl2 := floor(yend);
  plot(xpxl2, ypxl2, rfrac(yend) * xgap);
  plot(xpxl2, ypxl2 + 1, frac(yend) * xgap);

  for x := round(xpxl1) + 1 to round(xpxl2) - 1 do
  begin
    plot(x, floor(intery), rfrac(intery));
    plot(x, floor(intery) + 1, frac(intery));
    intery := intery + gradient;
  end;

end;

// Use sample

procedure TForm1.FormCreate(Sender: TObject);
begin
  Canvas.Brush.Style := bsSolid;
  Canvas.Brush.Color := clWhite;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Canvas.FillRect(ClientRect);
  DrawAntialisedLine(Canvas, Width div 2, Height div 2, X, Y, clBlack);
end;

Delphi相关代码片段

delphi array count

delphi string replace

create text file delphi

how to pull date from the system in delphi

delphi replace string

Creating a funstion in Delphi

Createing a procedure in delphi

how to install pip in python 3.9 windows 10

remove escapes from json

add data to json object

mongoose schema type double

"nickolasmin"

css social code bootstrap 4

bootstrap cards with image on the right side

download jupyter for linux

react replace object in array

bootstrap display error message

how write pi in delphi

bootstrap animated alerts

types of message box C#

eval javascipt

delphi if statement

delphi random letter

set vfat label

how to insert apostrophe in delphi string

remove unnecessary packages raspi pixel

breakpoint condition delphi

Shuffle list and print

hello world in delphi

how to make a shape move in delphi

free array Delphi 7

delphi check if key pressed is enter

delphi draw antialiased line

how to deacrease Time in delphi

INSERT into syntax error in delphi

duplicate ' in string delphi

delphi dynamic array count

delphi keypress ctrl+v

delphi calculator

delphi copiarcaracter string

delphi constant record

delphi basics const of record

choose character from string in delphi

delphi Tidhttp error could

password in delphi edit

fastreport mask text

"fastreport" "format" "text"

"fastreport" format field text

fastreport formating cpf

how to add item to listview delphi

firedac indexfieldnames

firedac sort

delphi firedac sort

firedac order by

get time in milliseconds delphi

delphi fullscreen

inputbox delphi

copy function delphi

delphi array

Delphi how copy works

length of string in delphi

belle delphine

delphi basics generating random number

get current date delphi

get last element of array delphi