Skill level: beginner

How to make a fun pause screen.

There are times when you may need to create a pause screen to entertain the users while you fetch something or do some work in the background.  This is probably one of the more interesting times that you can make use of a gradient. 

This tutorial will show you how to create a screen that slowly turns green as the job is completed.  Once the designated pause time is done, the window goes away and returns control to the user.












 

 





The first step is to create a gradient or ramp node:

Note: you can view all the mel here: tj_tutorial_funPauseScreen.mel

Create the gradient using a ramp:
string $tj_tempName = `shadingNode -asShader ramp`;
string $tj_rampNode = `rename $tj_tempName "tj_gradientColourTemp"`;

After that, we need to set up colours.  We're using a black ramp that fills to green, so we need three colours.  A black to fill, a green to go to, and one that makes the transition.

setAttr ($tj_rampNode + ".colorEntryList[0].color") -type double3 0.2 1 0.2 ;
setAttr ($tj_rampNode + ".colorEntryList[1].color") -type double3 0.2 0 0.2 ;
setAttr ($tj_rampNode + ".colorEntryList[2].color") -type double3 0 0 0.2 ;

setAttr ($tj_rampNode + ".colorEntryList[0].position") 0.0;
setAttr ($tj_rampNode + ".colorEntryList[1].position") 0.0;
setAttr ($tj_rampNode + ".colorEntryList[2].position") 1.0;

After that, we need to create a window and display the ramp to the user.

//create window
string $tj_winName = "tj_winName";
string $tj_winTitle = "TJ Fun Pause Screen";
if ( `window -exists $tj_winName` )
  deleteUI -window $tj_winName;

string $tj_rampWin = `window -t $tj_winTitle -wh 258 258 $tj_winName`;
    columnLayout;
      rampColorPort -node $tj_rampNode;
    showWindow $tj_rampWin;

Now we need to take control away from the user, and have something happen.  As shown above, we achieve this by having our ramp slowly change from black to green and fill in.  It can be all done with a simple loop.  By slicing the counter smaller and smaller, the pause will increase.  As noted in the comments below, we're using a slice of 0.005.

//do timer by filling in ramp with green
float $tj_i = 0.0;
while ($tj_i < 1)
 {
 float $tj_newPos = $tj_i;
 setAttr ($tj_rampNode + ".colorEntryList[1].position") $tj_newPos;
 setAttr ($tj_rampNode + ".colorEntryList[1].color") 0.2 $tj_newPos 0.2 ;

 // the smaller this increment, the longer the pause
 // using 0.005 tends to get us in around 15 seconds
 $tj_i = $tj_i + 0.005;

 showWindow $tj_rampWin;
 }

That's all there is too it.  All we have left is to clean up what we've done.  Delete the window and ramp nodes:

/////////////////////////////////////
// 15 seconds passed, all done pausing

//kill window
if ( `window -exists $tj_winName` )
  deleteUI -window $tj_winName;

//delete ramp
delete $tj_rampNode;

print "\n  -=-=-=-=       Finished pause screen.        =-=-=-=- \n";
//done

-tj Nov 2007

Note: you can view all the mel here: tj_tutorial_funPauseScreen.mel

34207A8C-FA8E-49E7-B8E1-647849024CED_files/tj_tutorial_funPauseScreen.mel34207A8C-FA8E-49E7-B8E1-647849024CED_files/tj_tutorial_funPauseScreen_1.melshapeimage_1_link_0shapeimage_1_link_1
MEL: How to make a fun pause screen Thursday, November 15, 2007 Education and Training    Products & Solutions  Education & Training About Work Client Area Contact Us   Tutorials for Sale Free Tutorials Training Choices