My Picasa Albums
My Picasa Albums This page will discuss how to write plugins for Imajico. Plugins are written in JavaScript, outside of the main Imajico JavaScript file. It will be possible to plugin the following:

Currently pluggable image effects are supported, see below for an example.
Below is a template for writing an image effect plugin.

Imj.Fx.pan = function(xInc, yInc, numSteps, interval) {
   this.xInc = undefined != xInc ? xInc : 0.5;
   this.yInc = undefined != yInc ? yInc : 0.5;
   this.numSteps = undefined != numSteps ? numSteps : 100;
   this.interval = undefined != interval ? interval : 50;
   this._timers = {};
};

Imj.Fx.pan.prototype.apply = function(fromPhotoDraw, toPhotoDraw) {
   var self = this;
   this._isCancelled = false;
   var stepNum = -1
   Imj.show(toPhotoDraw.element);
   if (fromPhotoDraw)
      Imj.hide(fromPhotoDraw.element);
   _doPan();
   
   function _doPan() {
      if (self._isCancelled) return;
      
      toPhotoDraw.setPos(toPhotoDraw.getX() + self.xInc, toPhotoDraw.getY() + self.yInc);
      if (stepNum < self.numSteps) {
         self._timers[toPhotoDraw.element.id] = setTimeout(_doPan, self.interval);
      }
   }
};

Imj.Fx.pan.prototype.cancel = function() {
   this._isCancelled = true;
   for (var key in this._timers) {
      Imj.clearTime(this._timers[key]);
   }
   this._timers = {};
};