-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVanishingLine.java
More file actions
64 lines (54 loc) · 1.4 KB
/
Copy pathVanishingLine.java
File metadata and controls
64 lines (54 loc) · 1.4 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
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* Lab 8 Vanishing Lines animation. used from lab 8.
*
* @author Grant Visker and Jordan Breen
* @Version Fall 2021
*/
class VanishingLine extends AnimatedLine {
private int fadeSpeed = 25;
private Color currColor = Color.black;
public VanishingLine(Point startPoint, Point endPoint, JComponent container)
{
super(startPoint, endPoint, container);
}
@Override
public void paint(Graphics g)
{
if(!done)
{
g.setColor(this.currColor);
g.drawLine(location[0].x, location[0].y, location[1].x, location[1].y);
}
}
@Override
public void run()
{
try
{
sleep(30);
}
catch (InterruptedException e)
{}
while (currColor.getRed() + fadeSpeed <= 255 &&
currColor.getGreen() + fadeSpeed <= 255 &&
currColor.getBlue() + fadeSpeed <= 255)
{
try
{
sleep(DELAY_TIME);
}
catch (InterruptedException e)
{}
currColor = new Color(currColor.getRed() + fadeSpeed,
currColor.getGreen() + fadeSpeed,
currColor.getBlue() + fadeSpeed);
container.repaint();
}
done = true;
}
}