EasyX库介绍
下载链接:下载传送门
以下是官网的介绍:
该库提供使用的函数:官网说明
程序演示
项目介绍
画点线实现
//获取鼠标横纵坐标
x = point.x;
y = point.y;
getimage(&img, 98, 58, 960, 800);
GetCursorPos(&point); // 获取鼠标指针位置(屏幕坐标)
ScreenToClient(hwnd, &point); // 将鼠标指针位置转换为窗口坐标
if (point.x > 96 && point.y > 56) {
setlinestyle(0, 2);
line(x, y, point.x, point.y);
}
if (!GetAsyncKeyState(VK_LBUTTON))
break;
画矩形实现
//实现策略:获取单击后的坐标作为起点直角汇点的坐标
//松开后获取的坐标作为起点直角对角汇点的坐标
getimage(&img, 98, 58, 960, 800);
GetCursorPos(&point); // 获取鼠标指针位置(屏幕坐标)
ScreenToClient(hwnd, &point); // 将鼠标指针位置转换为窗口坐标
if (point.x > 96 && point.y > 56) {
x1 = point.x;
y1 = point.y;
rectangle(x, y, x1, y1);
}
Sleep(20);
setc(8);
rectangle(x, y,