6788
|
1 ## Copyright (C) 1999,2000 Kai Habel |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
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 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
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. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {@var{map_out} =} brighten (@var{map}, @var{beta}) |
6792
|
22 ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{h}, @var{beta}) |
6788
|
23 ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta}) |
|
24 ## Darkens or brightens the given colormap. If the @var{map} argument |
|
25 ## is omitted, the function is applied to the current colormap. The first |
|
26 ## argument can also be a valid graphics handle @var{h}, in which case |
|
27 ## @code{brighten} is applied to the colormap associated with this handle. |
|
28 ## |
|
29 ## Should the resulting colormap @var{map_out} not be assigned, it will be |
|
30 ## written to the current colormap. |
|
31 ## |
|
32 ## The argument @var{beta} should be a scalar between -1 and 1, |
|
33 ## where a negative value darkens and a positive value brightens |
|
34 ## the colormap. |
|
35 ## @seealso{colormap} |
|
36 ## @end deftypefn |
|
37 |
|
38 function Rmap = brighten (m, beta) |
|
39 h = -1; |
|
40 if (nargin == 1) |
|
41 beta = m; |
|
42 m = colormap; |
|
43 h = gcf (); |
|
44 elseif (nargin == 2) |
|
45 if (ishandle (m)) |
|
46 h = m; |
|
47 m = get (h, "colormap"); |
|
48 elseif ((!is_matrix (m)) || (size (m, 2) != 3)) |
|
49 error ("First argument must be a matrix of size nx3 or a handle."); |
|
50 endif |
|
51 else |
|
52 print_usage (); |
|
53 endif |
|
54 |
6791
|
55 if ( (!isscalar (beta)) || (beta <= -1) || (beta >= 1) ) |
6788
|
56 error ("brighten(...,beta) beta must be a scalar in the range (-1,1)."); |
|
57 endif |
|
58 |
|
59 if (beta > 0) |
|
60 gamma = 1 - beta; |
|
61 else |
|
62 gamma = 1 / (1 + beta); |
|
63 endif |
|
64 |
|
65 if (nargout == 0) |
|
66 if (ishandle (h)) |
|
67 set (h, "colormap", m .^ gamma); |
|
68 else |
|
69 colormap (m .^ gamma); |
|
70 endif |
|
71 else |
|
72 Rmap = m .^ gamma; |
|
73 endif |
|
74 |
|
75 endfunction |