diff --git a/graphics/beziercurve.c b/graphics/beziercurve.c new file mode 100644 index 0000000..8ddf568 --- /dev/null +++ b/graphics/beziercurve.c @@ -0,0 +1,58 @@ +#include + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + PWSTR lpCmdLine, int nCmdShow) { + + MSG msg; + WNDCLASSW wc = {0}; + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpszClassName = L"BezierCurve"; + wc.hInstance = hInstance; + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); + wc.lpfnWndProc = WndProc; + wc.hCursor = LoadCursor(0, IDC_ARROW); + + RegisterClassW(&wc); + CreateWindowW(wc.lpszClassName, L"BeziƩr curve", + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 500, 200, NULL, NULL, hInstance, NULL); + + while (GetMessage(&msg, NULL, 0, 0)) { + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return (int) msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { + + HDC hdc; + PAINTSTRUCT ps; + + POINT points[4] = { 20, 40, 320, 200, 330, 110, 450, 40 }; + + switch(msg) { + + case WM_PAINT: + + hdc = BeginPaint(hwnd, &ps); + + PolyBezier(hdc, points, 4); + + EndPaint(hwnd, &ps); + break; + + case WM_DESTROY: + + PostQuitMessage(0); + return 0; + } + + return DefWindowProcW(hwnd, msg, wParam, lParam); +}