From 093abbf082b315ab3408cfe3b939a8c7bf7224c3 Mon Sep 17 00:00:00 2001 From: Kaehvaman Date: Wed, 30 Oct 2024 13:30:10 +0400 Subject: [PATCH] lab18 start n2 --- lab18/lab18/lab18.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/lab18/lab18/lab18.cpp b/lab18/lab18/lab18.cpp index 4aa81c0..333620c 100644 --- a/lab18/lab18/lab18.cpp +++ b/lab18/lab18/lab18.cpp @@ -140,18 +140,6 @@ void drawTriangle(HDC hdc, int cx, int cy, int size) { DeleteObject(hPen); } -void drawRecursiveImage(HDC hdc, int cx, int cy, int size, int mode, void image(HDC hdc, int cx, int cy, int size)) { - image(hdc, cx, cy, size); - - if (size < 20) { - return; - } - - if (mode > 0 && mode != 3) drawRecursiveImage(hdc, cx, cy - size, size / 2, mode, image); - if (mode > 1 && mode != 4) drawRecursiveImage(hdc, cx + size, cy + size, size / 2, mode, image); - if (mode > 2) drawRecursiveImage(hdc, cx - size, cy + size, size / 2, mode, image); -} - void drawHourglass(HDC hdc, int cx, int cy, int size) { HPEN hPen = CreatePen(PS_SOLID, 4, RGB(78, 180, 200)); SelectObject(hdc, hPen); @@ -168,6 +156,28 @@ void drawHourglass(HDC hdc, int cx, int cy, int size) { DeleteObject(hPen); } +void drawRecursiveTriangle(HDC hdc, int cx, int cy, int size, int mode) { + drawTriangle(hdc, cx, cy, size); + + if (size < 20) { + return; + } + + if (mode > 0 && mode != 3) drawRecursiveTriangle(hdc, cx, cy - size, size / 2, mode); + if (mode > 1 && mode != 4) drawRecursiveTriangle(hdc, cx + size, cy + size, size / 2, mode); + if (mode > 2) drawRecursiveTriangle(hdc, cx - size, cy + size, size / 2, mode); +} + +void drawRecursiveHourglass(HDC hdc, int cx, int cy, int size, int mode) { + drawHourglass(hdc, cx, cy, size); + if (size < 20) { + return; + } + + drawRecursiveHourglass(hdc, cx - size / 2, cy - size, size / 2, mode); + +} + int trmode = 0; int imageVar = 0; @@ -213,11 +223,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (netToggle) drawNet(hdc, rect.right, rect.bottom, 50, 50); - - - drawRecursiveTriangle(hdc, 300, 300, 100, trmode); - - drawHourglass(hdc, 500, 300, 100); + drawRecursiveTriangle(hdc, 300, 300, 100, trmode); + drawRecursiveHourglass(hdc, 600, 300, 100, trmode); EndPaint(hWnd, &ps); }