.


:




:

































 

 

 

 


RoundRect(X1,Y1,X2,Y2)




 

. 璺 .

TPoint points[7];

points[0]=TPoint(0,0);

points[1]=TPoint(500,30);

points[2]=TPoint(0,40);

points[3]=TPoint(300,400);

points[4]=TPoint(200,200);

points[5]=TPoint(600,500);

points[6]=TPoint(0,550);

Canvas->PolyBezier(points,6);

 

. "C++ Builder" . ( OnResize) .

 

void __fastcall TForm1::FormPaint(TObject *Sender)

{

int X,Y;

Canvas->Brush->Color= clYellow;

Canvas->Ellipse(0,0,ClientWidth,ClientHeight);

Canvas->Font->Size = Height/8;

X=(ClientWidth-Canvas->TextWidth("C++ Builder"))/2;

Y=(ClientHeight-Canvas->TextHeight("C"))/2;

Canvas->TextOut(X,Y,"C++ Builder");

}

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

void __fastcall TForm1::FormResize(TObject *Sender)

{

//

Form1->Canvas->Brush->Color=Form1->Color;

Form1->Canvas->FillRect(Rect(0,0,ClientWidth,ClientHeight));

// FormPaint

FormPaint(Form1);

}

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

 

 

. y= [0,25].

. .

 

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

 

#include <vcl.h>

#pragma hdrstop

 

#include "Unit1.h"

#include <math.h>

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

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

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

// ,

float f(float x)

{

return 2*sin(x)*exp(x/5);

}

const char * FN="2*Sin(x)*exp(x/5)";

 

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

 

void __fastcall TForm1::FormPaint(TObject *Sender)

{

//

float x1,x2; //

float y1,y2; //

float x; //

float y; // x

float dx; //

int l,b; //

int w,h; //

int mx,my; // X Y

int x0,y0; // -

 

//

l=20; // X -

b=ClientHeight-20; // Y -

h=ClientHeight-40; //

w=ClientWidth-40; //

 

x1=0; //

x2=25; //

dx=0.01; //

 

//

// [x1,x2]

y1=f(x1); //

y2=f(x1); //

x=x1+dx;

do

{ y = f(x);

if (y < y1) y1=y;

if (y > y2) y2=y;

x=x+dx; }

while (x<=x2);

 

//

my=h/abs(y2-y1); // Y

mx=w/abs(x2-x1); // X

 

//

x0=l;

y0=b-abs(floor(y1*my));

// i

Canvas->Pen->Color=clGreen;

Canvas->MoveTo(l,b);Canvas->LineTo(l,b-h);

Canvas->MoveTo(x0,y0);Canvas->LineTo(x0+w,y0);

Canvas->TextOut(l+5,b-h,FloatToStrF(y2,ffFixed,6,2));

Canvas->TextOut(l+5,b,FloatToStrF(y1,ffFixed,6,2));

//

x=x1;

do

{ y=f(x);

Canvas->Pixels[x0+floor(x*mx)][y0-floor(y*my)]=clRed;

x=x+dx; }

while (x<=x2);

Canvas->Font->Color=clPurple;

Canvas->TextOut(l+40,y0+60,FN);

 

}

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

void __fastcall TForm1::FormResize(TObject *Sender)

{

//

Canvas->FillRect(Rect(0,0,ClientWidth,ClientHeight));

//

FormPaint(Form1);

}

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

 

 





:


: 2015-10-01; !; : 367 |


:

:

,
==> ...

1847 - | 1627 -


© 2015-2024 lektsii.org - -

: 0.011 .