-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpiro.java
More file actions
99 lines (78 loc) · 2.43 KB
/
Spiro.java
File metadata and controls
99 lines (78 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Copyright © 2011 Parag Patil
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* You may not use this file except in compliance with Apache License, Version 2.0
* You may obtain a copy of the license at
* http://www.apache.org/licenses/LICENSE-2.0
**/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Random;
import java.util.ArrayList;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
public class Spiro {
public static void main(String[] args) {
PFrame pframe = new PFrame();
}
}
class PFrame extends JFrame {
private PCanvas canvas;
PFrame() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUndecorated(true);
canvas = new PCanvas(screenSize.width, screenSize.height);
add(canvas);
setVisible(true);
this.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.exit(0);
}
}
});
}
public PCanvas getCanvas() {
return canvas;
}
}
class PCanvas extends Canvas {
private int x;
private int y;
public static int SIZE_X;
public static int SIZE_Y;
private double R1 = 257;
private double R2 = 111;
private double R3 = 123;
private double RA1 = 133;
private double RA2 = 246;
private BufferedImage img;
PCanvas(int sizex, int sizey) {
SIZE_X = sizex;
SIZE_Y = sizey;
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
setCursor(blankCursor);
setBackground(Color.black);
setForeground(Color.white);
}
public void paint(Graphics g) {
for (double theta1 = 0 ; theta1 < 360; theta1+=.001) {
double theta2=RA1 * theta1;
double theta3=RA2 * theta1;
g.fillOval(SIZE_X/2 - (int)(R1 * Math.cos(Math.toRadians(theta1))
- R2 * Math.cos(Math.toRadians(theta2)))
,SIZE_Y/2 - (int)(R1 * Math.sin(Math.toRadians(theta1))
- R2 * Math.sin(Math.toRadians(theta2)))
,1
,1);
}
}
}