matlabapp窗口图像_matlab – 如何自定义App Designer图形的背景?
>如果要為整個圖形設置純色背景顏色,則執行此操作需要
a documented way,例如:
% When creating a new uifigure:
fig = uifigure('Color',[R G B])
% if the uifigure already exists:
fig.Color = [R G B];
>如果你想改變一些地區的背景顏色,你可以添加一個沒有標題或邊框的uipanel(uipanel(…,’BorderType’,’none’,’Title’,”,’BackgroundColor’, [RGB])).
>如果要將圖像設置為整個圖形的背景:
function q41602238a
%% Turn off some warnings:
warning off Matlab:structOnObject
warning off Matlab:HandleGraphics:ObsoletedProperty:JavaFrame
%% 0. Create a uifigure:
app = uifigure();
%% 1. Get a handle to the webwindow:
while true
try
win = struct(struct(app).Controller).Container.CEF;
break
catch
pause(0.1); % Give the figure (webpage) some more time to load
end
end
%% 2. Find the data_tag of the DOM element we want to edit:
data_tag = char(struct(app).Controller.ProxyView.PeerNode.getId);
%% 3. Manipulate the DOM via a JS command
while true
try
win.executeJS(['dojo.style(dojo.query("[data-tag^=''' data_tag ''']")[0],"background-image","url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg")']);
break
catch
pause(0.1); % Maybe JS is still not ready.
end
end
結果:
>如果要將圖像設置為某個區域的背景:
function q41602238b
%% Turn off some warnings:
warning off Matlab:structOnObject
warning off Matlab:HandleGraphics:ObsoletedProperty:JavaFrame
%% 0. Create a some element:
app = uifigure();
pnl = uipanel(app);
%% 1. Get a handle to the webwindow:
while true
try
win = struct(struct(app).Controller).Container.CEF;
% disp(win.URL);
break
catch
pause(0.1); % Give the figure (webpage) some more time to load
end
end
%% 2. Find the id of the DOM element we want to edit:
data_tag = char(struct(pnl).Controller.ProxyView.PeerNode.getId);
widgetId = win.executeJS(['dojo.getAttr(dojo.query("[data-tag^=''' data_tag ''']")[0],"widgetid")']);
%% 3. Manipulate the DOM via a JS command
dojo_style_prefix = ['dojo.style(dojo.query("#' widgetId(2:end-1) '")[0],'];
while true
try
win.executeJS([dojo_style_prefix '"background-image","url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg")']);
break
catch
pause(0.1); % Maybe JS is still not ready.
end
end
結果:
筆記:
>最后兩個示例基于這兩個帖子:1,2,操作原理是在某些所需UI元素的樣式屬性中添加background-image:“…”條目(恰好是HTML DIV).
>可以在this GitHub存儲庫中找到用于編程操作App Designer圖形的工具.>示例圖像恰好是.svg,這很有趣,因為我們可以以這種格式導出“常規”MATLAB數字,然后將它們用作uifigure的背景:)
總結
以上是生活随笔為你收集整理的matlabapp窗口图像_matlab – 如何自定义App Designer图形的背景?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 月神的迷宫位阶怎么提升
- 下一篇: 二维有限元方程matlab,有限元法求解