java 2D Graphics 學習筆記(一)

來源:互聯網
上載者:User
繪製簡單映像
 
// draw Line2D.Doubleg2.draw(new Line2D.Double(x, y+rectHeight-1,                          x + rectWidth, y));
// draw Rectangle2D.Doubleg2.setStroke(stroke);g2.draw(new Rectangle2D.Double(x, y,                               rectWidth,                               rectHeight));
// draw RoundRectangle2D.Doubleg2.setStroke(dashed);g2.draw(new RoundRectangle2D.Double(x, y,                                   rectWidth,                                   rectHeight,                                   10, 10));
// draw Arc2D.Doubleg2.setStroke(wideStroke);g2.draw(new Arc2D.Double(x, y,                         rectWidth,                         rectHeight,                         90, 135,                         Arc2D.OPEN));
// draw Ellipse2D.Doubleg2.setStroke(stroke);g2.draw(new Ellipse2D.Double(x, y,                             rectWidth,                             rectHeight));
// draw GeneralPath (polygon)int x1Points[] = {x, x+rectWidth,                  x, x+rectWidth};int y1Points[] = {y, y+rectHeight,                  y+rectHeight, y};GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD,     x1Points.length);polygon.moveTo(x1Points[0], y1Points[0]);for (int index = 1;     index < x1Points.length;     index++) {        polygon.lineTo(x1Points[index],                       y1Points[index]);};polygon.closePath();g2.draw(polygon);
// draw GeneralPath (polyline)int x2Points[] = {x, x+rectWidth, x,                  x+rectWidth};int y2Points[] = {y, y+rectHeight,                  y+rectHeight, y};GeneralPath polyline = new         GeneralPath(GeneralPath.WIND_EVEN_ODD,                x2Points.length);polyline.moveTo (x2Points[0], y2Points[0]);for (int index = 1;     index < x2Points.length;     index++) {  polyline.lineTo(x2Points[index],         y2Points[index]);};g2.draw(polyline);
// fill Rectangle2D.Double (red)g2.setPaint(red);g2.fill(new Rectangle2D.Double(x, y,        rectWidth, rectHeight));
// fill RoundRectangle2D.Doubleg2.setPaint(redtowhite);g2.fill(new RoundRectangle2D.Double(x, y,                                   rectWidth,                                   rectHeight,                                   10, 10));
// fill Arc2Dg2.setPaint(red);g2.fill(new Arc2D.Double(x, y, rectWidth,                         rectHeight, 90,                         135, Arc2D.OPEN));
// fill Ellipse2D.Doubleg2.setPaint(redtowhite);g2.fill (new Ellipse2D.Double(x, y,                              rectWidth,                              rectHeight));
// fill and stroke GeneralPathint x3Points[] = {x, x+rectWidth, x,                  x+rectWidth};int y3Points[] = {y, y+rectHeight,                  y+rectHeight, y};GeneralPath filledPolygon = new         GeneralPath(GeneralPath.WIND_EVEN_ODD,     x3Points.length);filledPolygon.moveTo(x3Points[0],                     y3Points[0]);for (int index = 1;     index < x3Points.length;     index++) {filledPolygon.lineTo(x3Points[index],                             y3Points[index]);};filledPolygon.closePath();g2.setPaint(red);g2.fill(filledPolygon);以上就是簡單的api和效果




Stroke
簡單說就是定義線寬/線類型用的
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.