| Цитата(bems @ 5.9.2015, 21:45) | как-то так?
| Код | unit Unit28;
interface
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type TForm28 = class(TForm) img: TImage; procedure FormResize(Sender: TObject); procedure imgMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); strict private const EllipceBounds: TRect = (Left: 100; Top: 150; Right: 400; Bottom: 600); public { Public declarations } end;
var Form28: TForm28;
implementation
uses Math;
{$R *.dfm}
procedure TForm28.FormResize(Sender: TObject); begin img.Picture.Bitmap.SetSize(img.Width, img.Height); img.Canvas.Ellipse(EllipceBounds) end;
procedure TForm28.imgMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var pt: TPoint; Alpha: Extended; begin if ssLeft in Shift then begin pt := Point(X, Y) - EllipceBounds.CenterPoint; pt.Y := Round(pt.Y * (EllipceBounds.Width / EllipceBounds.Height)); Alpha := Arctan2(pt.Y, pt.X); pt.X := Round(Cos(Alpha) * (EllipceBounds.Width / 2)); pt.Y := Round(Sin(Alpha) * (EllipceBounds.Height / 2)); pt := pt + EllipceBounds.CenterPoint; img.Canvas.MoveTo(pt.X, pt.Y); img.Canvas.LineTo(X, Y); end; end;
end.
|
|
Мне казалось что можно было все сделать попроще... Но похоже что нет. Спасибо )) |