Skip to content

Commit

Permalink
01/19/2012 *0.1 Build 627*
Browse files Browse the repository at this point in the history
--------------------------

* Added clip paths capability to be scaled accordingly to director's affine transform.
* Modified CAAT.Path bounding box to keep track of path's position. So if a clip path is defined as:
  new CAAT.Path().beginPath(200,200).addRectangleTo(300,300).endPath() there's no need to still apply the workaround
  of setting a behavior to show it properly.
  • Loading branch information
hyperandroid committed Jan 20, 2012
1 parent 214114e commit 477e5d4
Show file tree
Hide file tree
Showing 60 changed files with 1,599 additions and 1,509 deletions.
6 changes: 3 additions & 3 deletions build/caat-box2d-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/caat-box2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Version: 0.1 build: 611
Version: 0.1 build: 628
Created on:
DATE: 2012-01-19
TIME: 22:26:20
DATE: 2012-01-20
TIME: 02:02:22
*/


Expand Down
71 changes: 36 additions & 35 deletions build/caat-css-min.js

Large diffs are not rendered by default.

61 changes: 43 additions & 18 deletions build/caat-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Version: 0.1 build: 611
Version: 0.1 build: 628
Created on:
DATE: 2012-01-19
TIME: 22:26:20
DATE: 2012-01-20
TIME: 02:02:22
*/


Expand All @@ -45,7 +45,7 @@ var CAAT= CAAT || {};
* Common bind function. Allows to set an object's function as callback. Set for every function in the
* javascript context.
*/
Function.prototype.bind= function() {
Function.prototype.bind= Function.prototype.bind || function() {
var fn= this; // the function
var args= Array.prototype.slice.call(arguments); // copy the arguments.
var obj= args.shift(); // first parameter will be context 'this'
Expand Down Expand Up @@ -1522,8 +1522,8 @@ var cp1= proxy(
this.height= -1;
this.x= 0;
this.y= 0;
this.width= 0;
this.height= 0;
this.x1= 0;
this.y1= 0;
return this;
},
/**
Expand Down Expand Up @@ -1729,6 +1729,7 @@ var cp1= proxy(
}

// thanks yodesoft.com for spotting the first point is out of the BB
rectangle.setEmpty();
rectangle.union( this.coordlist[0].x, this.coordlist[0].y );

var pt= new CAAT.Point();
Expand Down Expand Up @@ -2196,7 +2197,7 @@ var cp1= proxy(
translate : function(x,y,z) {
this.x+= x;
this.y+= y;
this.z+= z||0;
this.z+= z;

return this;
},
Expand Down Expand Up @@ -12537,7 +12538,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
*
* @param ctx {RenderingContext2D}
*/
applyAsPath : function(ctx) {},
applyAsPath : function(director) {},

/**
* Transform this path with the given affinetransform matrix.
Expand Down Expand Up @@ -12571,8 +12572,8 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
points: null,
newPosition: null, // spare holder for getPosition coordinate return.

applyAsPath : function(ctx) {
ctx.lineTo( this.points[0].x, this.points[1].y );
applyAsPath : function(director) {
director.ctx.lineTo( this.points[0].x, this.points[1].y );
},
setPoint : function( point, index ) {
if ( index===0 ) {
Expand Down Expand Up @@ -12758,8 +12759,8 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
curve: null, // a CAAT.Bezier instance.
newPosition: null, // spare holder for getPosition coordinate return.

applyAsPath : function(ctx) {
this.curve.applyAsPath(ctx);
applyAsPath : function(director, ctx) {
this.curve.applyAsPath(director, ctx);
return this;
},
setPoint : function( point, index ) {
Expand Down Expand Up @@ -12944,7 +12945,8 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
bbox: null,
newPosition: null, // spare point for calculations

applyAsPath : function(ctx) {
applyAsPath : function(director) {
var ctx= director.ctx;
//ctx.rect( this.bbox.x, this.bbox.y, this.bbox.width, this.bbox.height );
if ( this.cw ) {
ctx.lineTo( this.points[0].x, this.points[0].y );
Expand Down Expand Up @@ -13184,8 +13186,9 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
}

this.bbox.setEmpty();
var minx= Number.MAX_VALUE, miny= Number.MAX_VALUE, maxx= Number.MIN_VALUE, maxy= Number.MIN_VALUE;
for( var i=0; i<4; i++ ) {
this.bbox.union( this.points[i].x, this.points[i].y );
this.bbox.union( this.points[i].x, this.points[i].y );
}

this.length= 2*this.bbox.width + 2*this.bbox.height;
Expand Down Expand Up @@ -13315,15 +13318,21 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
width: 0,
height: 0,

applyAsPath : function(ctx) {
clipOffsetX : 0,
clipOffsetY : 0,

applyAsPath : function(director) {
var ctx= director.ctx;

director.modelViewMatrix.transformRenderingContext( ctx );
ctx.beginPath();
ctx.globalCompositeOperation= 'source-out';
ctx.moveTo(
this.getFirstPathSegment().startCurvePosition().x,
this.getFirstPathSegment().startCurvePosition().y
);
for( var i=0; i<this.pathSegments.length; i++ ) {
this.pathSegments[i].applyAsPath(ctx);
this.pathSegments[i].applyAsPath(director);
}
ctx.globalCompositeOperation= 'source-over';
return this;
Expand Down Expand Up @@ -13761,18 +13770,34 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
this.bbox.setEmpty();
this.points= [];

var xmin= Number.MAX_VALUE, ymin= Number.MAX_VALUE;
for( i=0; i<this.pathSegments.length; i++ ) {
this.pathSegments[i].updatePath(point);
this.length+= this.pathSegments[i].getLength();
this.bbox.unionRectangle( this.pathSegments[i].bbox );

for( j=0; j<this.pathSegments[i].numControlPoints(); j++ ) {
this.points.push( this.pathSegments[i].getControlPoint( j ) );
var pt= this.pathSegments[i].getControlPoint( j );
this.points.push( pt );
if ( pt.x < xmin ) {
xmin= pt.x;
}
if ( pt.y < ymin ) {
ymin= pt.y;
}
}
}

this.clipOffsetX= -xmin;
this.clipOffsetY= -ymin;

this.width= this.bbox.width;
this.height= this.bbox.height;
this.setLocation( this.bbox.x, this.bbox.y );
this.bbox.x= 0;
this.bbox.y= 0;
this.bbox.x1= this.width;
this.bbox.y1= this.height;

this.pathSegmentStartTime= [];
this.pathSegmentDurationTime= [];
Expand Down Expand Up @@ -13978,7 +14003,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
for (i = 0; i < this.numControlPoints(); i++) {
this.setPoint(
this.matrix.transformCoord(
this.pathPoints[i].clone()), i);
this.pathPoints[i].clone().translate( this.clipOffsetX, this.clipOffsetY )), i);
}
// }

Expand Down
Loading

0 comments on commit 477e5d4

Please sign in to comment.