📄 generalpath.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class generalPath extends JFrame {
public generalPath (){
super( "Drawing 2D Shapes" );
setSize( 340, 340 );
setVisible( true );
}
public void paint( Graphics g ) {
super.paint( g );
int xPoints[] ={ 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 };
int yPoints[] ={ 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 };
Graphics2D g2d = ( Graphics2D ) g;
GeneralPath star = new GeneralPath();
star.moveTo( xPoints[ 0 ], yPoints[ 0 ] );
for ( int count = 1; count < xPoints.length; count++ )
star.lineTo( xPoints[ count ], yPoints[ count ] );
star.closePath();
g2d.translate( 170, 170 );
for ( int count = 1; count <= 20; count++ ) {
g2d.rotate( Math.PI / 10.0 );
g2d.setColor( new Color(( int ) ( Math.random() * 256 ),( int ) ( Math.random() * 256 ),( int ) ( Math.random() * 256 ) ) );
g2d.fill( star );
}
} // end method paint
public static void main( String args[] ){
generalPath application = new generalPath ();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -