Changeset 477 for trunk/src/update_waitbar.m
- Timestamp:
- Jun 26, 2012, 8:40:09 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/update_waitbar.m
r339 r477 3 3 %INPUT: 4 4 % hwaitbar: handles of the waitbar to update 5 % bar_size: vector with 4 elements, representing the abscissa, ordinate, width, height of the waitbar relative to the GUI6 5 % advance_ratio: number between 0 and 1 representing the advancement of the calculation (loop index relative to the total length) 7 6 8 function update_waitbar(hwaitbar,bar_size,advance_ratio) 9 % waitbarpos(1)=bar_size(1); 10 % waitbarpos(3)=bar_size(3); 11 % waitbarpos(4)=advance_ratio*bar_size(4); 12 % waitbarpos(2)=bar_size(4)+bar_size(2)-waitbarpos(4); 13 % set(hwaitbar,'Position',waitbarpos) 7 function update_waitbar(hwaitbar,advance_ratio) 8 14 9 set(hwaitbar,'Units','pixels') 15 pos=get(hwaitbar,'Position'); 16 CData=zeros([floor(pos(4)) floor(pos(3)) 3]); 17 set(hwaitbar,'Units','normalized') 18 CData(:,1:floor(advance_ratio*size(CData,2)),1:2)=1; 10 pos=get(hwaitbar,'Position');%read waitbar position in pixels 11 set(hwaitbar,'Units','normalized')%set back to normalize(the waitbar scales with the GUI) 12 CData=ones(floor(pos(4)),floor(pos(3)),3); 13 CData(:,:,3)=0 ;% initial color yellow (rgb=[1 1 0]) 14 CData(:,1:floor(advance_ratio*size(CData,2)),2)=0; % advancement part in red (suppress the second color component green) 19 15 set(hwaitbar,'CData',CData) 20 16 drawnow
Note: See TracChangeset
for help on using the changeset viewer.