|
3 | 3 | % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES,
|
4 | 4 | % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS
|
5 | 5 |
|
6 |
| - %-AXIS STRUCTURE-% |
7 |
| - axis_data = ancestor(patch_data.Parent,'axes'); |
8 |
| - |
9 |
| - %-FIGURE STRUCTURE-% |
10 |
| - figure_data = ancestor(patch_data.Parent,'figure'); |
11 |
| - |
12 |
| - %-INITIALIZE OUTPUT-% |
13 | 6 | line = struct();
|
| 7 | + if patch_data.LineStyle == "none" |
| 8 | + return |
| 9 | + end |
14 | 10 |
|
15 |
| - %-PATCH LINE COLOR-% |
| 11 | + cLim = ancestor(patch_data.Parent, "axes").CLim; |
| 12 | + colormap = ancestor(patch_data.Parent, "figure").Colormap; |
| 13 | + faceVertexCData = patch_data.FaceVertexCData(1,1); |
| 14 | + cDataMapping = patch_data.CDataMapping; |
16 | 15 |
|
17 |
| - colormap = figure_data.Colormap; |
| 16 | + line.color = extractColor(patch_data.EdgeColor, cDataMapping, colormap, cLim, faceVertexCData); |
| 17 | + line.width = patch_data.LineWidth; |
| 18 | + line.dash = extractLineStyle(patch_data.LineStyle); |
| 19 | +end |
18 | 20 |
|
19 |
| - if (~strcmp(patch_data.LineStyle,'none')) |
20 |
| - if isnumeric(patch_data.EdgeColor) |
21 |
| - col = round(255*patch_data.EdgeColor); |
22 |
| - line.color = getStringColor(col); |
23 |
| - else |
24 |
| - switch patch_data.EdgeColor |
25 |
| - case 'none' |
26 |
| - line.color = 'rgba(0,0,0,0)'; |
27 |
| - case 'flat' |
28 |
| - switch patch_data.CDataMapping |
29 |
| - case 'scaled' |
30 |
| - capCD = max(min( ... |
31 |
| - patch_data.FaceVertexCData(1,1), ... |
32 |
| - axis_data.CLim(2)), axis_data.CLim(1)); |
33 |
| - scalefactor = (capCD - axis_data.CLim(1)) ... |
34 |
| - / diff(axis_data.CLim); |
35 |
| - col = round(255*(colormap(1+floor(scalefactor ... |
36 |
| - * (length(colormap)-1)),:))); |
37 |
| - case 'direct' |
38 |
| - col = round(255*(colormap( ... |
39 |
| - patch_data.FaceVertexCData(1,1),:))); |
40 |
| - end |
41 |
| - line.color = getStringColor(col); |
42 |
| - end |
| 21 | +function out = extractColor(color, cDataMapping, colormap, cLim, faceVertexCData) |
| 22 | + if isnumeric(color) |
| 23 | + out = getStringColor(round(255*color)); |
| 24 | + else |
| 25 | + switch color |
| 26 | + case "none" |
| 27 | + out = "rgba(0,0,0,0)"; |
| 28 | + case "flat" |
| 29 | + switch cDataMapping |
| 30 | + case "scaled" |
| 31 | + capCD = max(min(faceVertexCData, cLim(2)), cLim(1)); |
| 32 | + scalefactor = (capCD - cLim(1)) / diff(cLim); |
| 33 | + col = colormap(1+floor(scalefactor ... |
| 34 | + * (length(colormap)-1)),:); |
| 35 | + case "direct" |
| 36 | + col = colormap(faceVertexCData,:); |
| 37 | + end |
| 38 | + out = getStringColor(round(255*col)); |
43 | 39 | end
|
| 40 | + end |
| 41 | +end |
44 | 42 |
|
45 |
| - %-PATCH LINE WIDTH (STYLE)-% |
46 |
| - line.width = patch_data.LineWidth; |
47 |
| - |
48 |
| - %-PATCH LINE DASH (STYLE)-% |
49 |
| - switch patch_data.LineStyle |
50 |
| - case '-' |
51 |
| - LineStyle = 'solid'; |
52 |
| - case '--' |
53 |
| - LineStyle = 'dash'; |
54 |
| - case ':' |
55 |
| - LineStyle = 'dot'; |
56 |
| - case '-.' |
57 |
| - LineStyle = 'dashdot'; |
58 |
| - end |
59 |
| - line.dash = LineStyle; |
| 43 | +function out = extractLineStyle(lineStyle) |
| 44 | + switch lineStyle |
| 45 | + case "-" |
| 46 | + out = "solid"; |
| 47 | + case "--" |
| 48 | + out = "dash"; |
| 49 | + case ":" |
| 50 | + out = "dot"; |
| 51 | + case "-." |
| 52 | + out = "dashdot"; |
60 | 53 | end
|
61 | 54 | end
|
0 commit comments