From e4d23309c7624adb67f3b1f756ae59d4ac313ac2 Mon Sep 17 00:00:00 2001 From: yixy-only Date: Wed, 2 Oct 2024 23:25:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=20bar3d=20=E5=BD=A2=E5=8F=82?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=B0=83=E6=95=B4=E8=87=B3=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=A3=B0=E6=98=8E=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/egegapi.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/egegapi.cpp b/src/egegapi.cpp index a2a9aab..a2d8303 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -1070,27 +1070,27 @@ 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) +void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIMAGE pimg) { - --x2; - --y2; + --right; + --bottom; { 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, + right, bottom, + right, top, + left, top, + left, bottom, + right, bottom, + right + depth, bottom - depth, + right + depth, top - depth, + left + depth, top - depth, + left, top, }; - bar(x1, y1, x2, y2, pimg); + bar(left, top, right, bottom, pimg); if (topFlag) { drawpoly(9, pt, pimg); - line(x2, y1, x2 + depth, y1 - depth, pimg); + line(right, top, right + depth, top - depth, pimg); } else { drawpoly(7, pt, pimg); } From 0f312222bda714bb2962e201367d9d87850ebc68 Mon Sep 17 00:00:00 2001 From: yixy-only Date: Thu, 3 Oct 2024 02:27:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20bar3d=20?= =?UTF-8?q?=E5=9B=BE=E5=BD=A2=E5=9C=A8=E7=BA=BF=E6=9D=A1=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=82=B9=E5=A4=84=E6=9C=89=E7=AA=81=E5=87=BA=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=9C=A8=E5=9B=BE=E5=BD=A2=E5=A0=86=E5=8F=A0=E6=97=B6?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E9=87=8D=E5=A4=8D=E8=BE=B9=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/egegapi.cpp | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/egegapi.cpp b/src/egegapi.cpp index a2d8303..3378bcd 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -1072,29 +1072,36 @@ void solidrect(int left, int top, int right, int bottom, PIMAGE pimg) void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIMAGE pimg) { - --right; - --bottom; - { - int pt[20] = { - right, bottom, - right, top, - left, top, - left, bottom, - right, bottom, - right + depth, bottom - depth, - right + depth, top - depth, - left + depth, top - depth, - left, top, + /* 6个外边界顶点(从左上角开始逆时针数) */ + POINT boundVertexes[6] = { + {left, top}, + {left, bottom}, + {right, bottom}, + {right + depth, bottom - depth}, + {right + depth, top - depth}, + {left + depth, top - depth}, }; - bar(left, top, right, bottom, pimg); - if (topFlag) { - drawpoly(9, pt, pimg); - line(right, top, right + depth, top - depth, pimg); - } else { - drawpoly(7, pt, pimg); - } + /* 正面右上边界的3个顶点 */ + POINT sideVertexes[3] = {{left, top}, {right, top}, {right, bottom}}; + + 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) From e758b9bc6e6db79e3d6b47c9e23cdf28621aa328 Mon Sep 17 00:00:00 2001 From: yixy-only Date: Fri, 4 Oct 2024 12:53:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/egegapi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/egegapi.cpp b/src/egegapi.cpp index 3378bcd..7e1527d 100644 --- a/src/egegapi.cpp +++ b/src/egegapi.cpp @@ -1082,8 +1082,6 @@ void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIM {left + depth, top - depth}, }; - /* 正面右上边界的3个顶点 */ - POINT sideVertexes[3] = {{left, top}, {right, top}, {right, bottom}}; bar(left, top, right, bottom, pimg); @@ -1092,13 +1090,15 @@ void bar3d(int left, int top, int right, int bottom, int depth, int topFlag, PIM setlinecap(LINECAP_FLAT, pimg); if (topFlag) { + /* 正面右上边界的3个顶点 */ + POINT sideVertexes[3] = {{left, top}, {right, top}, {right, bottom}}; 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); + line(right, top, right, bottom, pimg); } setlinecap(startCap, endCap, pimg);