TForm1 = class(TForm)
BGRAVirtualScreen1: TBGRAVirtualScreen;
procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
procedure FormCreate(Sender: TObject);
private
points: array of TPointF;
arr: array of TPointF = nil;
procedure DrawChart(Bitmap: TBGRABitmap);
procedure DrawChart2(Bitmap: TBGRABitmap);
public
end;
procedure TForm1.FormCreate(Sender: TObject);
const
range = 2*pi;
var
x: single;
i, n: integer;
kx, ky: double;
range: double;
x0: single;
begin
SetLength(points, cnt+1);
for i:= 0 to cnt do
begin
x:= range*i/cnt;
points[i].x:= x;
points[i].y:= sin(x) + (random-0.5)/5;
end;
n:= Length(points);
range:= points[n-1].x - points[0].x;
kx:= R.Width/range;
ky:= R.Height/3;
x0:= points[0].x;
SetLength(arr, n);
for i:=0 to n-1 do
arr[i]:= PointF(border + (points[i].x - x0)*kx, border + (1.5 - points[i].y)*ky);
end;
procedure TForm1.DrawChart2(Bitmap: TBGRABitmap);
const
border = 20;
var
R: TRect;
begin
R:= Rect(border, border, Bitmap.Width-border, Bitmap.Height - border);
Bitmap.Canvas2D.strokeStyle(clBlack);
Bitmap.Canvas2D.beginPath;
Bitmap.Canvas2D.polylineTo(arr);
Bitmap.Canvas2D.stroke;
end;