Mercurial > hg > octave-nkf
changeset 14640:b9c02ee24de1
new colormap options
* colormap.m: New options, list, register, and unregister.
* NEWS: Note new colormap options.
* autumn.m, bone.m, cool.m, copper.m, flag.m, gmap40.m, gray.m, hot.m,
hsv.m, jet.m, lines.m, ocean.m, pink.m, prism.m, rainbow.m,
spring.m, summer.m, winter: Always size and return 0x3 when size < 1.
Include PKD_ADD and PKG_DEL commands to register and unregister
colormap funtions.
author | Carnë Draug <carandraug+dev@gmail.com> |
---|---|
date | Wed, 16 May 2012 16:52:08 -0400 |
parents | 87a50e7cec7a |
children | 5f1d4def40e1 |
files | NEWS scripts/image/autumn.m scripts/image/bone.m scripts/image/colormap.m scripts/image/cool.m scripts/image/copper.m scripts/image/flag.m scripts/image/gmap40.m scripts/image/gray.m scripts/image/hot.m scripts/image/hsv.m scripts/image/jet.m scripts/image/lines.m scripts/image/ocean.m scripts/image/pink.m scripts/image/prism.m scripts/image/rainbow.m scripts/image/spring.m scripts/image/summer.m scripts/image/white.m scripts/image/winter.m |
diffstat | 21 files changed, 87 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -89,6 +89,11 @@ static + ** The colormap function now provides new options "list", "register", + and "unregister" to list all available colormap functions, and to + add or remove a function name from teh list of known colormap + functions. Packages that implement extra colormaps should use these + commands with PKG_ADD and PKG_DEL statements. Summary of important user-visible changes for version 3.6: ---------------------------------------------------------
--- a/scripts/image/autumn.m +++ b/scripts/image/autumn.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "autumn"); +## PKG_DEL: colormap ("unregister", "autumn"); + function map = autumn (n) if (nargin == 0)
--- a/scripts/image/bone.m +++ b/scripts/image/bone.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "bone"); +## PKG_DEL: colormap ("unregister", "bone"); + function map = bone (n) if (nargin == 0)
--- a/scripts/image/colormap.m +++ b/scripts/image/colormap.m @@ -1,4 +1,5 @@ ## Copyright (C) 1994-2012 John W. Eaton +## Copyright (C) 2012 Carnë Draug ## ## This file is part of Octave. ## @@ -20,6 +21,9 @@ ## @deftypefn {Function File} {@var{cmap} =} colormap () ## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{map}) ## @deftypefnx {Function File} {@var{cmap} =} colormap ("default") +## @deftypefnx {Function File} {@var{cmap} =} colormap ("list") +## @deftypefnx {Function File} {@var{cmap} =} colormap ("register", "name") +## @deftypefnx {Function File} {@var{cmap} =} colormap ("unregister", "name") ## Query or set the current colormap. ## ## @code{colormap (@var{map})} sets the current colormap to @var{map}. The @@ -30,6 +34,10 @@ ## @code{colormap ("default")} restores the default colormap (the ## @code{jet} map with 64 entries). The default colormap is returned. ## +## @code{colormap ("list")} returns a cell array with all the available +## colormaps. The options `register' and `unregister' will add or remove the +## colormap @var{name} to it. +## ## With no arguments, @code{colormap} returns the current color map. ## @seealso{jet} ## @end deftypefn @@ -38,17 +46,22 @@ ## Created: July 1994 ## Adapted-By: jwe -function cmap = colormap (map) +function cmap = colormap (map, name) - if (nargin > 1) + if (nargin > 2) print_usage (); endif + persistent map_list = cell (); + if (nargin == 1) if (ischar (map)) if (strcmp (map, "default")) map = jet (64); + elseif (strcmp (map, "list")) + cmap = map_list; + return; else map = feval (map); endif @@ -65,6 +78,16 @@ set (gcf (), "colormap", map); endif + elseif (nargin == 2) + if (! ischar (map) || all (! strcmp (map, {"register", "unregister"}))) + print_usage (); + elseif (! ischar (name)) + error ("colormap: to register/unregister a colormap, NAME must be a string"); + elseif (strcmp (map, "register")) + map_list{end+1} = name; + elseif (strcmp (map, "unregister")) + map_list(strcmp (name, map_list)) = []; + endif endif ## Return current color map.
--- a/scripts/image/cool.m +++ b/scripts/image/cool.m @@ -27,6 +27,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "cool"); +## PKG_DEL: colormap ("unregister", "cool"); + function map = cool (n) if (nargin == 0)
--- a/scripts/image/copper.m +++ b/scripts/image/copper.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "copper"); +## PKG_DEL: colormap ("unregister", "copper"); + function map = copper (n) if (nargin == 0)
--- a/scripts/image/flag.m +++ b/scripts/image/flag.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "flag"); +## PKG_DEL: colormap ("unregister", "flag"); + function map = flag (n) if (nargin == 0)
--- a/scripts/image/gmap40.m +++ b/scripts/image/gmap40.m @@ -28,6 +28,9 @@ ## @seealso{colormap} ## @end deftypefn +## PKG_ADD: colormap ("register", "gmap40"); +## PKG_DEL: colormap ("unregister", "gmap40"); + function map = gmap40 (n) if (nargin == 0)
--- a/scripts/image/gray.m +++ b/scripts/image/gray.m @@ -30,6 +30,9 @@ ## Created: July 1994 ## Adapted-By: jwe +## PKG_ADD: colormap ("register", "gray"); +## PKG_DEL: colormap ("unregister", "gray"); + function map = gray (n) if (nargin == 0)
--- a/scripts/image/hot.m +++ b/scripts/image/hot.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "hot"); +## PKG_DEL: colormap ("unregister", "hot"); + function map = hot (n) if (nargin == 0)
--- a/scripts/image/hsv.m +++ b/scripts/image/hsv.m @@ -32,6 +32,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "hsv"); +## PKG_DEL: colormap ("unregister", "hsv"); + function map = hsv (n) if (nargin == 0)
--- a/scripts/image/jet.m +++ b/scripts/image/jet.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "jet"); +## PKG_DEL: colormap ("unregister", "jet"); + function map = jet (n) if (nargin == 0)
--- a/scripts/image/lines.m +++ b/scripts/image/lines.m @@ -27,6 +27,9 @@ ## @seealso{colormap} ## @end deftypefn +## PKG_ADD: colormap ("register", "lines"); +## PKG_DEL: colormap ("unregister", "lines"); + function map = lines (n) if (nargin == 0)
--- a/scripts/image/ocean.m +++ b/scripts/image/ocean.m @@ -30,6 +30,9 @@ ## Created: July 1994 ## Adapted-By: jwe +## PKG_ADD: colormap ("register", "ocean"); +## PKG_DEL: colormap ("unregister", "ocean"); + function map = ocean (n) if (nargin == 0)
--- a/scripts/image/pink.m +++ b/scripts/image/pink.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "pink"); +## PKG_DEL: colormap ("unregister", "pink"); + function map = pink (n) if (nargin == 0)
--- a/scripts/image/prism.m +++ b/scripts/image/prism.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "prism"); +## PKG_DEL: colormap ("unregister", "prism"); + function map = prism (n) if (nargin == 0)
--- a/scripts/image/rainbow.m +++ b/scripts/image/rainbow.m @@ -31,6 +31,9 @@ ## this colormap is not part of matlab, it is like the prism ## colormap map but with a continuous map +## PKG_ADD: colormap ("register", "rainbow"); +## PKG_DEL: colormap ("unregister", "rainbow"); + function map = rainbow (n) if (nargin == 0)
--- a/scripts/image/spring.m +++ b/scripts/image/spring.m @@ -27,6 +27,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> +## PKG_ADD: colormap ("register", "spring"); +## PKG_DEL: colormap ("unregister", "spring"); + function map = spring (n) if (nargin == 0)
--- a/scripts/image/summer.m +++ b/scripts/image/summer.m @@ -28,6 +28,9 @@ ## Author: Kai Habel <kai.habel@gmx.de> ## Date: 06/03/2000 +## PKG_ADD: colormap ("register", "summer"); +## PKG_DEL: colormap ("unregister", "summer"); + function map = summer (n) if (nargin == 0)