0
繪製下圖如何在之前繪製如下圖?現在結束了......這將是漏斗狀的,所以我希望每個下一個橢圓形都在多邊形和圓弧下面。 我有這樣的代碼:Java Graphics2D:根據之前的
for (int i = 0; i < pdLen; i++) {
....
....
g2.fillPolygon(poly);
g2.fillOval(topLeft[0], topLeft[1] - 10, topRight[0] - topLeft[0], arcHeight);
g2.fillArc(botLeft[0], botLeft[1] - arcHeight/2, botRight[0] - botLeft[0], arcHeight, 0, -180);
}
感謝 PS:按照座標是從先前的計算,所以對(INT I = pdLen-1; i> 0; I - ){將不起作用
UPD:
每個循環步驟計算topLeft和topRight。
int[] topLeft = {(int)Math.round(startX + (procSum/onePixX)), (int)Math.round(startY + (procSum/onePixY))};
int[] topRight = {(int)Math.round(topRightX - (procSum/onePixX)), (int)Math.round(startY + (procSum/onePixY))};
procSum += (pieceData[i] * pieceProc);
int[] botLeft = {(int)Math.round(startX + (procSum/onePixX)), (int)Math.round(startY + (procSum/onePixY))};
int[] botRight = {(int)Math.round(topRightX - (procSum/onePixX)), (int)Math.round(startY + (procSum/onePixY))};
procSum += padProc;
感謝。 它的工作原理,後來會改變算法 – Gwalk 2014-09-01 13:23:10