1 Star 0 Fork 1

nkjpj/PaintPlus-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Ellipse.cpp 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
ngtritham 提交于 2017-12-06 23:09 . Initial commit
#include "stdafx.h"
#include "Shape.h"
CEllipse::CEllipse() {
startPoint.x = 0;
startPoint.y = 0;
endPoint.x = 0;
endPoint.y = 0;
}
CEllipse::CEllipse(POINT start, POINT end) {
startPoint = start;
endPoint = end;
}
CEllipse::~CEllipse() {
}
void CEllipse::Draw(Graphics *graphic) {
if (pressedShift) {
ChangeEndIfShift(startPoint, endPoint);
}
POINT topLeft;
int width = 0;
int height = 0;
if (startPoint.x > endPoint.x) {
if (startPoint.y > endPoint.y) {
topLeft = endPoint;
width = startPoint.x - endPoint.x;
height = startPoint.y - endPoint.y;
}
else {
topLeft.x = endPoint.x;
topLeft.y = startPoint.y;
width = startPoint.x - endPoint.x;
height = endPoint.y - startPoint.y;
}
}
else {
if (startPoint.y > endPoint.y) {
topLeft.x = startPoint.x;
topLeft.y = endPoint.y;
width = endPoint.x - startPoint.x;
height = startPoint.y - endPoint.y;
}
else {
topLeft = startPoint;
width = endPoint.x - startPoint.x;
height = endPoint.y - startPoint.y;
}
}
graphic->DrawEllipse(pen, topLeft.x, topLeft.y, width, height);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nkjpj/PaintPlus-1.git
git@gitee.com:nkjpj/PaintPlus-1.git
nkjpj
PaintPlus-1
PaintPlus-1
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385