updateProgress

Syntax

int updateProgress(int p, int max)

Arguments

p
Number in the range 0 to max representing current filter progress
max
The maximum value p can take

Return

Returns 1 if the user has pressed the Esc key, 0 otherwise.

Description

The function updateProgress(current,max) updates the progress bar on the plug-in or in the information bar at the bottom of the screen in your image editing program. The variable p describes the current progress in the range [0,max]. If the user presses the ESC key, a non-zero value is returned by updateProgress().

Example

%ffp

// This example updates the progress bar for every pixel in
// the image.  In more complicated filters this can slow
// down the plug-in - it may be better to update the progress
// bar for every Y row.

ForEveryTile:
{
  for ( y = 0; y < Y; y++ ) // row by row
  {
    for ( x = 0; x < X; x++ ) // column by column
      for ( z = 0; z < Z; z++ ) // channel by channel
        pset( x, y, z, src( x % 100, y % 100, z ) + rnd( -50, 50 ) ); // apply an effect
        updateProgress( y, Y ); // update the progress bar
        updatePreview( a ); // update the preview (only in active filter dialog)
  }
  return true;
}

Also see

updatePreview, testAbort

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.