-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsw_Lab10_B.m
More file actions
35 lines (32 loc) · 825 Bytes
/
csw_Lab10_B.m
File metadata and controls
35 lines (32 loc) · 825 Bytes
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
%Lab 10 B: Knight's Moves
clc;clear;
img=uint8(zeros(800,800,3));
[h,w,c]=size(img);
row = input('Enter the row the knight is on: ');
col = input('Enter the column the knight is on: ');
row = row*100-99;
col = col*100-99;
count = 1;
for ii=1:100:800
for jj=1:100:800
if count==1
img(ii:ii+99,jj:jj+99,:)=255;
count=0;
else
img(ii:ii+99,jj:jj+99,:)=0;
count=1;
end
if (abs(row-ii)==200 && abs(col-jj)==100) || (abs(row-ii)==100 && abs(col-jj)==200)
img(ii:ii+99,jj:jj+99,1:2)=255;
img(ii:ii+99,jj:jj+99,3)=0;
end
end
if count==1
count = 0;
else
count=1;
end
end
img(row:row+99,col:col+99,1)=255;
img(row:row+99,col:col+99,2:3)=0;
imshow(img)