OAIP/window/L8.cpp

194 lines
4.4 KiB
C++
Raw Normal View History

#include "L8.h"
#define SIN(x) sin(M_PI*x/180)
#define COS(x) cos(M_PI*x/180)
#define ATAN(y,x) atan2f(y,x)/M_PI*180
#define LLL(x,y) sqrt(pow(x,2) + pow(y,2))
void L8_christmas_tree(HDC hdc, int x, int y) {
};
void L8_logo(HDC hdc, int x, int y) {
SelectObject(hdc, GetStockObject(NULL_PEN));
SelectObject(hdc, CreateSolidBrush(RGB(0, 0, 0)));
Ellipse(hdc, x, y, x + 150, y + 150);
SelectObject(hdc, GetStockObject(DC_BRUSH));
Ellipse(hdc, x + 30, y + 30, x + 120, y + 120);
SelectObject(hdc, CreateSolidBrush(RGB(1, 99, 171)));
Pie(hdc, x + 30, y + 30, x + 120, y + 120, x + 75, y, x, y + 75);
Pie(hdc, x + 30, y + 30, x + 120, y + 120, x + 75, y + 120, x + 120, y + 75);
SelectObject(hdc, GetStockObject(DC_BRUSH));
SelectObject(hdc, CreatePen(BS_SOLID, 3, RGB(255, 255, 255)));
POINT M[5];
M[0] = { x + 75 - 10,y + 30 - 5 };
M[1] = { x + 75 - 10,y + 5 };
M[2] = { x + 75,y + 15 };
M[3] = { x + 75 + 10,y + 5 };
M[4] = { x + 75 + 10,y + 30 - 5 };
/*for (int i = 0; i < 5; i++) {
float L = sqrt(pow(x + 75 - M[i].x, 2) + pow(y + 75 - M[i].y, 2));
float ang = (float)ATAN(y + 75 - M[i].y, x + 75 - M[i].x) + 35;
M[i].x = x + 75 + (float)L * COS(ang);
M[i].y = y + 75 - (float)L * SIN(ang);
}*/
Polyline(hdc, M, 5);
int ALPHA = 35;
POINT W[5];
W[0] = { x + 75 - 10,y + 5 };
W[1] = { x + 75 - 10,y + 30 - 5 };
W[2] = { x + 75,y + 15 };
W[3] = { x + 75 + 10,y + 30 - 5 };
W[4] = { x + 75 + 10,y + 5 };
for (int i = 0; i < 5; i++) {
float L = sqrt(pow(x + 75 - W[i].x, 2) + pow(y + 75 - W[i].y, 2));
float ang = (float)ATAN(y + 75 - W[i].y, x + 75 - W[i].x) - ALPHA;
W[i].x = x + 75 + (float)L * COS(ang);
W[i].y = y + 75 - (float)L * SIN(ang);
}
Polyline(hdc, W, 5);
POINT B[2];
B[0] = { x + 75 - 10,y + 5 };
B[1] = { x + 75 - 10,y + 30 - 5 };
int xc = x + 75, yc = y + 75;
int shag = 5;
POINT Bprev = B[0];
for (int i = 0; i < 180; i += shag) {
float x2, y2;
float L1, ang1, L2, ang2;
L1 = LLL(Bprev.x - xc, Bprev.y - yc);
ang1 = ATAN((Bprev.y-yc), (Bprev.x-xc)) - ALPHA;
//MoveToEx(hdc, Bprev.x, Bprev.y, NULL);
x2 = (float)B[0].x + 20 * SIN((i + shag));
y2 = (float)B[0].y + 5 - 5 * COS((i + shag));
L2 = LLL((x2 - xc), (y2 - yc));
ang2 = ATAN((y2-yc), (x2-xc)) - ALPHA;
Bprev.x = x2;
Bprev.y = y2;
//LineTo(hdc, Bprev.x, Bprev.y);
MoveToEx(hdc, xc + L1 * COS(ang1), yc + L1 * SIN(ang1), NULL);
LineTo(hdc, xc + L2 * COS(ang2), yc + L2 * SIN(ang2));
}
for (int i = 0; i < 180; i += shag) {
float x2, y2;
float L1, ang1, L2, ang2;
L1 = LLL(Bprev.x - xc, Bprev.y - yc);
ang1 = ATAN((Bprev.y - yc), (Bprev.x - xc)) - ALPHA;
//MoveToEx(hdc, Bprev.x, Bprev.y, NULL);
x2 = (float)B[0].x + 20 * SIN((i + shag));
y2 = (float)B[0].y + 15 - 5 * COS((i + shag));
L2 = LLL((x2 - xc), (y2 - yc));
ang2 = ATAN((y2 - yc), (x2 - xc)) - ALPHA;
Bprev.x = x2;
Bprev.y = y2;
//LineTo(hdc, Bprev.x, Bprev.y);
MoveToEx(hdc, xc + L1 * COS(ang1), yc + L1 * SIN(ang1), NULL);
LineTo(hdc, xc + L2 * COS(ang2), yc + L2 * SIN(ang2));
}
for (int i = 0; i < 2; i++) {
float L = LLL((xc - B[i].x), (yc - B[i].y));
float ang = (float)ATAN((B[i].y - yc), (B[i].x - xc)) - ALPHA;
B[i].x = xc + (float)L * COS(ang);
B[i].y = yc + (float)L * SIN(ang);
}
MoveToEx(hdc, B[0].x, B[0].y, NULL);
LineTo(hdc, B[1].x, B[1].y);
/*for (int i = 0; i <= 180; i += 5) {
MoveToEx(hdc, Bprev.x, Bprev.y, NULL);
POINT Bend = { B[0].x + 20 * SIN(i), B[0].y + 15 - 5 * COS(i) };
LineTo(hdc, Bend.x, Bend.y);
Bprev = { Bend.x,Bend.y };
}*/
}
void StClausAuto(HDC hdc, int x, int y) {
MoveToEx(hdc, x+20, y, NULL);
LineTo(hdc, x+30, y+20);
LineTo(hdc, x+10, y+20);
LineTo(hdc, x+20, y);
MoveToEx(hdc, x+20, y+10, NULL);
LineTo(hdc, x+30, y+40);
LineTo(hdc, x+10, y+40);
LineTo(hdc, x+20, y+10);
MoveToEx(hdc, x+20, y+30, NULL);
LineTo(hdc, x+40, y+80);
LineTo(hdc, x, y+80);
LineTo(hdc, x+20, y+30);
}
void pattern1(HDC hdc, void (*f)(HDC, int, int)) {
f(hdc, 0, 0);
f(hdc, 625, 0);
f(hdc, 300, 300);
f(hdc, 0, 600);
f(hdc, 625, 600);
};
void pattern2(HDC hdc, void (*f)(HDC, int, int)) {
int x = 0;
while (x <= 625) {
f(hdc, x, 0);
x += 200;
}
};
void pattern3(HDC hdc, void (*f)(HDC, int, int)) {
int y = 0;
while (y <= 625) {
f(hdc, 0, y);
y += 200;
}
};
void pattern4(HDC hdc, void (*f)(HDC, int, int)) {
int y = 0;
int x = 0;
while (y <= 625) {
f(hdc, x, y);
y += 200;
x += 200;
}
};