116 lines
2.2 KiB
C++
116 lines
2.2 KiB
C++
#include "Function.h"
|
|
|
|
void triangle(HDC hdc, int x, int y, COLORREF color) {
|
|
HPEN hpen = CreatePen(PS_SOLID, 2, color);
|
|
SelectObject(hdc, hpen);
|
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
POINT pt[3] = {
|
|
{x,y - 20},
|
|
{x + 20,y + 20},
|
|
{x - 20, y + 20}
|
|
};
|
|
|
|
Polygon(hdc, pt, 3);
|
|
|
|
DeleteObject(hpen);
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
SelectObject(hdc, GetStockObject(DC_BRUSH));
|
|
}
|
|
|
|
void arrow(HDC hdc, int x, int y, COLORREF color) {
|
|
HPEN hpen = CreatePen(PS_SOLID, 2, color);
|
|
SelectObject(hdc, hpen);
|
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
POINT pt[4] = {
|
|
{x, y},
|
|
{x + 20, y - 20},
|
|
{x, y + 20},
|
|
{x - 20, y - 20}
|
|
};
|
|
|
|
Polygon(hdc, pt, 4);
|
|
|
|
DeleteObject(hpen);
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
SelectObject(hdc, GetStockObject(DC_BRUSH));
|
|
}
|
|
|
|
void diamond(HDC hdc, int x, int y, COLORREF color) {
|
|
HPEN hpen = CreatePen(PS_SOLID, 2, color);
|
|
SelectObject(hdc, hpen);
|
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
POINT pt[4] = {
|
|
{x, y - 20},
|
|
{x + 20, y},
|
|
{x, y + 20},
|
|
{x - 20, y}
|
|
};
|
|
|
|
Polygon(hdc, pt, 4);
|
|
|
|
DeleteObject(hpen);
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
SelectObject(hdc, GetStockObject(DC_BRUSH));
|
|
}
|
|
|
|
void flag(HDC hdc, int x, int y, COLORREF color) {
|
|
HPEN hpen = CreatePen(PS_SOLID, 2, color);
|
|
SelectObject(hdc, hpen);
|
|
|
|
POINT pt[6] = {
|
|
{x - 20, y},
|
|
{x + 20, y},
|
|
{x, y - 10},
|
|
{x + 20, y - 20},
|
|
{x - 20, y - 20},
|
|
{x - 20, y + 20}
|
|
};
|
|
|
|
Polyline(hdc, pt, 6);
|
|
|
|
DeleteObject(hpen);
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
}
|
|
|
|
void crown(HDC hdc, int x, int y, COLORREF color) {
|
|
HPEN hpen = CreatePen(PS_SOLID, 2, color);
|
|
SelectObject(hdc, hpen);
|
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
POINT pt[5] = {
|
|
{x, y},
|
|
{x + 20, y - 20},
|
|
{x + 20, y + 20},
|
|
{x - 20, y + 20},
|
|
{x - 20, y - 20},
|
|
};
|
|
|
|
Polygon(hdc, pt, 5);
|
|
|
|
DeleteObject(hpen);
|
|
SelectObject(hdc, GetStockObject(DC_PEN));
|
|
SelectObject(hdc, GetStockObject(DC_BRUSH));
|
|
}
|
|
|
|
void pattern1(HDC hdc, void (*f)(HDC, int, int, COLORREF)) {
|
|
COLORREF colors[Length] = {
|
|
RGB(255,0,0),
|
|
RGB(0,255,0),
|
|
RGB(0,0,255),
|
|
RGB(255,0,255),
|
|
RGB(255,255,0)
|
|
};
|
|
POINT pt[Length] = {
|
|
{40,40},
|
|
{240,40},
|
|
{440,40},
|
|
{40,240},
|
|
{440,240}
|
|
};
|
|
for (int i = 0; i < Length; i++) {
|
|
(*f)(hdc, pt[i].x, pt[i].y, colors[i]);
|
|
}
|
|
} |