comparison Color.m @ 655:ff745028d6bd feature/grids

Add some helpful properties to Color
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 24 Oct 2017 11:18:07 +0200
parents 283bdea202d2
children
comparison
equal deleted inserted replaced
654:6514c3b94721 655:ff745028d6bd
8 lightblue = [0.301 0.745 0.933]; 8 lightblue = [0.301 0.745 0.933];
9 darkred = [0.635 0.078 0.184]; 9 darkred = [0.635 0.078 0.184];
10 black = [0.000 0.000 0.000]; 10 black = [0.000 0.000 0.000];
11 white = [1.000 1.000 1.000]; 11 white = [1.000 1.000 1.000];
12 colors = { Color.blue, Color.red, Color.yellow, Color.green, Color.purple, Color.lightblue, Color.darkred, Color.black, Color.white}; 12 colors = { Color.blue, Color.red, Color.yellow, Color.green, Color.purple, Color.lightblue, Color.darkred, Color.black, Color.white};
13 markers = {'+', 'o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram'};
14 lineStyles = {'-', '--', ':', '-.'};
15
16 solidMarkers = {'o', 'square', 'diamond', 'v', 'pentagram', '^', '>', '<', 'hexagram'};
13 17
14 notabilityYellow = [100.0 99.0 22.0 ]/100; 18 notabilityYellow = [100.0 99.0 22.0 ]/100;
15 notabilityOrange = [97.0 61.0 15.0 ]/100; 19 notabilityOrange = [97.0 61.0 15.0 ]/100;
16 notabilityRed = [92.0 22.0 18.0 ]/100; 20 notabilityRed = [92.0 22.0 18.0 ]/100;
17 21
32 notabilityBlack = [0.0 0.0 0.0 ]/100; 36 notabilityBlack = [0.0 0.0 0.0 ]/100;
33 end 37 end
34 38
35 methods(Static) 39 methods(Static)
36 function sample() 40 function sample()
37 markers ={'+', 'o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram'};
38 % Filled and non-filled markers? 41 % Filled and non-filled markers?
39 lineStyles = {'-', '--', ':', '-.'};
40 42
41 43
42 function showMarkers(x0, y0, lx, ly, color, filled) 44 function showMarkers(x0, y0, lx, ly, color, filled)
43 n = length(markers); 45 n = length(Color.markers);
44 s = ceil(sqrt(n)); 46 s = ceil(sqrt(n));
45 47
46 x = linspace(x0, x0 + lx, s); 48 x = linspace(x0, x0 + lx, s);
47 y = linspace(y0, y0 + ly, s); 49 y = linspace(y0, y0 + ly, s);
48 50
49 [X,Y] = meshgrid(x,y); 51 [X,Y] = meshgrid(x,y);
50 52
51 for i = 1:n 53 for i = 1:n
52 lh = line(X(i),Y(i)); 54 lh = line(X(i),Y(i));
53 lh.Marker = markers{i}; 55 lh.Marker = Color.markers{i};
54 lh.MarkerSize = 12; 56 lh.MarkerSize = 12;
55 lh.Color = color; 57 lh.Color = color;
56 58
57 if filled 59 if filled
58 lh.MarkerFaceColor = color; 60 lh.MarkerFaceColor = color;
77 lh.MarkerSize = 12; 79 lh.MarkerSize = 12;
78 end 80 end
79 end 81 end
80 82
81 function showLines(y0, ly, A, w) 83 function showLines(y0, ly, A, w)
82 n = length(lineStyles); 84 n = length(Color.lineStyles);
83 x = linspace(0,1,100); 85 x = linspace(0,1,100);
84 y = linspace(y0, y0+ ly, n); 86 y = linspace(y0, y0+ ly, n);
85 for i = 1:n 87 for i = 1:n
86 lh = line(x, y(i) + A*sin(pi*x*w)); 88 lh = line(x, y(i) + A*sin(pi*x*w));
87 lh.LineWidth = 2; 89 lh.LineWidth = 2;
88 lh.LineStyle = lineStyles{i}; 90 lh.LineStyle = Color.lineStyles{i};
89 end 91 end
90 end 92 end
91 93
92 94
93 fh = figure(); 95 fh = figure();