.


:




:

































 

 

 

 


anvas




Tanvas, , , Image, PaintBox, ( GDI Windows) . . . , Y .

Image Additional, PaintBox System.

Canvas:

Pen ( ),

Brush ( ),

Font ( ).

Canvas:

Ellipse ( 1, 1, 2, 2) ( 1, 1), ( 2, 2) ;

MoveTo (, y) (, y);

LineTo (, y) (, y);

Rectangle ( 1, 1, 2, 2) ( 1, 1), ( 2, 2). FrameRect Polyline;

Polygon (const TPoint* Points, const int Points_Size) , ints Points_Size. . Polyline.

TextOut (, , const AnsiString Text) t , , , (, ).

 

hart Image.

. 9.2.

. 9.2

 

, , :

...

//---------------------------------------------------------------------------

double a,b,h,y_min,y_max;

int n;

typedef double (*Tfun)(double);

Tfun f;

double fun0(double);

double fun1(double);

double fun2(double);

//----------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

Edit1->Text="-3,1416"; // a

Edit2->Text="3,1416"; // b

Edit3->Text="50"; // n

RadioGroup1->ItemIndex = 0;

}


//----------------- ------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

double x, r;

a=StrToFloat(Edit1->Text);

b=StrToFloat(Edit2->Text);

n=StrToInt(Edit3->Text);

h = (b-a)/n;

switch(RadioGroup1->ItemIndex) {

case 0: f = fun0; break;

case 1: f = fun1; break;

case 2: f = fun2; break;

}

y_min = y_max = f(a);

for (x = a+h; x<=b; x+=h) {

r = f(x);

if(y_min>r) y_min = r;

if(y_max<r) y_max = r;

}

}

//------------------------ Chart ----------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

Chart1->Series[0]->Clear(); //

for(double x=a; x<=b; x+=h)

Chart1->Series[0]->AddXY(x,f(x));

}

//--------------------- ----------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)

{

Chart1->CopyToClipboardMetafile(True);

}

//--------------------- Image ---------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)

{

int xmax, ymax, xt, yt, y0, x0;

double hx,hy,x;

Image1->Canvas->Pen->Color=clBlack; //

// Image

xmax = Image1->Width; ymax = Image1->Height;

// Image

Image1->Canvas->Rectangle(0,0,xmax,ymax);

//

y0=ymax/2; x0=xmax/2;

//

Image1->Canvas->MoveTo(0,y0);

Image1->Canvas->LineTo(xmax,y0);

Image1->Canvas->MoveTo(x0,0);

Image1->Canvas->LineTo(x0,ymax);

Image1->Canvas->Pen->Color=clRed; //

Image1->Canvas->Pen-> //

//

hx=(b-a)/xmax; hy=(y_max-y_min)/ymax;

Image1->Canvas->MoveTo(ceil(x0+a/hx),ceil(y0-f(a)/hy));

for(x=a; x<=b; x+=h)

Image1->Canvas->LineTo(ceil(x0+x/hx),ceil(y0-f(x)/hy));

}

//------------------------------------------------------------

double fun0(double r) {

return sin(r);

}

double fun1(double r) {

return r*r;

}

double fun2(double r) {

return r*r*r;

}

 

 

( 3) Y (x) S (x) x, a b h ( ) hart Y (x) Image.


1





:


: 2018-10-15; !; : 235 |


:

:

, .
==> ...

1652 - | 1473 -


© 2015-2024 lektsii.org - -

: 0.009 .