Update of /cvsroot/dynapi/dynapi/src/lib/dynapi/util
In directory usw-pr-cvs1:/tmp/cvs-serv29491

Modified Files:
        pathanim.js 
Log Message:
Christof Pohl's PathAnimation.run change

Index: pathanim.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi/src/lib/dynapi/util/pathanim.js,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** pathanim.js 2001/03/27 15:34:27     1.11
--- pathanim.js 2001/03/29 00:19:47     1.12
***************
*** 13,17 ****
        this.Thread = Thread;
        this.Thread(dlyr);
- 
        this.paths = new Array();
        this.pathPlaying = null;
--- 13,16 ----
***************
*** 36,48 ****
        this.paths[n].frame = frame;
  };
- 
  PathAnimation.prototype.playAnimation = function (noevt) {
        if (this.playing) return;
        this.pathPlaying = null;
!               
!       if (typeof(arguments[0]) == "number") { // playAnimation(animNum)
                this.pathPlaying = this.paths[arguments[0]];
        }
!       else if (typeof(arguments[0]) == "object") {   // playAnimation([path], loops, 
resets)
                this.pathPlaying = arguments[0];
                this.pathPlaying.loops = arguments[1]||false;
--- 35,45 ----
        this.paths[n].frame = frame;
  };
  PathAnimation.prototype.playAnimation = function (noevt) {
        if (this.playing) return;
        this.pathPlaying = null;
!       if (typeof(arguments[0]) == "number") {
                this.pathPlaying = this.paths[arguments[0]];
        }
!       else if (typeof(arguments[0]) == "object") {  
                this.pathPlaying = arguments[0];
                this.pathPlaying.loops = arguments[1]||false;
***************
*** 50,56 ****
                this.pathPlaying.frame = 0;
        }
-       
        this.playing = true;
- 
        if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstart");
        this.start();
--- 47,51 ----
***************
*** 59,73 ****
        if (this.pathPlaying && this.pathPlaying.resets && !this.cancelThread && 
this.dlyr!=null) this.dlyr.moveTo(this.pathPlaying[0],this.pathPlaying[1]);
        this.stop();
!       delete this.pathPlaying;  // only deletes unstored path
        this.playing = false;
        if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstop");
  };
- 
  PathAnimation.prototype.run = function () {
        if (!this.playing || this.pathPlaying==null) return;
- 
        var anim = this.pathPlaying;
!       
!       if (anim.frame>=anim.length/2+1) {
                if (anim.loops) {
                        anim.frame = 0;
--- 54,65 ----
        if (this.pathPlaying && this.pathPlaying.resets && !this.cancelThread && 
this.dlyr!=null) this.dlyr.moveTo(this.pathPlaying[0],this.pathPlaying[1]);
        this.stop();
!       delete this.pathPlaying; 
        this.playing = false;
        if (this.dlyr!=null && noevt!=false) this.dlyr.invokeEvent("pathstop");
  };
  PathAnimation.prototype.run = function () {
        if (!this.playing || this.pathPlaying==null) return;
        var anim = this.pathPlaying;
!       if (anim.frame>=anim.length/2) {
                if (anim.loops) {
                        anim.frame = 0;
***************
*** 85,93 ****
                }
        }
-       
        if (anim.frame==0 && (this.dlyr!=null && this.dlyr.x==anim[0] && 
this.dlyr.y==anim[1])) {
!               anim.frame += 1;        // skip 1st frame if already at that location
        }
-       
        this.newX = anim[anim.frame*2];
        this.newY = anim[anim.frame*2+1];
--- 77,83 ----
                }
        }
        if (anim.frame==0 && (this.dlyr!=null && this.dlyr.x==anim[0] && 
this.dlyr.y==anim[1])) {
!               anim.frame += 1;
        }
        this.newX = anim[anim.frame*2];
        this.newY = anim[anim.frame*2+1];
***************
*** 97,107 ****
                this.dlyr.moveTo(this.newX,this.newY);
        }
-       
        anim.frame++;
  };
- 
- // DynLayer extension
- // these will invoke "pathstart", "pathrun", and "pathstop" events on the dynlayer 
when used
  
  DynLayer.prototype.slideTo = function(x,y,inc,ms) {
        if (!this.pathanim) this.pathanim = new PathAnimation(this);
--- 87,95 ----
                this.dlyr.moveTo(this.newX,this.newY);
        }
        anim.frame++;
  };
  
+ // DynLayer Extensions
+ // These will invoke "pathstart", "pathrun", and "pathstop" events on the dynlayer 
+when used
  DynLayer.prototype.slideTo = function(x,y,inc,ms) {
        if (!this.pathanim) this.pathanim = new PathAnimation(this);
***************
*** 118,123 ****
  
  // Path Functions
! 
! // generates a path between 2 points, stepping inc pixels at a time
  PathAnimation.line = function(x1,y1,x2,y2,inc) {
        var distx = x2 - x1;
--- 106,110 ----
  
  // Path Functions
! // Generates a path between 2 points, stepping inc pixels at a time
  PathAnimation.line = function(x1,y1,x2,y2,inc) {
        var distx = x2 - x1;
***************
*** 138,143 ****
        return path;
  };
! 
! // generates a path between 2 points in N steps
  PathAnimation.lineN = function(x1,y1,x2,y2,N) {
        if (N==0) return [];
--- 125,129 ----
        return path;
  };
! // Generates a path between 2 points in N steps
  PathAnimation.lineN = function(x1,y1,x2,y2,N) {
        if (N==0) return [];
***************
*** 151,156 ****
        return path;
  };
! 
! // combines separate [x1,x2],[y1,y2] arrays into a path array [x1,y1,x2,y2]
  PathAnimation.interlace = function(x,y) {
        var l = Math.max(x.length,y.length);
--- 137,141 ----
        return path;
  };
! // Combines separate [x1,x2],[y1,y2] arrays into a path array [x1,y1,x2,y2]
  PathAnimation.interlace = function(x,y) {
        var l = Math.max(x.length,y.length);
***************
*** 162,167 ****
        return a;
  };
! 
! // returns correct angle in radians between 2 points
  PathAnimation.getNormalizedAngle = function(x1,y1,x2,y2) {
        var distx = Math.abs(x1-x2);
--- 147,151 ----
        return a;
  };
! // Returns correct angle in radians between 2 points
  PathAnimation.getNormalizedAngle = function(x1,y1,x2,y2) {
        var distx = Math.abs(x1-x2);
***************
*** 170,174 ****
        else if (distx==0) angle = Math.PI/2;
        else angle = Math.atan(disty/distx);
-       
        if (x1<x2) {
                if (y1<y2) angle = Math.PI*2-angle;
--- 154,157 ----
***************
*** 180,185 ****
        return angle;
  };
! 
! // radian conversion
  PathAnimation.radianToDegree = function(radian) {
        return radian*180/Math.PI
--- 163,167 ----
        return angle;
  };
! // Radian conversion
  PathAnimation.radianToDegree = function(radian) {
        return radian*180/Math.PI
***************
*** 187,189 ****
  PathAnimation.degreeToRadian = function(degree) {
        return degree*Math.PI/180
! };
--- 169,171 ----
  PathAnimation.degreeToRadian = function(degree) {
        return degree*Math.PI/180
! };
\ No newline at end of file


_______________________________________________
Dynapi-CVS mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-cvs

Reply via email to