1 ## Copyright (C) 2010-2012 Etienne Grossmann <etienne@egdn.net>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
16 ## col = checker_color (R,C, checker, col)
18 function col = checker_color (checker, col, R,C)
20 if length (checker) == 1, checker = [checker, checker]; end
22 if checker(1) > 0, checker(1) = - (C-1)/checker(1); end
23 if checker(2) > 0, checker(2) = - (R-1)/checker(2); end
27 colx = 2 * (rem (0:C-2,2*checker(1)) < checker(1)) - 1;
28 coly = 2 * (rem (0:R-2,2*checker(2)) < checker(2)) - 1;
29 icol = 1 + ((coly'*colx) > 0);
30 # Keep at most 1st 2 colors of col for the
32 if prod (size (col)) == 2,
34 elseif prod (size (col)) < 6, # Can't be < 3 because of previous code
36 if all (col >= 1-eps), col = [col [0;0;0]]; # Black and White
37 else col = [col [1;1;1]]; # X and White
40 col = reshape (col(:),3,2);