裁减多边形 |
| 作者:不详 来源:本站整理 发布时间:2005-11-24 17:30:12 |
|
System.out.println(" "+heaps[j]); } } int bx = 0; if(heaps == null) continue; int j = 0; while(heaps != null){ if((j%2)==0){ int ex = pop(); bx = ex; }else{ int ex = pop(); gb.drawLine(bx,i,ex,i); bx = ex; } j++; } } } private void drawPolygon(int nodes[][]) { gb.setColor(0x0000ff00); for(int i = 0; i < nodes.length-1; i++){ gb.drawLine(nodes[0],nodes[1],nodes[i+1][0],nodes[i+1][1]); // gb.fillArc(nodes[0] - 10,nodes[1] - 10,20,20,0,360); } gb.drawLine(nodes[0][0],nodes[0][1], nodes[nodes.length-1][0], nodes[nodes.length-1][1]); // gb.fillArc(nodes[nodes.length-1][0] - 10,nodes[nodes.length-1][1] - 10,20,20,0,360); } //裁减,裁减后的图放在theCutImg里面 Image theCutImg; private void cutGraphics(int x,int y,int w, int h) { Graphics tg; try{ theCutImg = Image.createImage(w,h); }catch(Exception e){System.out.println(e+" createImage");} tg = theCutImg.getGraphics(); tg.drawImage(bufImg, -x, -y, 0); } public void run() { gb.setColor(0x00ffffff); gb.fillRect(0,0,nWidth,nHeight); fillPolygon(nodes); System.out.println("done1"); drawPolygon(nodes); System.out.println("done2"); repaint(); } private void pause(long t) { try{Thread.sleep(t);}catch(Exception e){} } public void keyPressed(int keyCode) { } } |
| [] [返回上一页] [打 印] |
|
文章评论 |
