D
dhjs
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟刚开始学delphi,有些问题请教,
procedure TForm1.Button1Click(Sender: TObject);
var
n,k,p,t:integer;
xt,yt:real;
const
pi:real=3.14159;
begin
n:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
p:=strtoint(edit3.Text);
with Image1 do
begin
canvas.pen.Color:=clred;
canvas.pen.Width:=3;
canvas.MoveTo(18,height-15);
canvas.LineTo(round((width-30)*(180-Trunc(140/n/k))/360),height-15);
for t:=0 to 10000*Trunc(140/n/k*round(width-30)/360) do
begin
xt:=t/10000;
yt:=p*10*(1-cos(pi*xt/trunc(140/n/k*360/round(width-30))))/2;
canvas.Pixels[round(t/10000+(width-30)*(180-Trunc(140/n/k))/360),height-15-round(yt)]:=clred;
end;
end;
Image1.canvas.pen.Width:=3;
Image1.canvas.MoveTo(trunc((width-30)/2),trunc(height-15-p*10));
Image1.canvas.LineTo(trunc((width-30)/2+round((180-Trunc(140/n/k))/360)),trunc(height-15-p*10)); [red]// 此处无法执行在Image1上,[/red]
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
var
n,k,p,t:integer;
xt,yt:real;
const
pi:real=3.14159;
begin
n:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
p:=strtoint(edit3.Text);
with Image1 do
begin
canvas.pen.Color:=clred;
canvas.pen.Width:=3;
canvas.MoveTo(18,height-15);
canvas.LineTo(round((width-30)*(180-Trunc(140/n/k))/360),height-15);
for t:=0 to 10000*Trunc(140/n/k*round(width-30)/360) do
begin
xt:=t/10000;
yt:=p*10*(1-cos(pi*xt/trunc(140/n/k*360/round(width-30))))/2;
canvas.Pixels[round(t/10000+(width-30)*(180-Trunc(140/n/k))/360),height-15-round(yt)]:=clred;
end;
end;
Image1.canvas.pen.Width:=3;
Image1.canvas.MoveTo(trunc((width-30)/2),trunc(height-15-p*10));
Image1.canvas.LineTo(trunc((width-30)/2+round((180-Trunc(140/n/k))/360)),trunc(height-15-p*10)); [red]// 此处无法执行在Image1上,[/red]
end;
end.