Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
Delphi 10.4 Sydney
|
AW: TLine - Canvas an Line ausrichten
6. Mär 2013, 19:55
Ja, das ist klar (Siehe OffSet1 und OffSet2). Typen hab ich auch schon (hab ich in der Paint jetzt weggelassen).
Delphi-Quellcode:
TLineStyle = (lsTop, lsBottom, lsLeft, lsRight,
lsTopLeft, lsTopRight, lsBottomLeft, lsBottomRight,
lsTopLeftBottomRight, lsTopRightBottomLeft);
procedure TLine.Paint;
var
X1, Y1, X2, Y2: Integer;
begin
with Canvas do
begin
Pen := FPen;
X1 := 0;
Y1 := 0;
X2 := Width;
Y2 := Height;
if X2 < 0 then
begin
Dec(X1, OffSet2);
Inc(X2, OffSet1);
end
else
begin
Inc(X1, OffSet1);
Dec(X2, OffSet2);
end;
if Y2 < 0 then
begin
Dec(Y1, OffSet2);
Inc(Y2, OffSet1);
end
else
begin
Inc(Y1, OffSet1);
Dec(Y2, OffSet2);
end;
case FStyle of
lsTop, lsLeft, lsTopRight, lsBottomLeft, lsTopLeftBottomRight:
MoveTo(X1, Y1);
lsRight, lsTopLeft, lsBottomRight, lsTopRightBottomLeft:
MoveTo(X2, Y1);
lsBottom:
MoveTo(X1, Y2);
end;
case FStyle of
lsTopLeft:
LineTo(X1, Y1);
lsTopRight:
LineTo(X2, Y1);
lsBottomLeft:
LineTo(X1, Y2);
lsBottomRight:
LineTo(X2, Y2);
end;
case FStyle of
lsTop:
LineTo(X2, Y1);
lsLeft, lsTopLeft, lsBottomRight, lsTopRightBottomLeft:
LineTo(X1, Y2);
lsBottom, lsRight, lsTopRight, lsBottomLeft, lsTopLeftBottomRight:
LineTo(X2, Y2);
end;
end;
end;
Das Problem ist aber ein anderes. Ich mu0 hier genau zeichen. Ich will ja eine Line von z.B. P1 nach P2 haben und nicht von P1 + Offset nach P2 - Offset?
|