1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, ValEdit, StdCtrls, Buttons, ExtCtrls, ClipBrd;
type TForm1 = class(TForm) GroupBox1: TGroupBox; ValueListEditor1: TValueListEditor; GroupBox2: TGroupBox; Image1: TImage; GroupBox3: TGroupBox; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure Image1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject); var x,y:integer; x4,x3,x2,x1,x0:real; z,dvx,dvy:real; f:boolean; begin if Length(ValueListEditor1.Strings[0])>4 THEN x4:=StrToFloat(Copy(ValueListEditor1.Strings[0], 5,Length(ValueListEditor1.Strings[0])-4)) else x4:=0; Form1.Caption:=FloatToStr(x4)+'x^4';
if Length(ValueListEditor1.Strings[1])>4 THEN x3:=StrToFloat(Copy(ValueListEditor1.Strings[1], 5,Length(ValueListEditor1.Strings[1])-4)) else x3:=0; Form1.Caption:=Form1.Caption+'+'+FloatToStr(x3)+'x^3';
if Length(ValueListEditor1.Strings[2])>4 THEN x2:=StrToFloat(Copy(ValueListEditor1.Strings[2], 5,Length(ValueListEditor1.Strings[2])-4)) else x2:=0; Form1.Caption:=Form1.Caption+'+'+FloatToStr(x2)+'x^2';
if Length(ValueListEditor1.Strings[3])>4 THEN x1:=StrToFloat(Copy(ValueListEditor1.Strings[3], 5,Length(ValueListEditor1.Strings[3])-4)) else x1:=0; Form1.Caption:=Form1.Caption+'+'+FloatToStr(x1)+'x^1';
if Length(ValueListEditor1.Strings[4])>4 THEN x0:=StrToFloat(Copy(ValueListEditor1.Strings[4], 5,Length(ValueListEditor1.Strings[4])-4)) else x0:=0; Form1.Caption:=Form1.Caption+'+'+FloatToStr(x0)+'x^0';
if Length(ValueListEditor1.Strings[5])>4 THEN dvx:=StrToFloat(Copy(ValueListEditor1.Strings[5], 5,Length(ValueListEditor1.Strings[5])-4)) else dvx:=1;
if Length(ValueListEditor1.Strings[6])>4 THEN dvy:=StrToFloat(Copy(ValueListEditor1.Strings[6], 5,Length(ValueListEditor1.Strings[6])-4)) else dvy:=1;
f:=false;
Image1.Picture := NIL; Image1.Canvas.Pen.Color:=$00FF00; Image1.Canvas.MoveTo(150,0); Image1.Canvas.LineTo(150,300); Image1.Canvas.MoveTo(0,150); Image1.Canvas.LineTo(300,150); for x:=-150 to 150 do begin z:=x / dvx; y:=trunc((x4*z*z*z*z+x3*z*z*z+x2*z*z+x1*z+x0) / dvy); if (y>=-150) and (y<=150) then begin Image1.Canvas.Pen.Color:=$FF0000; if f=false then Image1.Canvas.MoveTo(X+150,Y+150);f:=true;
Image1.Canvas.LineTo(X+150,Y+150); end; end; end;
procedure TForm1.Image1Click(Sender: TObject); var Bitmap: TBitmap; begin Bitmap:=Image1.Picture.Bitmap; try Clipboard.Assign(Bitmap); finally Bitmap.Free; end; end;
end. |