1## Copyright (C) 1999, 2000, 2007, 2009 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## Darkens or brightens 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
37function Rmap = brighten (m, beta)
46 m = get (h, "colormap");
47 elseif (! is_matrix (m) || size (m, 2) != 3)
48 error ("brighten: first argument must be an Nx3 matrix or a handle");
54 if (! isscalar (beta) || beta <= -1 || beta >= 1)
55 error ("brighten: beta must be a scalar in the range (-1,1)");
61 gamma = 1 / (1 + beta);
66 set (h, "colormap", m .^ gamma);
68 colormap (m .^ gamma);