Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.awt.geom.*;
  4. import java.math.*;;
  5.  
  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(5.0f));
  13.       graph.setColor(Color.yellow);
  14.       Shape circle = new Ellipse2D.Float(100.0f, 100.0f, 500.0f, 500.0f);
  15.       graph.draw(circle);
  16.       graph.fill(circle);
  17.       //lines
  18.       double t;
  19.       int radius = 250;
  20.       double  x = 100 , y=250  , px , py;
  21.       //for(float i =  0 ; i < 60 ; i++) {
  22.       for(int a = 0; a <= 360; a+=20)
  23.          
  24.              {    
  25.          
  26.                 px = (int) (Math.cos(Math.toRadians(a)) * 600) + 350;        
  27.                  py = (int) (Math.sin(Math.toRadians(a)) * 600) + 350;
  28.  
  29.           Line2D line1 = new Line2D.Double(px, py, 350, 350);
  30.           graph.draw(line1);
  31.                      
  32.          
  33.                       }
  34.  
  35.     //    px = x * Math.cos(Math.toRadians(j)) + y * Math.sin(Math.toRadians(j));;
  36.         //  py = y * Math.cos(Math.toRadians(j)) - x *Math.sin(Math.toRadians(j));
  37.          
  38.       //}
  39. }
  40.     public static void main(String[] args) {
  41.           Frame frame = new ForWhile();
  42.          
  43.           frame.addWindowListener(
  44.                   new WindowAdapter(){
  45.                       public void windowClosing(WindowEvent we){
  46.                       System.exit(0);
  47.                      }
  48.                     }
  49.                   );
  50.           frame.setSize(1000, 1000);
  51.           frame.setVisible(true);
  52.     }
  53.    
  54.    
  55.    
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement