- 80 名前:デフォルトの名無しさん mailto:sage [2007/05/27(日) 01:20:03 ]
- >>79
よく知らんがGraphics2DじゃないGraphicsって組み込み用VMとか? public class LineTest extends javax.swing.JComponent { private void drawLine(java.awt.Graphics g, int x1, int y1, int x2, int y2, int width) { double x = x2 - x1, y = y2 - y1, d = 2 * Math.hypot(x, y) / width; int xx = (int)(x / d), yy = (int)(y / d); java.awt.Polygon polygon = new java.awt.Polygon(); polygon.addPoint(x1-yy, y1+xx); polygon.addPoint(x1+yy, y1-xx); polygon.addPoint(x2+yy, y2-xx); polygon.addPoint(x2-yy, y2+xx); g.fillPolygon(polygon); g.drawPolygon(polygon); } public static void main(String[] args) { javax.swing.JFrame f = new javax.swing.JFrame(); f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); f.add(new LineTest()); f.setSize(250, 250); f.setVisible(true); } protected void paintComponent(java.awt.Graphics g) { for (int i = 60; i <= 180; i += 20) { drawLine(g, 240 - i, 180, i, 60, (i-40)/15); drawLine(g, 60, i, 180, 240 - i, (i-40)/15); } } }
|

|