Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Matlab re-engraving sign to refuel villain generator

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use Matlab re-engraving card refueling villain generator", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Matlab re-engraving card refueling villain generator" this article.

Suddenly found that the cla function can also be applied to the app designer control, so some of the content has been changed.

Hand itching, with matlab app designer re-engraved a sign refueling villain generator, the effect is as follows:

The program can generate square and rectangular sign villains, and can set their own background color (click on those small colored boxes), click the green rotate button to refresh the resulting picture.

Currently, you need to save the image or use the toolbar that comes with uiaxes (shown in the upper right corner of the following figure):

To use this program, you need the villain's material package. I have organized the material into a materials.mat file. The download link of the network disk is as follows:

Link: https://pan.baidu.com/s/1ISloOsq8bIVDjm8TzRPlKw

Extraction code: 1234

When using, you need to put the materials.mat and m files in the same folder.

Complete code

Function upupglobal textMsg bkgColor colorList axesTypeglobal textAreatextMsg= []; axesType=2;bkgColor= [1] ColorList= [0.9000 0 0.0700 0.9200 0.3300 0.0800 0.9600 0.6200 0.7500 0.9600 0.9400 0.5500 0.7600 0.8400 0.2500 0.3800 0.7600 0.7300 0.4700 0.8100 0.9400 0.6000 0.0500 0.4900 1 1];% load pic and create pic = = materials=load ('materials.mat') If ~ exist ('materials','dir') mkdir (' materials'); endfor i=1:size (colorList,1) Rc=zeros (60 materials'); Rc (1150) = 255.*colorList (iMag1); Gc=zeros (60); Gc (1150) = 255.*colorList (iMag2); Bc=zeros (60); Bc (1150) = 255.*colorList (iMag3); cPic (:,: 1) = Rc;cPic (:,:, 2) = Gc CPic (:,:, 3) = Bc; imwrite (uint8 (cPic), ['materials\ bkg',num2str (I),' .png']) endimwrite (materials.imgSet.cover,'materials\ cover.jpg') imwrite (materials.imgSet.square,'materials\ square.jpg') imwrite (materials.imgSet.refresh.CData,'materials\ refresh.png','Alpha',materials.imgSet.refresh.AData)% = upFig=uifigure ('units','pixels',... Position', [32050400600],... 'Numbertitle','off',... 'menubar','none',... 'resize','off',... 'name','upup',... 'color', [0.93 0.60]);% = textAreaLabel=uilabel (upFig); textAreaLabel.Position= [55 445 290 100]; textAreaLabel.Text='';textAreaLabel.BackgroundColor= [0meme 0]; textArea=uitextarea (upFig,'ValueChangedFcn',@changeText); textArea.Position= [60 450 280 90]; textArea.FontSize=23;%text label hdl part===textLabel_1=uilabel (upFig); textLabel_1.Position= [52 517 296 106]; textLabel_1.Text='YOUR MESSAGE HERE';textLabel_1.FontSize=24;textLabel_1.FontWeight='bold';textLabel_1.HorizontalAlignment='center' TextLabel_2=uilabel (upFig); textLabel_2.Position= [52 367 296 106]; textLabel_2.Text='BACKGROUND COLORS';textLabel_2.FontSize=24;textLabel_2.FontWeight='bold';textLabel_2.HorizontalAlignment='center';textLabel_3=uilabel (upFig); textLabel_3.Position= [10 310 60 50]; textLabel_3.Text='SIZE';textLabel_3.FontSize=20;textLabel_3.FontWeight='bold';textLabel_3.HorizontalAlignment='center';%bkg color hdl part===for i=1:size (colorList,1) CL (I) = uiimage (upFig) CL (I) .position = [10 accounting35 bkg',num2str (I) .UserData = I; CL (I) .ImageSource = ['materials\ bkg',num2str (I),' .png']; endset (CL,'ImageClickedFcn',@bkgChange)% reset Size hdl part===sizeBtn (1) = uiimage (upFig); sizeBtn (1). Position= [70 320 168 30]; sizeBtn (1). UserData=1;sizeBtn (1). ImageSource='materials\ cover.jpg';sizeBtn (2) = uiimage (upFig); sizeBtn (2). Position= [245320 8030] SizeBtn (2). UserData=2;sizeBtn (2). ImageSource='materials\ square.jpg';set (sizeBtn,'ImageClickedFcn',@sizeChange)% = refreshBtn=uiimage (upFig); refreshBtn.Position= [340 317.5 35 35]; refreshBtn.ImageSource='materials\ refresh.png';set (refreshBtn,'ImageClickedFcn',@changeText)% = upAx=uiaxes ('Units','pixels',...) 'parent',upFig,... Position', [50 10 300 300],... Color', [0.990.99 0.99],... 'Box','on',... 'XTick', [],... 'YTick', [],... 'XLimMode','manual',... 'YLimMode','manual',... 'XLim', [0300],... 'YLim', [0300],... 'The BackgroundColor', [010],... 'YDir','reverse'); hold (upAx,'on')% = function bkgChange (~, event) objNum=event.Source.UserData; upAx.Color=colorList (objNum,:); end function sizeChange (~, event) axesType=event.Source.UserData; switch axesType case 1 upAx.Position= [10 120 380 141]; upAx.XLim= [0 380] UpAx.YLim= [0 141]; case 2 upAx.Position= [50 10 300 300]; upAx.XLim= [0 300]; upAx.YLim= [0 300] End end function changeText (~, ~) cla (upAx)% hold (upAx,'off')% image (upAx, [- 1 textMsg=textArea.Value; for ii=1:length 0], [- 1 visible','off' 0], ones (1 upAx,'on') textMsg=textArea.Value; for ii=1:length (textMsg) tempStr=textMsg {ii} For jj=1:length (tempStr) if tempStr (jj) ~ =''roleType=randi (24); image (upAx, [0103 ~ 0.4] + 110cm 28 * (jj-1)-27 * (ii-1),... Materials.imgSet.CData {roleType},... 'AlphaData',materials.imgSet.AData {roleType},... 'Interpolation','bilinear') text (upAx,21+110+28* (jj-1)-27 * (ii-1),... 10 * 10 * 12 * (jj-1) + 22 * (ii-1),... TempStr (jj), 'rotation',-38,'FontSize',16,... FontWeight','bold','Color', [0.4, 0.3, 0.3],... 'FontAngle','italic','HorizontalAlignment','center'); endend end endend

Also: complete material package + mat file + m file can be downloaded below

Baidu network disk link: https://pan.baidu.com/s/1F6Z3_-91_OKtV2zjQUg47Q

Note: the code and materials are for learning purposes only, not for other purposes.

In addition

If matlab is released after R2016a and before R2019a, it cannot be used properly because uiimage has not been launched. You can try the following code, which still requires materials.mat and m files to be in the same folder:

Function upupUiBtnglobal textMsg bkgColor colorList axesTypeglobal textAreatextMsg= []; axesType=2;bkgColor= [1] ColorList= [0.9000 0 0.0700 0.9200 0.3300 0.0800 0.9600 0.6200 0.7500 0.9600 0.9400 0.5500 0.7600 0.8400 0.2500 0.3800 0.7600 0.7300 0.4700 0.8100 0.9400 0.6000 0.0500 0.4900 1 1];% load pic and create pic = = materials=load ('materials.mat') If ~ exist ('materials','dir') mkdir (' materials'); endfor i=1:size (colorList,1) Rc=zeros (60 materials'); Rc (1150) = 255.*colorList (iMag1); Gc=zeros (60); Gc (1150) = 255.*colorList (iMag2); Bc=zeros (60); Bc (1150) = 255.*colorList (iMag3); cPic (:,: 1) = Rc;cPic (:,:, 2) = Gc CPic (:,:, 3) = Bc; imwrite (uint8 (cPic), ['materials\ bkg',num2str (I),' .png']) endimwrite (materials.imgSet.cover,'materials\ cover.jpg') imwrite (materials.imgSet.square,'materials\ square.jpg') imwrite (materials.imgSet.refresh.CData,'materials\ refresh.png','Alpha',materials.imgSet.refresh.AData)% = upFig=uifigure ('units','pixels',... Position', [32050400600],... 'Numbertitle','off',... 'menubar','none',... 'resize','off',... 'name','upup',... 'color', [0.93 0.60]);% = textAreaLabel=uilabel (upFig); textAreaLabel.Position= [55 445 290 100]; textAreaLabel.Text='';textAreaLabel.BackgroundColor= [0meme 0]; textArea=uitextarea (upFig,'ValueChangedFcn',@changeText); textArea.Position= [60 450 280 90]; textArea.FontSize=23;%text label hdl part===textLabel_1=uilabel (upFig); textLabel_1.Position= [52 517 296 106]; textLabel_1.Text='YOUR MESSAGE HERE';textLabel_1.FontSize=24;textLabel_1.FontWeight='bold';textLabel_1.HorizontalAlignment='center' TextLabel_2=uilabel (upFig); textLabel_2.Position= [52 367 296 106]; textLabel_2.Text='BACKGROUND COLORS';textLabel_2.FontSize=24;textLabel_2.FontWeight='bold';textLabel_2.HorizontalAlignment='center';textLabel_3=uilabel (upFig); textLabel_3.Position= [10 310 60 50]; textLabel_3.Text='SIZE';textLabel_3.FontSize=20;textLabel_3.FontWeight='bold';textLabel_3.HorizontalAlignment='center';%bkg color hdl part===for i=1:size (colorList,1) CL (I) = uibutton (upFig) CL (I) .position = [10 materials bkg',num2str (I) 35]; CL (I). BackgroundColor= [000]; CL (I) .text =''; CL (I) .UserData = I; CL (I) .Icon = ['materials\ UserData (I),' .png']; endset (CL,'ButtonPushedFcn',@bkgChange)% reset Size hdl part===sizeBtn (1) = uibutton (upFig); sizeBtn (1). Position= [80 320 145 32]; sizeBtn (1). UserData=1;sizeBtn (1) .Text ='' SizeBtn (1). BackgroundColor= [2000]; sizeBtn (1). Icon='materials\ cover.jpg';sizeBtn (2) = uibutton (upFig); sizeBtn (2). Position= [235320 78 32]; sizeBtn (2). UserData=2;sizeBtn (2) .Text ='; sizeBtn (2). BackgroundColor= [2000]; sizeBtn (2). Icon='materials\ square.jpg';set (sizeBtn,'ButtonPushedFcn',@sizeChange) refreshBtn=uibutton (upFig); refreshBtn.Position= [330318 35]; refreshBtn.Text='' RefreshBtn.BackgroundColor= [0.93 0.6]; refreshBtn.Icon='materials\ refresh.png';set (refreshBtn,'ButtonPushedFcn',@changeText)% = upAx=uiaxes ('Units','pixels',... 'parent',upFig,... Position', [50 10 300 300],... Color', [0.990.99 0.99],... 'Box','on',... 'XTick', [],... 'YTick', [],... 'XLimMode','manual',... 'YLimMode','manual',... 'XLim', [0300],... 'YLim', [0300],... 'The BackgroundColor', [010],... 'YDir','reverse'); hold (upAx,'on')% = function bkgChange (~, event) objNum=event.Source.UserData; upAx.Color=colorList (objNum,:); end function sizeChange (~, event) axesType=event.Source.UserData; switch axesType case 1 upAx.Position= [10 120 380 141]; upAx.XLim= [0 380] UpAx.YLim= [0 141]; case 2 upAx.Position= [50 10 300 300]; upAx.XLim= [0 300]; upAx.YLim= [0 300] End end function changeText (~, ~) cla (upAx)% hold (upAx,'off')% image (upAx, [- 1 textMsg=textArea.Value; for ii=1:length 0], [- 1 visible','off' 0], ones (1 upAx,'on') textMsg=textArea.Value; for ii=1:length (textMsg) tempStr=textMsg {ii} For jj=1:length (tempStr) if tempStr (jj) ~ =''roleType=randi (24); image (upAx, [0103 ~ 0.4] + 110cm 28 * (jj-1)-27 * (ii-1),... Materials.imgSet.CData {roleType},... 'AlphaData',materials.imgSet.AData {roleType},... 'Interpolation','bilinear') text (upAx,21+110+28* (jj-1)-27 * (ii-1),... 10 * 10 * 12 * (jj-1) + 22 * (ii-1),... TempStr (jj), 'rotation',-38,'FontSize',16,... FontWeight','bold','Color', [0.4, 0.3, 0.3],... 'FontAngle','italic','HorizontalAlignment','center'); endend end endend

The non-uiimage button looks like this:

The above is all the contents of the article "how to use Matlab to refuel the villain generator". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report