// Triplicate Curve
Int drawthreesnailcurve (Graphics * GRP, int * ctrlpoint)
{
Pen (color (255, 0, 255, 0), 1 );
Point P [] = {point (200,150), // P
Point (ctrlpoint [0], ctrlpoint [1]), point (200,100 ),
Point (100,100), // P
Point (ctrlpoint [1], ctrlpoint [3]), point (200,100 ),
Point (300,200), // P
Point (ctrlpoint [2], ctrlpoint [5]), point (200,200 ),
Point (200,150), // P
Point (ctrlpoint [6], ctrlpoint [7]), point (200,250 ),
Point (300,250), // P
Point (ctrlpoint [8], ctrlpoint [9]), point (200,150 ),
Point (50,150), // P
Point (ctrlpoint [10], ctrlpoint [11]), point (300,160 ),
Point (700,500), // P
Point (ctrlpoint [12], ctrlpoint [13]), point (700,200 ),
Point (600,200), // P
Point (ctrlpoint [14], ctrlpoint [15]), point (800,655 ),
Point (800,600), // P
Point (ctrlpoint [16], ctrlpoint [17]), point (300,240 ),
Point (250,240), // P
};
Float zstep = 0.0f;
For (INT I = 0; I <10; I ++ ){
GRP-> translatetransform (0.0f, zstep );
GRP-> drawbeziers (& pen, P, 28 );
Zstep + = 3.0f;
}
Return 0;
}
Int CP [56];
Rect drawrect;
Rect specrect;
// Functions that I often use in winapi are worth encapsulation. Because always calls
Time_t fstime = 0;
Time_t frtime = 0;
Struct TM * fpstime = 0;
Struct TM * fprtime = 0;
Int fistime = 0; // start time
Int firtime = 0; // Real-Time
// Obtain the first time
Int getinittime ()
{
Time (& fstime );
Fpstime = localtime (& fstime );
Fistime = fpstime-> tm_sec;
Return 0;
}
// Real-time call
Int Runtime ()
{
Time (& frtime );
Fprtime = localtime (& frtime );
Firtime = fprtime-> tm_sec;
Return 0;
}
// Initialize the paint brush
Int initgdi ()
{
HDC = getdc (hwnd );
Hpen = createpen (ps_dot, 2, RGB (255, 0 ));
SelectObject (HDC, Hpen );
Getwindowrect (hwnd, & rect );
For (INT I = 0; I <56; I ++)
CP [I] = 0;
CP [0] = 200; CP [1] = 150;
CP [2] = 200; CP [3] = 200;
CP [4] = 300; CP [5] = 200;
CP [6] = 200; CP [7] = 150;
CP [8] = 200; CP [9] = 250;
CP [10] = 50; CP [11] = 250;
CP [12] = 700; CP [13] = 500;
CP [14] = 500; CP [15] = 250;
CP [16] = 400; CP [17] = 600;
Fig. Left =-100;
Fig. Right = 2048;
Drawrect. Top =-100;
Drawrect. Bot = 1024;
// Range of special control points on the right
Specrect. Left =-1024;
Specrect. Right = 1100;
Specrect. Top =-500;
Specrect. Bottom = 1024;
Getinittime ();
Return 0;
}
Const int rstep = 10;
Int raspectx0 = rstep;
Int raspecty0 = rstep;
Int raspectx1 =-rstep;
Int raspecty1 = rstep;
Int raspectx2 = rstep;
Int raspecty2 =-rstep;
Int raspectx3 =-rstep;
Int raspecty3 =-rstep;
Int raspectx4 = rstep;
Int raspecty4 = rstep;
Int raspectx5 = rstep;
Int raspecty5 = rstep;
Int raspectx6 = rstep;
Int raspecty6 = rstep;
Int raspectx7 = rstep;
Int raspecty7 = rstep;
Int raspectx8 = rstep;
Int raspecty8 = rstep;
// Random Control Point Range
Int rrcrangex0 = 2048;
Int rcrangex1 =-100;
Int crny0 =-100;
Int crny1 = 1024;
Int crnx2 = 2048;
Int crnx3 =-100;
Int crnx4 = 2048;
Int crnx5 =-100;
Int crnx6 = 2048;
Int crnx7 =-100;
Int crnx8 = 2048;
Int crnx9 =-100;
Int crnx10 = 2048;
Int crnx11 =-100;
Int crnx12 = 2048;
Int crnx13 =-100;
Int crnx14 = 2048;
Int crnx15 =-100;
Int crnx16 = 2048;
Int crnx17 =-100;
Int crny2 =-100;
Int crny3 = 1024;
Int crny4 =-100;
Int CRC 5 = 1024;
Int crny6 =-100;
Int crny7 = 1024;
Int crny8 =-100;
Int crny9 = 1024;
Int crny10 =-100;
Int crny11 = 1024;
Int crny12 =-100;
Int crny13 = 1024;
Int crny14 =-100;
Int crny15 = 1024;
Int crny16 =-100;
Int crny17 = 1024;
Char szmsg [max_path];
Wchar_t szmulb [max_path];
Int makepoint ()
{
Rcrangex0 = rand () %2000;
Rcrangex1 = rand () %2000;
Crny0 = rand () %1024;
Crny1 = rand () %1024;
Crnx2 = rand () %2000;
Crnx3 = rand () %2000;
Crny2 = rand () %1024;
Crny3 = rand () %1024;
Crnx4 = rand () %2000;
Crnx5 = rand () % 2000;
Crny4 = rand () %1024;
Crnx5 = rand () % 1024;
Crnx6 = rand () % 2000;
Crnx7 = rand () % 2000;
Crny6 = rand () %1024;
Crny7 = rand () %1024;
Crnx8 = rand () %2000;
Crny9 = rand () %2000;
Crny8 = rand () %1024;
Crny9 = rand () %1024;
Crnx10 = rand () %2000;
Crnx11 = rand () %2000;
Crny10 = rand () %1024;
Crny11 = rand () %1024;
Crnx12 = rand () %2000;
Crnx13 = rand () %2000;
Crnx14 = rand () %1024;
Crnx15 = rand () %1024;
Crnx16 = rand () %2000;
Crnx17 = rand () %2000;
Crny12 = rand () %1024;
Crny13 = rand () %1024;
Crny14 = rand () %2000;
Crny15 = rand () %2000;
Crny16 = rand () %1024;
Crny17 = rand () %1024;
If (ABS (rcrangex0-rcrangex1) <100 ){
Rcrangex1 = drawrect. Left;
Return 0;
}
If (ABS (crnx2-crnx3) <100 ){
Crnx3 = drawrect. Left;
Return 0;
}
If (ABS (crnx4-crnx5) <100 ){
Crnx5 = drawrect. Left;
Return 0;
}
If (ABS (crnx6-crnx7) <100 ){
Crny7 = drawrect. Left;
Return 0;
}
If (ABS (crnx8-crnx9) <100 ){
Crnx9 = drawrect. Left;
Return 0;
}
If (ABS (crnx10-crnx11) <100 ){
Crnx11 = drawrect. Left;
Return 0;
}
If (ABS (crnx12-crnx13) <100 ){
Crnx13 = drawrect. Left;
Return 0;
}
If (ABS (crnx14-crnx15) <100 ){
Crnx15 = drawrect. Left;
Return 0;
}
If (ABS (crnx16-crnx17) <100 ){
Crnx17 = drawrect. Left;
Return 0;
}
If (ABS (crny6-crny7) <100 ){
Crny7 = drawrect. Top;
Return 0;
}
If (ABS (crny8-crny9) <100 ){
Crny9 = drawrect. Top;
Return 0;
}
If (ABS (crny10-crny11) <100 ){
Crny11 = drawrect. Top;
Return 0;
}
If (ABS (crny12-crny13) <100 ){
Crny13 = drawrect. Top;
Return 0;
}
If (ABS (crny14-crny15) <100 ){
Crny15 = drawrect. Top;
Return 0;
}
If (ABS (crny16-crny17) <100 ){
Crny17 = drawrect. Top;
Return 0;
}
If (ABS (crny0-crny1) <100 ){
Crny1 = drawrect. Top;
Return 0;
}
If (ABS (cRnY2-cRnY3)> 400 ){
Crny3 = drawrect. Top;
Return 0;
}
If (ABS (cRnY4-cRnY5)> 400 ){
Crny5 = drawrect. Top;
Return 0;
}
Return 0;
}
Int drawfivesnail ()
{
// Generate a random number at a specified interval
Runtime ();
Wsprintf (szmulb, l "% d", firtime, fistime );
Textout (HDC, 0, 0, szmulb, (INT) wcslen (szmulb ));
If (ABS (firtime-fistime)> = 2)
{
Fistime = firtime;
Makepoint ();
}
Graphics graphic (HDC );
If (CP [1]> crny0 | CP [1] <crny1 ){
Raspecty0 =-raspecty0;
}
If (CP [0]> rcrangex0 | CP [0] <rcrangex1 ){
Raspectx0 =-raspectx0;
}
// Control Point 2
If (CP [3]> crny2 | CP [3] <crny3 ){
Raspecty1 =-raspecty1;
}
If (CP [2] <crnx2 | CP [2]> crnx3 ){
Raspectx1 =-raspectx1;
}
// Control Point 3
If (CP [5]> crny4 | CP [5] <crny5 ){
Raspecty2 =-raspecty2;
}
If (CP [4]> crnx4 | CP [4] <crnx5 ){
Raspectx2 =-raspectx2;
}
// Control Point 4
If (CP [7]> crny6 | CP [7] <crny7 ){
Raspecty3 =-raspecty3;
}
If (CP [6]> crnx6 | CP [6] <crnx7 ){
Raspectx3 =-raspectx3;
}
// Control Point 5
If (CP [8]> crny8 | CP [8] <crny9 ){
Raspectx4 =-raspectx4;
}
If (CP [9]> crnx8 | CP [9] <crnx9 ){
Raspecty4 =-raspecty4;
}
// Control Point 6
If (CP [11]> crny10 | CP [11] <crny11 ){
Raspecty5 =-raspecty5;
}
If (CP [10]> crnx10 | CP [10] <crnx11 ){
Raspectx5 =-raspectx5;
}
// * Indicates a Special Control Point
// Control Point 7 -*
If (CP [13]> crny12 | CP [13] <crny13 ){
Raspecty6 =-raspecty6;
}
If (CP [12]> crnx12 | CP [12] <crnx13 ){
Raspectx6 =-raspectx6;
}
// Control Point 8 -*
If (CP [15]> crny14 | CP [15] <crny15 ){
Raspecty7 =-raspecty7;
}
If (CP [14]> crnx14 | CP [14] <crnx15 ){
Raspectx7 =-raspectx7;
}
// Control Point 9 -*
If (CP [17]> crny16 | CP [17] <crny17 ){
Raspecty8 =-raspecty8;
}
If (CP [16]> crnx16 | CP [16] <crnx17 ){
Raspectx8 =-raspectx8;
}
// Increment
CP [0] + = raspectx0;
CP [1] + = raspecty0;
CP [2] + = raspectx1;
CP [3] + = raspecty1;
CP [4] + = raspectx2;
CP [5] + = raspecty2;
CP [6] + = raspectx3;
CP [7] + = raspecty3;
CP [8] + = raspectx4;
CP [9] + = raspecty4;
CP [10] + = raspectx5;
CP [11] + = raspecty5;
CP [12] + = raspectx6;
CP [13] + = raspecty6;
CP [14] + = raspectx7;
CP [15] + = raspecty7;
CP [16] + = raspectx8;
CP [17] + = raspecty8;
Drawthreesnailcurve (& Graphic, CP );
Invalidaterect (hwnd, & rect, true );
Return 0;
}
Int render ()
{
Drawfivesnail ();
Sleep (5 );
Return 0;
}