Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import java.applet.Applet;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.geom.Ellipse2D;
  5. // import java.awt.geom.Ellipse2D.Double;
  6.  
  7. public class Slinkey extends Applet {
  8. private static final long serialVersionUID = 4803949557086825455L;
  9.  
  10. public void paint(Graphics g) {
  11. Graphics2D g2 = (Graphics2D) g;
  12.  
  13. int x = 10;
  14. int y = 10;
  15. int w = 100;
  16. int h = 100;
  17. int k = 0;
  18. int otherX = 0;
  19. double xpos = 0, ypos = 10;
  20.  
  21. System.out.println(xpos + " " + ypos);
  22.  
  23. Ellipse2D.Double c1 = new Ellipse2D.Double(ypos, ypos, w, h);
  24.  
  25.  
  26. for (k = 0; k < 155; k += 5) {
  27. xpos = x + k;
  28. ypos = getYStart(xpos);
  29.  
  30. System.out.println(xpos + " " + ypos);
  31.  
  32. c1.setFrame(xpos, ypos, w, h); // (10, 10) (Top left corner) (1325, 650) (Bottom right corner).
  33. g2.draw(c1);
  34. }
  35.  
  36. for (double i = 160; i < 1325; i++) {
  37. xpos = x + i;
  38.  
  39. ypos = getYMain(otherX);
  40.  
  41. otherX++;
  42.  
  43. System.out.println("Y Coordinate: " + xpos + " " + ypos);
  44.  
  45. if (ypos < 652) {
  46. c1.setFrame(xpos, ypos, w, h);
  47. g2.draw(c1);
  48.  
  49. }
  50.  
  51. }
  52.  
  53.  
  54. }
  55. public static double getYStart(double x) { // Starting trajectory.
  56.  
  57. return (0.029) * (Math.pow(x - 10, 2) + 10);
  58. }
  59.  
  60. public static double getYMain(double x) { // Main equation that is causing problems.
  61. return (Math.pow(x - 100, 2) + 10);
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement