changeset 122:54cf593d6643

Added method for showing plotting samples in Color.
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 18 Dec 2015 11:28:53 +0100
parents ceba6be0389f
children edccf4ba788b
files Color.m
diffstat 1 files changed, 77 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r ceba6be0389f -r 54cf593d6643 Color.m
--- a/Color.m	Fri Dec 18 11:28:07 2015 +0100
+++ b/Color.m	Fri Dec 18 11:28:53 2015 +0100
@@ -10,4 +10,81 @@
         black     = [0.000 0.000 0.000];
         white     = [1.000 1.000 1.000];
     end
+
+    methods(Static)
+        function sample()
+            markers ={'+', 'o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram'};
+            % Filled and non-filled markers?
+            lineStyles = {'-', '--', ':', '-.'};
+            colors = { Color.blue, Color.red, Color.yellow, Color.purple, Color.green, Color.lightblue, Color.darkred, Color.black, Color.white};
+
+
+            function showMarkers(x0, y0, lx, ly, color, filled)
+                n = length(markers);
+                s = ceil(sqrt(n));
+
+                x = linspace(x0, x0 + lx, s);
+                y = linspace(y0, y0 + ly, s);
+
+                [X,Y] = meshgrid(x,y);
+
+                for i = 1:n
+                    lh = line(X(i),Y(i));
+                    lh.Marker = markers{i};
+                    lh.MarkerSize = 12;
+                    lh.Color = color;
+
+                    if filled
+                        lh.MarkerFaceColor = color;
+                    end
+                end
+            end
+
+            function showColors(x0, y0, lx, ly)
+                n = length(colors);
+                s = ceil(sqrt(n));
+
+                x = linspace(x0, x0 + lx, s);
+                y = linspace(y0, y0 + ly, s);
+
+                [X,Y] = meshgrid(x,y);
+
+                for i = 1:n
+                    lh = line(X(i),Y(i));
+                    lh.Marker = 'o';
+                    lh.MarkerFaceColor = colors{i};
+                    lh.Color = colors{i};
+                    lh.MarkerSize = 12;
+                end
+            end
+
+            function showLines(y0, ly, A, w)
+                n = length(lineStyles);
+                x = linspace(0,1,100);
+                y = linspace(y0, y0+ ly, n);
+                for i = 1:n
+                    lh = line(x, y(i) + A*sin(pi*x*w));
+                    lh.LineWidth = 2;
+                    lh.LineStyle = lineStyles{i};
+                end
+            end
+
+
+            fh = figure();
+
+            y0 = 0.1;
+            dl = 0.15;
+            margin = 0.07;
+            showMarkers(     0.1, y0, dl, dl, Color.blue, false);
+            showMarkers(  0.9-dl, y0, dl, dl, Color.blue,  true);
+            showColors( 0.5-dl/2, y0, dl, dl);
+
+            showLines(0.6, 0.2, 0.1, 5);
+
+            xlim([0 1])
+            ylim([0 1])
+            axis square
+
+        end
+    end
 end
\ No newline at end of file