Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 bar3d 图形在线条连接点处有突出,以及在图形堆叠时存在重复边的问题 #233

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions src/egegapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,31 +1070,38 @@ void solidrect(int left, int top, int right, int bottom, PIMAGE pimg)
CONVERT_IMAGE_END
}

void bar3d(int x1, int y1, int x2, int y2, int depth, int topFlag, PIMAGE pimg)
{
--x2;
--y2;
{
int pt[20] = {
x2, y2,
x2, y1,
x1, y1,
x1, y2,
x2, y2,
x2 + depth, y2 - depth,
x2 + depth, y1 - depth,
x1 + depth, y1 - depth,
x1, y1,
void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIMAGE pimg)
{
/* 6个外边界顶点(从左上角开始逆时针数) */
POINT boundVertexes[6] = {
{left, top},
{left, bottom},
{right, bottom},
{right + depth, bottom - depth},
{right + depth, top - depth},
{left + depth, top - depth},
};

bar(x1, y1, x2, y2, pimg);
if (topFlag) {
drawpoly(9, pt, pimg);
line(x2, y1, x2 + depth, y1 - depth, pimg);
} else {
drawpoly(7, pt, pimg);
}
/* 正面右上边界的3个顶点 */
POINT sideVertexes[3] = {{left, top}, {right, top}, {right, bottom}};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个变量似乎只在 if(topFlag) 进去的时候才需要? else 里面可以直接使用 left、top等, 你看看要不要优化下? 不过不改也没事...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不改的话我就直接合入啦~~~


bar(left, top, right, bottom, pimg);

line_cap_type startCap, endCap;
getlinecap(&startCap, &endCap, pimg);
setlinecap(LINECAP_FLAT, pimg);

if (topFlag) {
polygon(6, (const int*)boundVertexes, pimg);
polyline(3, (const int*)&sideVertexes, pimg);
line(right, top, right + depth, top - depth, pimg);
} else {
/* 只绘制与底部相连的 5 条边 */
polyline(5, (const int*)boundVertexes, pimg);
line(sideVertexes[1].x, sideVertexes[1].y, sideVertexes[2].x, sideVertexes[2].y, pimg);
}

setlinecap(startCap, endCap, pimg);
}

void drawpoly(int numOfPoints, const int* points, PIMAGE pimg)
Expand Down
Loading