-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit1.cpp
154 lines (140 loc) · 3.64 KB
/
Unit1.cpp
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
unsigned long tim;
int level;
int phs;
float e=2.7182;
bool start_fill=false;
bool start_sink=false;
bool on1=false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
level=Path1->Height;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::set_level(TPath * pth, int lvl)
{
pth->Data->Clear();
pth->Data->MoveTo(TPointF(0,pth->Height));
pth->Data->LineTo(TPointF(0,0));
pth->Data->LineTo(TPointF(0,lvl));
//-------------------------------------------
for (int i=0; i <(int) pth->Width; i++) {
pth->Data->LineTo(TPointF(i,lvl+5*sin(3*i*3.1415/180 + phs*3.1415/180)));
}
//-------------------------------------------
pth->Data->LineTo(TPointF(pth->Width,lvl));
pth->Data->LineTo(TPointF(pth->Width,0));
pth->Data->LineTo(TPointF(pth->Width,pth->Height));
pth->Data->ClosePath();
phs+=10;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
tim++;
if (Path1->Height- level>=Rectangle5->Position->Y)
{
on1=false;
Rectangle4->Fill->Color=0xffffffff;
}
else
{
Rectangle4->Fill->Color=0xffff0000;
}
if (Path1->Height- level<Rectangle4->Position->Y)
{
on1=true;
Rectangle5->Fill->Color=0xffff0000;
}
else
{
Rectangle5->Fill->Color=0xffffffff;
}
if (on1==true)
{
if (start_fill==true) {
level--;
if (level<0) {
level=0;
}
}
if (level>0) {
create_point(Form1,Path1);
}
}
else
{
start_fill=false;
}
if (start_sink==true) {
level++;
}
if (level<Path1->Height-3) {
set_level(Path1,level);
}
move_point(Path1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::create_point(TComponent* Owner,TPath * pth)
{
for (int i=0; i<4; i++)
{
TCircle * c=new TCircle(Owner);
c->Position->Point=TPointF(0,0);
c->Width=RandomRange(4,8);
c->Height=c->Width;
c->TagFloat=RandomRange(pth->Width/4,pth->Width/2);
c->Tag=tim;
c->Fill->Color=0xFF6BB8F7;
c->Stroke->Kind=0;
pth->AddObject(c);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::move_point(TPath * pth)
{
for (int i=0; i<pth->Children->Count; i++) {
TCircle * c= (TCircle *) pth->Children->Items[i];
if (c->ClassName()=="TCircle") {
float f=1/ (float)(tim-c->Tag);
f=(1-Power(e,f)/e);
f=c->TagFloat *f;
c->Position->X=f;
//Text1->Text=FloatToStrF(f,ffFixed,2,2)+" , "+FloatToStrF(c->TagFloat,ffFixed,2,2);
c->Opacity=c->Opacity-0.01;
c->Position->Y=c->Position->Y+5;
if (c->Position->Y>level) {
pth->RemoveObject(c);
c->DisposeOf();
start_fill=true;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//create_point(Form1,Path1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Switch1Switch(TObject *Sender)
{
if (Path1->Height- level<Rectangle5->Position->Y) {
on1=Switch1->IsChecked;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Switch2Switch(TObject *Sender)
{
start_sink=Switch2->IsChecked;
}
//---------------------------------------------------------------------------