//
Форма в виде звезды
// Unit1.cpp
//--------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1
*Form1;
//--------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent*
Owner)
:
TForm(Owner)
{
}
//--------------------------------------------------------------
int __fastcall Sin(int a, int
R)
{
double
W=36*3.14159265/180.0; return
R*sin(W*a);
}
int __fastcall
Cos(int a, int
R)
{
double
W=36*3.14159265/180.0; return
R*cos(W*a);
}
HRGN __fastcall
GetStarReg(int X, int Y, int
R)
{
TPoint P[5];
P[0]=Point(X,
Y-R);
P[1]=Point(X-Sin(4, R), Y-Cos(4, R));
P[2]=Point(X-Sin(8, R), Y-Cos(8, R));
P[3]=Point(X-Sin(2,
R), Y-Cos(2, R));
P[4]=Point(X-Sin(6, R), Y-Cos(6,
R));
return CreatePolygonRgn(P,
5, WINDING);
}
void
__fastcall TForm1::FormCreate(TObject *Sender)
{
int X=Width/2, Y=Height/2;
HRGN
R1, R2, R;
R=GetStarReg(X, Y, 100);
for(int i=1;i<10;i+=2)
{
R1=GetStarReg(X-Sin(i, 120), Y-Cos(i, 110),
40);
CombineRgn(R, R, R1,
RGN_OR);
}
R1=GetStarReg(X, Y,
30);
CombineRgn(R, R, R1, RGN_DIFF);
R1=CreateEllipticRgn(3, 3, Width-6, Height-6);
R2=CreateEllipticRgn(20, 10, Width-20, Height-10);
CombineRgn(R1, R1,R2, RGN_DIFF);
CombineRgn(R, R, R1,
RGN_OR);
SetWindowRgn(Handle, R,
TRUE);
}
//-------------------------------------------------------------- |
|
|