1 ## Copyright (C) 1999-2012 Kai Habel
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {@var{map_out} =} brighten (@var{map}, @var{beta})
21 ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{h}, @var{beta})
22 ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta})
23 ## Darken or brighten the given colormap. If the @var{map} argument
24 ## is omitted, the function is applied to the current colormap. The first
25 ## argument can also be a valid graphics handle @var{h}, in which case
26 ## @code{brighten} is applied to the colormap associated with this handle.
28 ## Should the resulting colormap @var{map_out} not be assigned, it will be
29 ## written to the current colormap.
31 ## The argument @var{beta} should be a scalar between -1 and 1,
32 ## where a negative value darkens and a positive value brightens
37 function rmap = brighten (arg1, beta)
46 m = get (h, "colormap");
47 elseif (ismatrix (arg1) && columns (arg1) == 3)
50 error ("brighten: first argument must be an Nx3 matrix or a handle");
56 if (! isscalar (beta) || beta <= -1 || beta >= 1)
57 error ("brighten: BETA must be a scalar in the range (-1,1)");
63 gamma = 1 / (1 + beta);
68 set (h, "colormap", m .^ gamma);
70 colormap (m .^ gamma);