-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsetLineOpacity.m
51 lines (44 loc) · 1.57 KB
/
setLineOpacity.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function setLineOpacity(s, alpha)
% setLineOpacity(hLine, alpha)
% [edge, face] = deal(cell(numel(s), 1));
for i = 1:numel(s)
% tag it as translucent for saveFigure to
% pick up during SVG authoring
% userdata = get(s(i),'UserData');
% userdata.svg.LineAlpha = alpha;
% set(s(i),'UserData', userdata);
if ~verLessThan('matlab', '8.4')
% % first cache marker opacity
% if isempty(s(i).MarkerHandle) && ~isa(s(i).MarkerHandle, 'matlab.graphics.GraphicsPlaceholder')
% edge{i} = s(i).MarkerHandle.EdgeColorData;
% face{i} = s(i).MarkerHandle.FaceColorData;
% end
% use RGBA color specification
s(i).Color(4) = alpha;
% % keep transparent
% addlistener(s(i),'MarkedClean',...
% @(ObjH, EventData) keepAlpha(ObjH, EventData, faceAlpha, edgeAlpha));
end
end
% drawnow;
%
% for i = 1:length(s)
% if ~isempty(edge{i})
% s(i).MarkerHandle.EdgeColorData = edge;
% s(i).MarkerHandle.FaceColorData = face;
% end
% end
end
%
% function keepAlpha(src, ~, faceAlpha, edgeAlpha)
% mh = src.MarkerHandle;
% if ~isempty(mh.EdgeColorData)
% mh.EdgeColorType = 'truecoloralpha';
% mh.EdgeColorData(4) = uint8(edgeAlpha*255);
% end
% if ~isempty(mh.FaceColorData)
% mh.FaceColorType = 'truecoloralpha';
% mh.FaceColorData(4) = uint8(faceAlpha*255);
% end
% end
%