comparison scripts/image/pink.m @ 16465:e09e58e44c80

pink.m: Simplify calculation in colormap. * pink.m: Replace switch statement with simple division.
author Rik <rik@octave.org>
date Sun, 07 Apr 2013 17:24:53 -0700
parents 7762d56dbc8a
children d63878346099
comparison
equal deleted inserted replaced
16464:328048fd43b8 16465:e09e58e44c80
49 map = sqrt ([1/3, 1/3, 1/6 49 map = sqrt ([1/3, 1/3, 1/6
50 1 1 1 ]); 50 1 1 1 ]);
51 elseif (n > 2) 51 elseif (n > 2)
52 x = [0:(n-1)]' / (n-1); 52 x = [0:(n-1)]' / (n-1);
53 idx = floor (3/8 * n); 53 idx = floor (3/8 * n);
54 base = floor (n/8); 54 base = 1 / (3 * idx);
55 switch (mod (n, 8))
56 case {0, 1, 2}
57 base = 1 / (9*base);
58 case {3, 4, 5}
59 base = 1 / (9*base + 3);
60 case {6, 7}
61 base = 1 / (9*base + 6);
62 endswitch
63 55
64 nel = idx; # number of elements 56 nel = idx; # number of elements
65 r(1:idx,1) = linspace (base, 2/3*x(idx) + 1/3, nel); 57 r(1:idx,1) = linspace (base, 2/3*x(idx) + 1/3, nel);
66 r(idx+1:n,1) = 2/3*x(idx+1:n) + 1/3; 58 r(idx+1:n,1) = 2/3*x(idx+1:n) + 1/3;
67 59