Type of paper: Essay

Topic: Icon, Corner, Axis, Shopping, Display, Hit, Loop, Discrimination

Pages: 1

Words: 275

Published: 2020/09/12

clc
clear;
%First Get "Canvas" Image.
im = imread('Mainpage.png');
imshow(im),title('Original Image')
subplot(2,2,1)
imshow(im);
b=imread('Fridgelist.png');
subplot(2,2,2)
imshow(b)
c=imread('FridgesFreezers.png');
subplot(2,2,3)
imshow(c)
I=imread('fluenciatable.jpg');
subplot(2,2,4)
imshow(I)
% display the image
mainCatalogImg = image(X);
% turn off the axis and markers
axis off
% scale the axis to the image size
axis image;
% the exit ICON upper left corner X and Y, as well as the button height and
% widths
exitIconX = 845;
exitIconY = 10;
exitIconWidth = 140;
exitIconHeight = 30;
% These values relate only to the icons use on the main catalog display,
% which was just loaded (ie MainPage.png)
iconWidth = 232;
iconHeight = 170;
% these points locate the upper left corner of each icon 1st position is
% X, and second position if Y
% X , Y
mainCatalogXYStarts = [ [22, 50];
[266, 50];
[510, 50];
[755, 50];
[22, 227];
[266, 227];
[510, 227];
[755, 227] ];
%while(1)
% ginput(1)
%end
% simple flag to control the main while loop
shopping = 1;
% simple flag to identify when an icon was actually clicked
iconClicked = 0;
% the MAIN loop
while( shopping )
% get a single mouse click from user
[xMouse,yMouse] = ginput(1);
% First check if exit button clicked
if( IsHit(xMouse, yMouse, exitIconX, exitIconY, exitIconWidth, exitIconHeight) )
shopping = 0;
close(mainWindow);
else
% Now we check which icon was actually hit, we do this by
% looping through each icon position and see if a hit was registered
% within the boundaries of the icon (remember we have the upper left
% corner X and Y corodinates as well as the height and width of the icons
for idx=1:length(mainCatalogXYStarts) % row centric icon counting
iconAnchorX = mainCatalogXYStarts(idx,1); % icon upper left corner X
iconAnchorY = mainCatalogXYStarts(idx,2); % icon upper left corner Y
iconClicked = IsHit(xMouse, yMouse, iconAnchorX, iconAnchorY, iconWidth, iconHeight);
% if we find the icon that was clicked then exit the FOR loop
% because we are done. The value of 'idx' continas the index of the
% icon that was clicked
if( iconClicked )
break;
end
end
end
% if an icons was clicked then do something interesting (well this code
% just opens the next catalog, passing the 'idx' value to indicate
% which catalog to display (if I had multiples)
if( iconClicked == 1)
disp(['Hit icon number ', num2str(idx)]);
iconClicked = 0; % reset it

ShowCatalog(idx);

end
end

Cite this page
Choose cite format:
  • APA
  • MLA
  • Harvard
  • Vancouver
  • Chicago
  • ASA
  • IEEE
  • AMA
WePapers. (2020, September, 12) Matlab Assignment Essays Example. Retrieved November 05, 2024, from https://www.wepapers.com/samples/matlab-assignment-essays-example/
"Matlab Assignment Essays Example." WePapers, 12 Sep. 2020, https://www.wepapers.com/samples/matlab-assignment-essays-example/. Accessed 05 November 2024.
WePapers. 2020. Matlab Assignment Essays Example., viewed November 05 2024, <https://www.wepapers.com/samples/matlab-assignment-essays-example/>
WePapers. Matlab Assignment Essays Example. [Internet]. September 2020. [Accessed November 05, 2024]. Available from: https://www.wepapers.com/samples/matlab-assignment-essays-example/
"Matlab Assignment Essays Example." WePapers, Sep 12, 2020. Accessed November 05, 2024. https://www.wepapers.com/samples/matlab-assignment-essays-example/
WePapers. 2020. "Matlab Assignment Essays Example." Free Essay Examples - WePapers.com. Retrieved November 05, 2024. (https://www.wepapers.com/samples/matlab-assignment-essays-example/).
"Matlab Assignment Essays Example," Free Essay Examples - WePapers.com, 12-Sep-2020. [Online]. Available: https://www.wepapers.com/samples/matlab-assignment-essays-example/. [Accessed: 05-Nov-2024].
Matlab Assignment Essays Example. Free Essay Examples - WePapers.com. https://www.wepapers.com/samples/matlab-assignment-essays-example/. Published Sep 12, 2020. Accessed November 05, 2024.
Copy

Share with friends using:

Related Premium Essays
Contact us
Chat now