checkStatute(a:string)
{
let status = '';
for(let i = 0; i < item.length; i++)
{
if(item.every((e:item) => e.status === 'open'))
{
status = 'open';
console.log(status);
const element = <HTMLElement>document.getElementById(a);
return element.style.background = '#f4e800'
}
else if(item.every((e:item) => e.status === 'closed'))
{
status = 'closed';
console.log(status);
const element = <HTMLElement>document.getElementById(a);
return element.style.background = '#f64b25'
}
else
{
status = 'not all items has the same status';
console.log(status)
const element = <HTMLElement>document.getElementById(a);
return element.style.background = '#ff9900'
}
}
return 0;
}
#include <windows.h>
#include <math.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
POINT apt[4]; // define global variable
RECT r;
HINSTANCE hInst;
// control function:
int WINAPI WinMain(HINSTANCE hInst, // create copy of application descriptor
HINSTANCE hPrevInst, // define window class (don`t use)
LPSTR lpCmdLine, // create window, show on screen (don`t use)
int nCmdShow) // window show mode
{
TCHAR szClassName[] = L"My class"; // class name string
HWND hMainWnd; // create descriptor for window
MSG msg; // create copy of structure MSG for handle messages
WNDCLASSEX wc; // create copy, for acces member of class WNDCLASSEX
wc.cbSize = sizeof(wc); // structure size (in byte)
wc.style = CS_HREDRAW | CS_VREDRAW; // window class style
wc.lpfnWndProc = WndProc; // pointer to user function
wc.lpszMenuName = nullptr; // pointer to menu name
wc.lpszClassName = szClassName; // указатель на имя класса
wc.cbWndExtra = 0; // count of released byte in the end of structure
wc.cbClsExtra = 0; // count of released byte for copy of application
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); // program descriptor
wc.hIconSm = LoadIcon(nullptr, IDI_WINLOGO); // logo descriptor (for tray)
wc.hCursor = LoadCursor(nullptr, IDC_ARROW); // cursor descriptor
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // brush descriptor for paint background
wc.hInstance = hInst; // string pointer, which contain menu name, using for class
if (!RegisterClassEx(&wc)) {
// if don`t exist on class registration:
MessageBox(nullptr, L"Could not registrate the class!", L"Error", MB_OK);
return 1; // return - exit from WinMain
}
// function which create window:
HWND hWnd = CreateWindow(
szClassName, // class name
L"Curba Bezier", // window name
WS_OVERLAPPEDWINDOW, // window show mode
CW_USEDEFAULT, // window position х
NULL, // window position у (default is х, don`t need to write y)
CW_USEDEFAULT, // width
0, // windows height (default is width, don`t need to write height)
(HWND)NULL, // parent class descriptor
NULL, // menu descriptor
HINSTANCE(hInst), // descriptor of application copy
NULL); // don`t return anything from WndProc
if (!hWnd) {
// if window is wrong create (wrong parameter...):
MessageBox(nullptr, L"Could not create the window!", L"Error", MB_OK);
return 0;
}
ShowWindow(hWnd, nCmdShow); // show window
UpdateWindow(hWnd); // update window
while (GetMessage(&msg, nullptr, 0, 0)) { // extract message from queue, send to function, ОS
TranslateMessage(&msg); // interpret message
DispatchMessage(&msg); // send message to OS
}
return msg.wParam; // return exit code from application
}
void DrawBezier(HDC hdc, POINT apt[])
{
PolyBezier(hdc, apt, 4);
MoveToEx(hdc, apt[0].x, apt[0].y, nullptr);
LineTo(hdc, apt[1].x, apt[1].y);
MoveToEx(hdc, apt[2].x, apt[2].y, nullptr);
LineTo(hdc, apt[3].x, apt[3].y);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
static POINT apt[4];
int x1 = 0;
int y1 = 0;
HDC hdc;
int cxClient, cyClient;
PAINTSTRUCT ps;
switch (iMsg)
{
case WM_CREATE:
SetTimer(hwnd, 1, 1, nullptr);
break;
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
apt[0].x = cxClient / 4;
apt[0].y = cyClient / 2;
apt[1].x = cxClient / 2;
apt[1].y = cyClient / 4;
apt[2].x = cxClient / 2;
apt[2].y = 3 * cyClient / 4;
apt[3].x = 3 * cxClient / 4;
apt[3].y = cyClient / 2;
return 0;
case WM_MOUSEMOVE:
if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
{
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(WHITE_PEN));
DrawBezier(hdc, apt);
if (wParam & MK_LBUTTON)
{
apt[1].x = LOWORD(lParam);
apt[1].y = HIWORD(lParam);
}
if (wParam & MK_RBUTTON)
{
apt[2].x = LOWORD(lParam);
apt[2].y = HIWORD(lParam);
}
SelectObject(hdc, GetStockObject(BLACK_PEN));
DrawBezier(hdc, apt);
ReleaseDC(hwnd, hdc);
}
return 0;
case WM_KEYDOWN:
//deplasarea punctului de control
if (GetAsyncKeyState(VK_CONTROL))
{
switch (wParam)
{
case VK_LEFT:
apt[2].x -= 10;
break;
case VK_RIGHT:
apt[2].x += 6;
break;
case VK_UP:
apt[2].y -= 10;
break;
case VK_DOWN:
apt[2].y += 6;
break;
}
}
else
{
if (GetAsyncKeyState(VK_SPACE))
{
switch (wParam)
{
case VK_LEFT:
{
for (size_t i = 0; i < 4; i++)
{
apt[i].x--;
}
}
break;
case VK_RIGHT:
{
for (size_t i = 0; i < 4; i++)
{
apt[i].x++;
}
}
break;
case VK_UP:
{
for (size_t i = 0; i < 4; i++)
{
apt[i].y--;
}
}
break;
case VK_DOWN:
{
for (size_t i = 0; i < 4; i++)
{
apt[i].y++;
}
}
break;
}
}
else
{
if (GetAsyncKeyState(VK_SHIFT)) {
switch (wParam)
{
case VK_LEFT:
GetClientRect(hwnd, &r);
apt[0].x = r.right / 4; apt[0].y = r.bottom / 2;
apt[1].x = r.right / 2; apt[1].y = r.bottom / 4;
apt[2].x = r.right / 2; apt[2].y = 3 * r.bottom / 4;
apt[3].x = 3 * r.right / 4; apt[3].y = r.bottom / 2;
break;
case VK_RIGHT:
GetClientRect(hwnd, &r);
apt[0].x = r.right / 2; apt[0].y = r.bottom / 4;
apt[1].x = 3 * r.right / 4; apt[1].y = r.bottom / 2;
apt[2].x = r.right / 4; apt[2].y = r.bottom / 2;
apt[3].x = r.right / 2; apt[3].y = 3 * r.bottom / 4;
break;
}
}
else {
switch (wParam)
{
case VK_LEFT:
apt[1].x -= 10;
break;
case VK_RIGHT:
apt[1].x += 6;
break;
case VK_UP:
apt[1].y -= 10;
break;
case VK_DOWN:
apt[1].y += 6;
break;
}
}
}
}
InvalidateRect(hwnd, NULL, TRUE);
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SetTextColor(hdc, RGB(50, 70, 70));
//InvalidateRect(hWnd, NULL, TRUE);
PolyBezier(hdc, apt, 4);
{
int x[4] = { 20, 60, 160, 220 };
int y[4] = { 110, 20, 190, 110 };
for (double u = 0.0; u <= 1.0; u += 0.0001)
{
double xu = (pow(1 - u, 3) * x[0] + 3 * u * pow(1 - u, 2) * x[1] + 3 * pow(u, 2) * (1 - u) * x[2] + pow(u, 3) * x[3]);
double yu = pow(1 - u, 3) * y[0] + 3 * u * pow(1 - u, 2) * y[1] + 3 * pow(u, 2) * (1 - u) * y[2] + pow(u, 3) * y[3];
xu -= 10;
yu += 10;
SetPixel(hdc, static_cast<int>(xu), static_cast<int>(yu), RGB(125, 120, 235));
}
}
EndPaint(hwnd, &ps);
break;
case WM_TIMER:
InvalidateRect(hwnd, nullptr, TRUE);
break;
case WM_DESTROY:
KillTimer(hwnd, 1);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}