-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchangeBuildingColor.m
62 lines (55 loc) · 2.5 KB
/
changeBuildingColor.m
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
function RiskGame = changeBuildingColor(RiskGame, buildingNumber, player)
[row, col, ch] = size(RiskGame(buildingNumber).image);
% figure(1);
% image(RiskGame(buildingNumber).image, 'AlphaData', RiskGame(buildingNumber).imgAlpha);
% axis('image', 'off');
% Case per player
switch player
% Changes building color to (1) light blue
case 1
for ir = 1:row
for ic = 1:col
if ((RiskGame(buildingNumber).image(ir,ic,1) > 100) && (RiskGame(buildingNumber).image(ir,ic,2) > 100)) && (RiskGame(buildingNumber).image(ir,ic,3) > 100)
RiskGame(buildingNumber).image(ir,ic,1) = 211;
RiskGame(buildingNumber).image(ir,ic,2) = 225;
RiskGame(buildingNumber).image(ir,ic,3) = 255;
end
end
end
% Changes building color to (2) light green
case 2
for ir = 1:row
for ic = 1:col
if ((RiskGame(buildingNumber).image(ir,ic,1) > 100) && (RiskGame(buildingNumber).image(ir,ic,2) > 100)) && (RiskGame(buildingNumber).image(ir,ic,3) > 100)
RiskGame(buildingNumber).image(ir,ic,1) = 235;
RiskGame(buildingNumber).image(ir,ic,2) = 255;
RiskGame(buildingNumber).image(ir,ic,3) = 211;
end
end
end
% Changes building color to (3) light red
case 3
for ir = 1:row
for ic = 1:col
if ((RiskGame(buildingNumber).image(ir,ic,1) > 100) && (RiskGame(buildingNumber).image(ir,ic,2) > 100)) && (RiskGame(buildingNumber).image(ir,ic,3) > 100)
RiskGame(buildingNumber).image(ir,ic,1) = 255;
RiskGame(buildingNumber).image(ir,ic,2) = 222;
RiskGame(buildingNumber).image(ir,ic,3) = 211;
end
end
end
% Changes building color to (4) light purple
case 4
for ir = 1:row
for ic = 1:col
if ((RiskGame(buildingNumber).image(ir,ic,1) > 100) && (RiskGame(buildingNumber).image(ir,ic,2) > 100)) && (RiskGame(buildingNumber).image(ir,ic,3) > 100)
RiskGame(buildingNumber).image(ir,ic,1) = 244;
RiskGame(buildingNumber).image(ir,ic,2) = 211;
RiskGame(buildingNumber).image(ir,ic,3) = 255;
end
end
end
end
% figure(2);
% image(RiskGame(buildingNumber).image, 'AlphaData', RiskGame(buildingNumber).imgAlpha);
% axis('image', 'off');