-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds missing setMarkerOpacity fn and updates call, closes #16
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function setMarkerOpacity(s, faceAlpha, edgeAlpha) | ||
% stores information in UserData struct to cause saveFigure to render | ||
% marker points as translucent when exporting to svg | ||
if nargin < 3 | ||
edgeAlpha = faceAlpha; | ||
end | ||
|
||
for i = 1:length(s) | ||
% old version, simply tag it as translucent for saveFigure to pick | ||
% up during SVG authoring | ||
|
||
userdata = get(s(i),'UserData'); | ||
userdata.svg.MarkerFaceAlpha = faceAlpha; | ||
userdata.svg.MarkerEdgeAlpha = edgeAlpha; | ||
set(s(i),'UserData', userdata); | ||
|
||
if ~verLessThan('matlab', '8.4') | ||
mh = s.MarkerHandle; | ||
if ~isa(mh, 'matlab.graphics.GraphicsPlaceholder') | ||
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 | ||
|
||
% keep transparent | ||
addlistener(s(i),'MarkedClean',... | ||
@(ObjH, EventData) keepAlpha(ObjH, EventData, faceAlpha, edgeAlpha)); | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters