1######################################################################## 2## 3## Copyright (C) 2000-2021 The Octave Project Developers 4## 5## See the file COPYRIGHT.md in the top-level directory of this 6## distribution or <https://octave.org/copyright/>. 7## 8## This file is part of Octave. 9## 10## Octave is free software: you can redistribute it and/or modify it 11## under the terms of the GNU General Public License as published by 12## the Free Software Foundation, either version 3 of the License, or 13## (at your option) any later version. 14## 15## Octave is distributed in the hope that it will be useful, but 16## WITHOUT ANY WARRANTY; without even the implied warranty of 17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18## GNU General Public License for more details. 19## 20## You should have received a copy of the GNU General Public License 21## along with Octave; see the file COPYING. If not, see 22## <https://www.gnu.org/licenses/>. 23## 24######################################################################## 25 26## -*- texinfo -*- 27## @deftypefn {} {@var{map} =} pink () 28## @deftypefnx {} {@var{map} =} pink (@var{n}) 29## Create color colormap. This colormap varies from black to white with 30## shades of gray-pink. 31## 32## This colormap gives a sepia tone when used on grayscale images. 33## 34## The argument @var{n} must be a scalar. 35## If unspecified, the length of the current colormap, or 64, is used. 36## @seealso{colormap} 37## @end deftypefn 38 39function map = pink (n) 40 41 if (nargin > 1) 42 print_usage (); 43 elseif (nargin == 1) 44 if (! isscalar (n)) 45 error ("pink: N must be a scalar"); 46 endif 47 n = double (n); 48 else 49 hf = get (0, "currentfigure"); 50 if (! isempty (hf)) 51 n = rows (get (hf, "colormap")); 52 else 53 n = 64; 54 endif 55 endif 56 if (n == 1) 57 map = sqrt ([1/3, 1/3, 1/3]); 58 elseif (n == 2) 59 map = sqrt ([1/3, 1/3, 1/6 60 1 1 1 ]); 61 elseif (n > 2) 62 x = [0:(n-1)]' / (n-1); 63 idx = floor (3/8 * n); 64 base = 1 / (3 * idx); 65 66 nel = idx; # number of elements 67 r(1:idx,1) = linspace (base, 2/3*x(idx) + 1/3, nel); 68 r(idx+1:n,1) = 2/3*x(idx+1:n) + 1/3; 69 70 g(1:idx,1) = 2/3*x(1:idx); 71 g(idx:2*idx,1) = linspace (2/3*x(idx), 2/3*x(2*idx) + 1/3, nel+1); 72 g(2*idx+1:n,1) = 2/3*x(2*idx+1:n) + 1/3; 73 74 nel = n - 2*idx + 1; 75 b(1:2*idx,1) = 2/3*x(1:2*idx); 76 b(2*idx:n,1) = linspace (2/3*x(2*idx), 1, nel); 77 78 map = sqrt ([r, g, b]); 79 else 80 map = zeros (0, 3); 81 endif 82 83endfunction 84 85 86%!demo 87%! ## Show the 'pink' colormap profile and as an image 88%! cmap = pink (256); 89%! subplot (2, 1, 1); 90%! rgbplot (cmap, "composite"); 91%! subplot (2, 1, 2); 92%! rgbplot (cmap); 93