Advertisement
daniv1

Untitled

Mar 30th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.awt.geom.*;
  4. import java.math.*;
  5. import java.lang.*;
  6.  
  7. public class ForWhile extends Frame {
  8.    
  9.  
  10. public void paint(Graphics g) {
  11.     Graphics2D graph = (Graphics2D)g;
  12.       graph.setStroke(new BasicStroke(3.0f));
  13.       graph.setColor(Color.black);
  14.       Shape circle = new Ellipse2D.Float(100.0f, 100.0f, 500.0f, 500.0f);
  15.       Shape circle1 = new Ellipse2D.Float(150.0f, 150.0f, 400.0f, 400.0f);
  16.       graph.draw(circle);
  17.       //lines
  18.       double  px , py;
  19.       //for(float i =  0 ; i < 60 ; i++) {
  20.       for(double a = 0; a <= 360; a+=30)
  21.          
  22.              {    
  23.          
  24.                 px = (int) (Math.cos(Math.toRadians(a)) * 250) + 350;        
  25.                  py = (int) (Math.sin(Math.toRadians(a)) * 250) + 350;
  26.  
  27.           Line2D line1 = new Line2D.Double(px, py, 350, 350);
  28.           graph.draw(line1);
  29.                      
  30.          
  31.    
  32.              }
  33.       graph.setPaint(Color.WHITE);
  34.       graph.draw(circle1);
  35.       graph.fill(circle1);
  36.      
  37.       }
  38.  
  39.    
  40.      
  41.  
  42.     public static void main(String[] args) {
  43.           Frame frame = new ForWhile();
  44.          
  45.           frame.addWindowListener(
  46.                   new WindowAdapter(){
  47.                       public void windowClosing(WindowEvent we){
  48.                       System.exit(0);
  49.                      }
  50.                     }
  51.                   );
  52.           frame.setSize(1000, 1000);
  53.           frame.setVisible(true);
  54.     }
  55.    
  56.    
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement