Start on a svgutils unit test file
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1856 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -213,4 +213,22 @@ svgedit.math.snapToAngle = function(x1,y1,x2,y2) {
|
||||
return {x:x, y:y, a:snapangle};
|
||||
};
|
||||
|
||||
|
||||
// Function: rectsIntersect
|
||||
// Check if two rectangles (BBoxes objects) intersect each other
|
||||
//
|
||||
// Paramaters:
|
||||
// r1 - The first BBox-like object
|
||||
// r2 - The second BBox-like object
|
||||
//
|
||||
// Returns:
|
||||
// Boolean that's true if rectangles intersect
|
||||
svgedit.math.rectsIntersect = function(r1, r2) {
|
||||
return r2.x < (r1.x+r1.width) &&
|
||||
(r2.x+r2.width) > r1.x &&
|
||||
r2.y < (r1.y+r1.height) &&
|
||||
(r2.y+r2.height) > r1.y;
|
||||
};
|
||||
|
||||
|
||||
})();
|
||||
@@ -1503,7 +1503,7 @@ var getIntersectionList = this.getIntersectionList = function(rect) {
|
||||
var i = curBBoxes.length;
|
||||
while (i--) {
|
||||
if(!rubberBBox.width || !rubberBBox.width) continue;
|
||||
if (svgedit.utilities.rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
||||
if (svgedit.math.rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
||||
resultList.push(curBBoxes[i].elem);
|
||||
}
|
||||
}
|
||||
@@ -4660,7 +4660,7 @@ var textActions = canvas.textActions = function() {
|
||||
|
||||
// TODO: Find a way to make this work: Use transformed BBox instead of evt.target
|
||||
// if(last_x === mouse_x && last_y === mouse_y
|
||||
// && !svgedit.utilities.rectsIntersect(transbb, {x: pt.x, y: pt.y, width:0, height:0})) {
|
||||
// && !svgedit.math.rectsIntersect(transbb, {x: pt.x, y: pt.y, width:0, height:0})) {
|
||||
// textActions.toSelectMode(true);
|
||||
// }
|
||||
if(last_x === mouse_x && last_y === mouse_y && evt.target !== curtext) {
|
||||
@@ -6123,7 +6123,7 @@ var pathActions = this.pathActions = function() {
|
||||
height: 0
|
||||
};
|
||||
|
||||
var sel = svgedit.utilities.rectsIntersect(rbb, pt_bb);
|
||||
var sel = svgedit.math.rectsIntersect(rbb, pt_bb);
|
||||
|
||||
this.select(sel);
|
||||
//Note that addPtsToSelection is not being run
|
||||
|
||||
@@ -183,22 +183,6 @@ svgedit.utilities.convertToXMLReferences = function(input) {
|
||||
return output;
|
||||
};
|
||||
|
||||
// Function: rectsIntersect
|
||||
// Check if two rectangles (BBoxes objects) intersect each other
|
||||
//
|
||||
// Paramaters:
|
||||
// r1 - The first BBox-like object
|
||||
// r2 - The second BBox-like object
|
||||
//
|
||||
// Returns:
|
||||
// Boolean that's true if rectangles intersect
|
||||
svgedit.utilities.rectsIntersect = function(r1, r2) {
|
||||
return r2.x < (r1.x+r1.width) &&
|
||||
(r2.x+r2.width) > r1.x &&
|
||||
r2.y < (r1.y+r1.height) &&
|
||||
(r2.y+r2.height) > r1.y;
|
||||
};
|
||||
|
||||
// Function: text2xml
|
||||
// Cross-browser compatible method of converting a string to an XML tree
|
||||
// found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f
|
||||
@@ -332,6 +316,8 @@ svgedit.utilities.findDefs = function(svgElement) {
|
||||
return defs;
|
||||
};
|
||||
|
||||
// TODO(codedread): Consider moving the next to functions to bbox.js
|
||||
|
||||
// Function: svgedit.utilities.getPathBBox
|
||||
// Get correct BBox for a path in Webkit
|
||||
// Converted from code found here:
|
||||
|
||||
Reference in New Issue
Block a user