diff --git a/+PlotID/TagPlot.m b/+PlotID/TagPlot.m index d940a5dc29e9cc7b4869e9f86eab8721b37437ed..e955632ae8f059056dd4c2891995fe6909566751 100644 --- a/+PlotID/TagPlot.m +++ b/+PlotID/TagPlot.m @@ -24,6 +24,8 @@ arguments options.Position (1,2) {mustBeVector} = [1,0.4] % default for east options.Rotation (1,1) {mustBeReal} = NaN options.ConfigFileName (1,:) {mustBeText} = 'config.json' + options.QRcode (1,1) {mustBeNumericOrLogical} = false %experimentally + options.QRsize (1,1) {mustBeNonnegative} = 0.15 end if isempty(options.ProjectID) @@ -73,16 +75,24 @@ IDs = cell(numel(figs),1); for n = 1:numel(figs) IDs{n} = PlotID.CreateID; % Create ID IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID - axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation + pltAxes = get(figs(n),'CurrentAxes'); % Axes object for text annotation % Limits for relative Positioning - ylim =get(axes,'YLim'); - xlim =get(axes,'XLim'); + ylim =get(pltAxes,'YLim'); + xlim =get(pltAxes,'XLim'); %ID position = [options.Position(1), options.Position(2)]; - text(axes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,... + t=text(pltAxes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,... 'Rotation',Rotation, 'VerticalAlignment','bottom','Color',... options.Color,'BackgroundColor','w', 'Units', 'normalized'); - set(figs(n),'Tag', IDs{n}); + set(figs(n),'Tag', IDs{n}); + + if options.QRcode + qrCode = PlotID.plotQR(IDs{n}); + size = options.QRsize; + axes('Position',[position(1)-.05 position(2)+0.1 size size]); + imshow(qrCode); + t.Visible = 'off'; + end end if numel(figs) == 1 diff --git a/+PlotID/plotQR.m b/+PlotID/plotQR.m new file mode 100644 index 0000000000000000000000000000000000000000..1b30acb7310626f7af72fb5d532aec87abbacaa4 --- /dev/null +++ b/+PlotID/plotQR.m @@ -0,0 +1,22 @@ +function img = plotQR(data, size) +%QR reads a QR code from qrserver +% created by J.Stifter + arguments + data {mustBeTextScalar} = 'example'; + size (1,2) {mustBeInteger} = [150, 150]; + end + + m = size(1); + n = size(2); + + base_api = 'https://api.qrserver.com/v1/create-qr-code/?size=%dx%d&data=%s'; + request = sprintf(base_api, m, n, data); + + options = weboptions; + options.Timeout = 5; + + img = webread(request, options); + img =logical(img); + +end +