-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPulsePix.java
102 lines (92 loc) · 1.46 KB
/
PulsePix.java
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
100
101
102
/**
* PulsePix Class
* Pix set their default value to 100 after reaching maximum
* @author Nic Manoogian <zimmoz3@verizon.net>
* @author Mike Lyons
*/
public class PulsePix extends Pix
{
/**
* Constructs a PulsePix with random RGB values using super class
*/
public PulsePix()
{
super();
}
/**
* Constructs a PulsePix with given RGB values using the super class
* @param r red channel
* @param g green channel
* @param b blue channel
*/
public PulsePix(int r, int g, int b)
{
super(r,g,b);
}
/**
* Changes both Pix objects with respect to dominant channel
* @param p Pix interactee
*/
public void interact(Pix p)
{
changeWithChannel(getDomChannel());
p.changeWithChannel(p.getDomChannel());
}
/**
* Increases dominant channel, does not decrease non-dom
* @param channel dominant channel
*/
public void changeWithChannel(int channel)
{
switch (channel)
{
case 0:
//Inc dominant
if (red + 1 <= 255)
{
red += 1;
}
else
{
setPix(100,0,0);
}
break;
case 1:
//Inc dominant
if (blue + 1 <= 255)
{
blue += 1;
}
else
{
setPix(0,0,100);
}
break;
case 2:
//Inc dominant
if (green + 1 <= 255)
{
green += 1;
}
else
{
setPix(0,100,0);
}
break;
case -1:
if (red < 255)
{
red++;
}
if (green < 255)
{
green++;
}
if (blue < 255)
{
blue++;
}
break;
}
}
}