procedure TForm4.Draw();// Функция рисования кривой
begin
var j := 0;
var step := 0.01; // Возьмем шаг 0.01 для большей точности
var res: TArray<TD2DPoint2f>;
SetLength(res, 101); //Конечный массив точек кривой
Series1.Clear; //<----------------------------------------------------------- Изменения 1
var t: Single := 0;
while t < 1 do
begin
t := t + step;
var ytmp := 0.0;
var xtmp := 0.0;
for var i := 0 to High(Arr) do
begin // проходим по каждой точке
var b := polinom(i, Length(Arr) - 1, t); // вычисляем наш полином Бернштейна
xtmp := xtmp + Arr[i].X * b; // записываем и прибавляем результат
ytmp := ytmp + Arr[i].Y * b;
end;
Series1.AddXY(xtmp, -ytmp, ''); //<------------------------------------- Изменения 2
res[j].x := xtmp;
res[j].y := ytmp;
Inc(j);
end;
with TDirect2DCanvas.Create(Canvas, ClientRect) do
try
BeginDraw;
for var i := 0 to High(res) - 1 do
DrawLine(res[i], res[i+1]);
EndDraw;
finally
Free;
end;
end;
object Chart1: TChart
Left = 416
Top = 64
Width = 400
Height = 250
Legend.Visible = False
Title.Text.Strings = (
'TChart')
Title.Visible = False
BottomAxis.Axis.Visible = False
LeftAxis.Axis.Width = 0
LeftAxis.Axis.Visible = False
Shadow.Visible = False
View3D = False
View3DWalls = False
Zoom.Animated = True
Zoom.Pen.Visible = False
BevelOuter = bvNone
Color = clWhite
TabOrder = 0
DefaultCanvas = 'TGDIPlusCanvas'
ColorPaletteIndex = 13
object Series1: THorizLineSeries
Brush.BackColor = clDefault
Dark3D = False
Pointer.HorizSize = 2
Pointer.InflateMargins = True
Pointer.Style = psCircle
Pointer.VertSize = 2
XValues.Name = 'X'
XValues.Order = loNone
YValues.Name = 'Y'
YValues.Order = loAscending
end
end
var a := [1, 2, 3, 4];
var b := [5, 6, 7, 8, 1];
var c: TArray<integer>;
SetLength(c, Max(Length(a), Length(b)));
for var i := 0 to High(c) do
if (i < Length(a)) and (i < Length(b)) then
c[i] := a[i] + b[i]
else if i < Length(a) then
c[i] := a[i]
else
c[i] := b[i];