Advertisement
daniv1

Untitled

Mar 30th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 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.       graph.draw(circle);
  16.       //lines
  17.       double  px , py;
  18.       //for(float i =  0 ; i < 60 ; i++) {
  19.       for(double a = 0; a <= 360; a+=5)
  20.          
  21.              {    
  22.          
  23.                 px = (int) (Math.cos(Math.toRadians(a)) * 250) + 350;        
  24.                  py = (int) (Math.sin(Math.toRadians(a)) * 250) + 350;
  25.  
  26.           Line2D line1 = new Line2D.Double(px, py, 350, 350);
  27.           graph.draw(line1);
  28.                      
  29.          
  30.    
  31.              }
  32.       }
  33.  
  34.    
  35.      
  36.  
  37.     public static void main(String[] args) {
  38.           Frame frame = new ForWhile();
  39.          
  40.           frame.addWindowListener(
  41.                   new WindowAdapter(){
  42.                       public void windowClosing(WindowEvent we){
  43.                       System.exit(0);
  44.                      }
  45.                     }
  46.                   );
  47.           frame.setSize(1000, 1000);
  48.           frame.setVisible(true);
  49.     }
  50.    
  51.    
  52.    
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement