Added win32 graphics project
BIN
lab5-6-7-8-11/1.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
lab5-6-7-8-11/chevrolet.jpg
Normal file
After Width: | Height: | Size: 1.0 MiB |
BIN
lab5-6-7-8-11/diagLogo.png
Normal file
After Width: | Height: | Size: 83 KiB |
31
lab5-6-7-8-11/lab5-6-7-8.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35312.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab5-6", "lab5-6\lab5-6.vcxproj", "{338A83EB-228F-46AE-BB48-647AA29D24F9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Debug|x64.Build.0 = Debug|x64
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Debug|x86.Build.0 = Debug|Win32
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Release|x64.ActiveCfg = Release|x64
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Release|x64.Build.0 = Release|x64
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Release|x86.ActiveCfg = Release|Win32
|
||||
{338A83EB-228F-46AE-BB48-647AA29D24F9}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {880FA844-6AB5-4C5E-9A0F-6D683EECA3EA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
15
lab5-6-7-8-11/lab5-6/framework.h
Normal file
@ -0,0 +1,15 @@
|
||||
// header.h: включаемый файл для стандартных системных включаемых файлов
|
||||
// или включаемые файлы для конкретного проекта
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows
|
||||
// Файлы заголовков Windows
|
||||
#include <windows.h>
|
||||
// Файлы заголовков среды выполнения C
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
642
lab5-6-7-8-11/lab5-6/lab5-6-7-8.cpp
Normal file
@ -0,0 +1,642 @@
|
||||
// lab5-6.cpp : Определяет точку входа для приложения.
|
||||
//
|
||||
|
||||
#include "framework.h"
|
||||
#include "lab5-6.h"
|
||||
#include "stdio.h"
|
||||
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
// Глобальные переменные:
|
||||
HINSTANCE hInst; // текущий экземпляр
|
||||
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
||||
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
||||
|
||||
// Отправить объявления функций, включенных в этот модуль кода:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
BOOL InitInstance(HINSTANCE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// TODO: Разместите код здесь.
|
||||
|
||||
// Инициализация глобальных строк
|
||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadStringW(hInstance, IDC_LAB56, szWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
// Выполнить инициализацию приложения:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB56));
|
||||
|
||||
MSG msg;
|
||||
|
||||
// Цикл основного сообщения:
|
||||
while (GetMessage(&msg, nullptr, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: MyRegisterClass()
|
||||
//
|
||||
// ЦЕЛЬ: Регистрирует класс окна.
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LAB56));
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB56);
|
||||
wcex.lpszClassName = szWindowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||
|
||||
return RegisterClassExW(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
||||
//
|
||||
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
||||
//
|
||||
// КОММЕНТАРИИ:
|
||||
//
|
||||
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
||||
// создается и выводится главное окно программы.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
||||
|
||||
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//Рисует квадратную сетку с шагом в 50 пикселей от нуля до указанных координат
|
||||
void drawNet(HDC hdc, int width, int height) {
|
||||
for (int i = 0; i <= width; i = i + 50) {
|
||||
MoveToEx(hdc, i, 0, NULL);
|
||||
LineTo(hdc, i, height);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= height; i = i + 50) {
|
||||
MoveToEx(hdc, 0, i, NULL);
|
||||
LineTo(hdc, width, i);
|
||||
}
|
||||
}
|
||||
|
||||
void drawTractor(HDC hdc, int cx, int cy) {
|
||||
HBRUSH hBrush;
|
||||
HPEN hPen;
|
||||
hBrush = CreateSolidBrush(RGB(0, 0, 150));
|
||||
SelectObject(hdc, hBrush);
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 100));
|
||||
SelectObject(hdc, hPen);
|
||||
Rectangle(hdc, cx-150, cy-50, cx+150, cy+50);
|
||||
MoveToEx(hdc, cx + 150, cy - 50, NULL);
|
||||
LineTo(hdc, cx + 150, cy - 150);
|
||||
LineTo(hdc, cx + 50, cy - 150);
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(153, 217, 234));
|
||||
SelectObject(hdc, hPen);
|
||||
LineTo(hdc, cx, cy - 50);
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
|
||||
SelectObject(hdc, hPen);
|
||||
hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
|
||||
SelectObject(hdc, hBrush);
|
||||
Ellipse(hdc, cx-175, cy+25, cx-75, cy+125);
|
||||
Ellipse(hdc, cx + 25, cy - 25, cx + 175, cy + 125);
|
||||
DeleteObject(hPen);
|
||||
DeleteObject(hBrush);
|
||||
}
|
||||
|
||||
void drawHouse(HDC hdc){
|
||||
HPEN hPen;
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
//крыша и стены
|
||||
MoveToEx(hdc, 150, 250, NULL);
|
||||
LineTo(hdc, 300, 50);
|
||||
LineTo(hdc, 450, 250);
|
||||
LineTo(hdc, 150, 250);
|
||||
LineTo(hdc, 150, 500);
|
||||
LineTo(hdc, 450, 500);
|
||||
LineTo(hdc, 450, 250);
|
||||
//окно
|
||||
MoveToEx(hdc, 200, 300, NULL);
|
||||
LineTo(hdc, 200, 400);
|
||||
LineTo(hdc, 300, 400);
|
||||
LineTo(hdc, 300, 300);
|
||||
LineTo(hdc, 200, 300);
|
||||
MoveToEx(hdc, 250, 300, NULL);
|
||||
LineTo(hdc, 250, 400);
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawSpruce(HDC hdc) {
|
||||
HPEN hPen;
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(30, 200, 80));
|
||||
SelectObject(hdc, hPen);
|
||||
//ёлка
|
||||
MoveToEx(hdc, 0, 600, NULL);
|
||||
LineTo(hdc, 150, 600);
|
||||
LineTo(hdc, 75, 500);
|
||||
LineTo(hdc, 0, 600);
|
||||
MoveToEx(hdc, 25, 500, NULL);
|
||||
LineTo(hdc, 125, 500);
|
||||
LineTo(hdc, 75, 400);
|
||||
LineTo(hdc, 25, 500);
|
||||
MoveToEx(hdc, 50, 400, NULL);
|
||||
LineTo(hdc, 100, 400);
|
||||
LineTo(hdc, 75, 300);
|
||||
LineTo(hdc, 50, 400);
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawCar(HDC hdc) {
|
||||
HPEN hPen;
|
||||
HBRUSH hBrush;
|
||||
//корпус авто
|
||||
hBrush = CreateSolidBrush(RGB(100, 100, 100));
|
||||
SelectObject(hdc, hBrush);
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(50, 50, 50));
|
||||
SelectObject(hdc, hPen);
|
||||
Rectangle(hdc, 550, 350, 850, 450);
|
||||
//крыша авто
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(0, 162, 232));
|
||||
SelectObject(hdc, hPen);
|
||||
MoveToEx(hdc, 550, 350, NULL);
|
||||
LineTo(hdc, 650, 250);
|
||||
LineTo(hdc, 800, 250);
|
||||
LineTo(hdc, 850, 350);
|
||||
//колёса
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
|
||||
SelectObject(hdc, hPen);
|
||||
hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(20, 20, 20));
|
||||
SelectObject(hdc, hBrush);
|
||||
Ellipse(hdc, 560, 410, 640, 490);
|
||||
Ellipse(hdc, 560 + 200, 410, 640 + 200, 490);
|
||||
DeleteObject(hPen);
|
||||
DeleteObject(hBrush);
|
||||
}
|
||||
|
||||
void drawTree(HDC hdc) {
|
||||
HPEN hPen;
|
||||
HBRUSH hBrush;
|
||||
//ствол дерева
|
||||
hPen = CreatePen(PS_SOLID, 25, RGB(114, 78, 54));
|
||||
SelectObject(hdc, hPen);
|
||||
MoveToEx(hdc, 950, 500, NULL);
|
||||
LineTo(hdc, 950, 200);
|
||||
//листва дерева
|
||||
hPen = CreatePen(PS_SOLID, 5, RGB(30, 150, 80));
|
||||
SelectObject(hdc, hPen);
|
||||
hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(30, 210, 80));
|
||||
SelectObject(hdc, hBrush);
|
||||
Ellipse(hdc, 850, 50, 1050, 350);
|
||||
DeleteObject(hPen);
|
||||
DeleteObject(hBrush);
|
||||
}
|
||||
|
||||
//Рисует логотип Шевроле
|
||||
void drawLogo(HDC hdc, int cx, int cy) {
|
||||
POINT pt[12];
|
||||
pt[0].x = cx + 50; pt[0].y = cy + 50;
|
||||
pt[1].x = cx - 50; pt[1].y = cy + 50;
|
||||
pt[2].x = cx - 50; pt[2].y = cy + 25;
|
||||
pt[3].x = cx - 150; pt[3].y = cy + 25;
|
||||
pt[4].x = cx - 125; pt[4].y = cy - 25;
|
||||
pt[5].x = cx - 50; pt[5].y = cy - 25;
|
||||
pt[6].x = cx - 50; pt[6].y = cy - 50;
|
||||
pt[7].x = cx + 50; pt[7].y = cy - 50;
|
||||
pt[8].x = cx + 50; pt[8].y = cy - 25;
|
||||
pt[9].x = cx + 150; pt[9].y = cy - 25;
|
||||
pt[10].x = cx + 125; pt[10].y = cy + 25;
|
||||
pt[11].x = cx + 50; pt[11].y = cy + 25;
|
||||
|
||||
HPEN hPen;
|
||||
HBRUSH hBrush;
|
||||
hPen = CreatePen(PS_SOLID, 10, RGB(180, 180, 180));
|
||||
hBrush = CreateHatchBrush(HS_CROSS, RGB(255, 215, 104));
|
||||
SelectObject(hdc, hPen);
|
||||
SelectObject(hdc, hBrush);
|
||||
|
||||
Polygon(hdc, pt, 12);
|
||||
|
||||
DeleteObject(hPen);
|
||||
DeleteObject(hBrush);
|
||||
}
|
||||
|
||||
void lab5(HDC hdc) {
|
||||
drawHouse(hdc);
|
||||
drawSpruce(hdc);
|
||||
drawCar(hdc);
|
||||
drawTree(hdc);
|
||||
drawTractor(hdc, 1200, 450);
|
||||
}
|
||||
|
||||
void lab6(HDC hdc) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
|
||||
SelectObject(hdc, hPen);
|
||||
int x1 = 100;
|
||||
do {
|
||||
MoveToEx(hdc, 400, 300, NULL);
|
||||
LineTo(hdc, x1, 100);
|
||||
x1 += 25;
|
||||
} while (x1 <= 700);
|
||||
|
||||
int x2 = 600, y2 = 400;
|
||||
do {
|
||||
MoveToEx(hdc, 800, 400, NULL);
|
||||
LineTo(hdc, x2, y2);
|
||||
x2 += 10;
|
||||
y2 -= 16;
|
||||
} while (x2 < 800);
|
||||
do {
|
||||
MoveToEx(hdc, 800, 400, NULL);
|
||||
LineTo(hdc, x2, y2);
|
||||
x2 += 10;
|
||||
y2 += 16;
|
||||
} while (x2 <= 1000);
|
||||
|
||||
int x3 = 1100;
|
||||
do {
|
||||
MoveToEx(hdc, x3, 50, NULL);
|
||||
LineTo(hdc, x3, 300);
|
||||
x3 += 5;
|
||||
} while (x3 <= 1400);
|
||||
|
||||
int x4 = 100, y4 = 350;
|
||||
int x5 = 400, y5 = 350;
|
||||
int i = 0;
|
||||
do {
|
||||
MoveToEx(hdc, x4, y4, NULL);
|
||||
LineTo(hdc, x5, y5);
|
||||
y4 += 10;
|
||||
x5 -= 10;
|
||||
i++;
|
||||
} while (i <= 30);
|
||||
|
||||
int x6 = 600, y6 = 600;
|
||||
int dy = 10;
|
||||
i = 0;
|
||||
|
||||
do {
|
||||
MoveToEx(hdc, x6, y6 - dy, NULL);
|
||||
LineTo(hdc, x6, y6 + dy);
|
||||
x6 += 10;
|
||||
dy += 10;
|
||||
i++;
|
||||
} while (i < 15);
|
||||
}
|
||||
|
||||
void lab8(HDC hdc) {
|
||||
/*drawLogo(hdc, 155, 55);
|
||||
drawLogo(hdc, 155+300, 55);
|
||||
drawLogo(hdc, 155, 55+300);
|
||||
drawLogo(hdc, 155+300, 55+300);
|
||||
drawLogo(hdc, 155 + 150, 55 + 150);*/
|
||||
|
||||
int x1 = 0, y1 = 0;
|
||||
int i = 0;
|
||||
do {
|
||||
drawLogo(hdc, 155 + x1, 55 + y1);
|
||||
x1 += 125;
|
||||
y1 += 125;
|
||||
i++;
|
||||
} while (i < 5);
|
||||
}
|
||||
|
||||
int imageNum = 1;
|
||||
bool netToggle = true;
|
||||
|
||||
//Рисует картинки по нажатию цифры на клавиатуре
|
||||
void drawImageSequence1(HDC hdc) {
|
||||
switch (imageNum)
|
||||
{
|
||||
case 0:
|
||||
lab5(hdc);
|
||||
break;
|
||||
case 1:
|
||||
drawSpruce(hdc);
|
||||
break;
|
||||
case 2:
|
||||
drawHouse(hdc);
|
||||
break;
|
||||
case 3:
|
||||
drawLogo(hdc, 500, 300);
|
||||
break;
|
||||
case 4:
|
||||
drawCar(hdc);
|
||||
break;
|
||||
case 5:
|
||||
drawTree(hdc);
|
||||
break;
|
||||
case 6:
|
||||
drawTractor(hdc, 1200, 450);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void draw5logos(HDC hdc, RECT rect) {
|
||||
drawLogo(hdc, rect.right - 200, rect.bottom - 100);
|
||||
drawLogo(hdc, rect.right - 200, rect.top + 100);
|
||||
drawLogo(hdc, rect.left + 200, rect.bottom - 100);
|
||||
drawLogo(hdc, rect.right / 2, rect.bottom / 2);
|
||||
}
|
||||
|
||||
void drawImage1(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[4] = {
|
||||
cx, cy - 20,
|
||||
cx + 20, cy + 20,
|
||||
cx - 20, cy + 20,
|
||||
cx, cy - 20
|
||||
};
|
||||
Polyline(hdc, p, 4);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage2(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[5] = {
|
||||
cx, cy - 20,
|
||||
cx + 20, cy,
|
||||
cx, cy + 20,
|
||||
cx - 20, cy,
|
||||
cx, cy - 20
|
||||
};
|
||||
Polyline(hdc, p, 5);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage3(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[5] = {
|
||||
cx, cy,
|
||||
cx + 20, cy - 20,
|
||||
cx, cy + 20,
|
||||
cx - 20, cy - 20,
|
||||
cx, cy
|
||||
};
|
||||
Polyline(hdc, p, 5);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage4(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[6] = {
|
||||
cx - 20, cy + 20,
|
||||
cx - 20, cy - 20,
|
||||
cx + 20, cy - 20,
|
||||
cx, cy - 10,
|
||||
cx + 20, cy,
|
||||
cx - 20, cy
|
||||
};
|
||||
Polyline(hdc, p, 6);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage5(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[6] = {
|
||||
cx, cy ,
|
||||
cx + 20, cy - 20,
|
||||
cx + 20, cy + 20,
|
||||
cx - 20, cy + 20,
|
||||
cx - 20, cy - 20,
|
||||
cx, cy
|
||||
};
|
||||
Polyline(hdc, p, 6);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImageNet(HDC hdc, int cx, int cy, int width, int height, int step, void (*image)(HDC hdc, int cx, int cy, COLORREF color)) {
|
||||
int r, g, b, fb;
|
||||
r = 255;
|
||||
g = 40;
|
||||
b = 0;
|
||||
int dr, dg, db;
|
||||
dr = r / width;
|
||||
dg = (255 - g) / width;
|
||||
db = (255 - b) / height;
|
||||
for (int i = cx; i <= width * step; i += step) {
|
||||
fb = b;
|
||||
for (int j = cy; j <= height * step; j += step) {
|
||||
image(hdc, i, j, RGB(r, g, fb));
|
||||
fb += db;
|
||||
}
|
||||
//r -= dr;
|
||||
g += dg;
|
||||
}
|
||||
}
|
||||
|
||||
enum Modes {
|
||||
image1,
|
||||
image2,
|
||||
image3,
|
||||
image4,
|
||||
image5
|
||||
} mode;
|
||||
|
||||
void drawImageSequence2(HDC hdc, int cx, int cy, int width, int height, int step) {
|
||||
switch (mode)
|
||||
{
|
||||
case image1:
|
||||
drawImageNet(hdc, cx, cy, width, height, step, drawImage1);
|
||||
break;
|
||||
case image2:
|
||||
drawImageNet(hdc, cx, cy, width, height, step, drawImage2);
|
||||
break;
|
||||
case image3:
|
||||
drawImageNet(hdc, cx, cy, width, height, step, drawImage3);
|
||||
break;
|
||||
case image4:
|
||||
drawImageNet(hdc, cx, cy, width, height, step, drawImage4);
|
||||
break;
|
||||
case image5:
|
||||
drawImageNet(hdc, cx, cy, width, height, step, drawImage5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
//
|
||||
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
||||
//
|
||||
// WM_COMMAND - обработать меню приложения
|
||||
// WM_PAINT - Отрисовка главного окна
|
||||
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
||||
//
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
{
|
||||
int wmId = LOWORD(wParam);
|
||||
// Разобрать выбор в меню:
|
||||
switch (wmId)
|
||||
{
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hWnd, &rect);
|
||||
|
||||
if (netToggle) drawNet(hdc, rect.right, rect.bottom); //drawNet(hdc, 1400, 650);
|
||||
|
||||
//drawImageSequence1(hdc);
|
||||
|
||||
//lab5(hdc);
|
||||
|
||||
//lab6(hdc);
|
||||
|
||||
//lab8(hdc);
|
||||
|
||||
//draw5logos(hdc, rect);
|
||||
|
||||
//drawImageNet(hdc, 50, 50, 8, 8, 100, drawImage4);
|
||||
|
||||
//drawImageSequence2(hdc, 50, 50, 12, 8, 100);
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_SPACE:
|
||||
netToggle = !netToggle;
|
||||
break;
|
||||
case 0x30:
|
||||
imageNum = 0;
|
||||
break;
|
||||
case 0x31:
|
||||
imageNum = 1;
|
||||
mode = image1;
|
||||
break;
|
||||
case 0x32:
|
||||
imageNum = 2;
|
||||
mode = image2;
|
||||
break;
|
||||
case 0x33:
|
||||
imageNum = 3;
|
||||
mode = image3;
|
||||
break;
|
||||
case 0x34:
|
||||
imageNum = 4;
|
||||
mode = image4;
|
||||
break;
|
||||
case 0x35:
|
||||
imageNum = 5;
|
||||
mode = image5;
|
||||
break;
|
||||
case 0x36:
|
||||
imageNum = 6;
|
||||
break;
|
||||
}
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Обработчик сообщений для окна "О программе".
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
3
lab5-6-7-8-11/lab5-6/lab5-6.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
BIN
lab5-6-7-8-11/lab5-6/lab5-6.ico
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
lab5-6-7-8-11/lab5-6/lab5-6.rc
Normal file
149
lab5-6-7-8-11/lab5-6/lab5-6.vcxproj
Normal file
@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{338a83eb-228f-46ae-bb48-647aa29d24f9}</ProjectGuid>
|
||||
<RootNamespace>lab56</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>lab5-6-7-8</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="lab5-6.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab5-6-7-8.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab5-6.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="lab5-6.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
49
lab5-6-7-8-11/lab5-6/lab5-6.vcxproj.filters
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lab5-6.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab5-6-7-8.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab5-6.rc">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
<Image Include="lab5-6.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
28
lab5-6-7-8-11/lab5-6/resource.h
Normal file
@ -0,0 +1,28 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Включаемый файл, созданный в Microsoft Visual C++.
|
||||
// Используется lab5-6.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_LAB56_DIALOG 102
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_LAB56 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_LAB56 109
|
||||
#define IDR_MAINFRAME 128
|
||||
#define ID_32771 32771
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32772
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
BIN
lab5-6-7-8-11/lab5-6/small.ico
Normal file
After Width: | Height: | Size: 45 KiB |
6
lab5-6-7-8-11/lab5-6/targetver.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows.
|
||||
// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и
|
||||
// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h.
|
||||
#include <SDKDDKVer.h>
|
BIN
lab5-6-7-8-11/камаз.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
lab5-6-7-8-11/лого.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
lab5-6-7-8-11/трактор.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
lab5-6-7-8-11/шаблон сетки.png
Normal file
After Width: | Height: | Size: 16 KiB |