Added line to getbbox primitives

master
Dmitry Baranovskiy 2013-11-27 13:20:50 +11:00
parent e2fdaaf12e
commit aa6be97f60
4 changed files with 25 additions and 19 deletions

File diff suppressed because one or more lines are too long

3
dist/snap.svg.js vendored
View File

@ -4851,6 +4851,9 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
var bbox = el.getBBox(); var bbox = el.getBBox();
return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
}, },
line: function (el) {
return "M" + [el.attr("x1"), el.attr("y1"), el.attr("x2"), el.attr("y2")];
},
polyline: function (el) { polyline: function (el) {
return "M" + el.attr("points"); return "M" + el.attr("points");
}, },

View File

@ -10820,7 +10820,7 @@ prototypes). This allow you to extend anything you want.
<article id="Snap.path.getTotalLength"> <article id="Snap.path.getTotalLength">
<header> <header>
<h3 class="dr-method">Snap.path.getTotalLength(path)<a href="#Snap.path.getTotalLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1069 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1069">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.getTotalLength(path)<a href="#Snap.path.getTotalLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1072 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1072">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.getTotalLength-extra"></div> <div class="extra" id="Snap.path.getTotalLength-extra"></div>
@ -10880,7 +10880,7 @@ prototypes). This allow you to extend anything you want.
<article id="Snap.path.getPointAtLength"> <article id="Snap.path.getPointAtLength">
<header> <header>
<h3 class="dr-method">Snap.path.getPointAtLength(path, length)<a href="#Snap.path.getPointAtLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1086 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1086">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.getPointAtLength(path, length)<a href="#Snap.path.getPointAtLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1089 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1089">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.getPointAtLength-extra"></div> <div class="extra" id="Snap.path.getPointAtLength-extra"></div>
@ -10987,7 +10987,7 @@ prototypes). This allow you to extend anything you want.
<article id="Snap.path.getSubpath"> <article id="Snap.path.getSubpath">
<header> <header>
<h3 class="dr-method">Snap.path.getSubpath(path, from, to)<a href="#Snap.path.getSubpath" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1099 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1099">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.getSubpath(path, from, to)<a href="#Snap.path.getSubpath" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1102 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1102">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.getSubpath-extra"></div> <div class="extra" id="Snap.path.getSubpath-extra"></div>
@ -11053,7 +11053,7 @@ prototypes). This allow you to extend anything you want.
<article id="Element.getTotalLength"> <article id="Element.getTotalLength">
<header> <header>
<h3 class="dr-method">Element.getTotalLength()<a href="#Element.getTotalLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1113 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1113">&#x27ad;</a></h3> <h3 class="dr-method">Element.getTotalLength()<a href="#Element.getTotalLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1116 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1116">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Element.getTotalLength-extra"></div> <div class="extra" id="Element.getTotalLength-extra"></div>
@ -11095,7 +11095,7 @@ prototypes). This allow you to extend anything you want.
<article id="Element.getPointAtLength"> <article id="Element.getPointAtLength">
<header> <header>
<h3 class="dr-method">Element.getPointAtLength(length)<a href="#Element.getPointAtLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1134 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1134">&#x27ad;</a></h3> <h3 class="dr-method">Element.getPointAtLength(length)<a href="#Element.getPointAtLength" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1137 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1137">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Element.getPointAtLength-extra"></div> <div class="extra" id="Element.getPointAtLength-extra"></div>
@ -11199,7 +11199,7 @@ prototypes). This allow you to extend anything you want.
<article id="Element.getSubpath"> <article id="Element.getSubpath">
<header> <header>
<h3 class="dr-method">Element.getSubpath(from, to)<a href="#Element.getSubpath" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1149 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1149">&#x27ad;</a></h3> <h3 class="dr-method">Element.getSubpath(from, to)<a href="#Element.getSubpath" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1152 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1152">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Element.getSubpath-extra"></div> <div class="extra" id="Element.getSubpath-extra"></div>
@ -11262,7 +11262,7 @@ prototypes). This allow you to extend anything you want.
<article id="Snap.path.findDotsAtSegment"> <article id="Snap.path.findDotsAtSegment">
<header> <header>
<h3 class="dr-method">Snap.path.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)<a href="#Snap.path.findDotsAtSegment" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1192 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1192">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)<a href="#Snap.path.findDotsAtSegment" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1195 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1195">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.findDotsAtSegment-extra"></div> <div class="extra" id="Snap.path.findDotsAtSegment-extra"></div>
@ -11487,7 +11487,7 @@ Finds dot coordinates on the given cubic beziér curve at the given t
<article id="Snap.path.bezierBBox"> <article id="Snap.path.bezierBBox">
<header> <header>
<h3 class="dr-method">Snap.path.bezierBBox(…)<a href="#Snap.path.bezierBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1220 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1220">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.bezierBBox(…)<a href="#Snap.path.bezierBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1223 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1223">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.bezierBBox-extra"></div> <div class="extra" id="Snap.path.bezierBBox-extra"></div>
@ -11666,7 +11666,7 @@ Returns the bounding box of a given cubic beziér curve
<article id="Snap.path.isPointInsideBBox"> <article id="Snap.path.isPointInsideBBox">
<header> <header>
<h3 class="dr-method">Snap.path.isPointInsideBBox(bbox, x, y)<a href="#Snap.path.isPointInsideBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1233 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1233">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.isPointInsideBBox(bbox, x, y)<a href="#Snap.path.isPointInsideBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1236 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1236">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.isPointInsideBBox-extra"></div> <div class="extra" id="Snap.path.isPointInsideBBox-extra"></div>
@ -11733,7 +11733,7 @@ Returns <code>true</code> if given point is inside bounding box
<article id="Snap.path.isBBoxIntersect"> <article id="Snap.path.isBBoxIntersect">
<header> <header>
<h3 class="dr-method">Snap.path.isBBoxIntersect(bbox1, bbox2)<a href="#Snap.path.isBBoxIntersect" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1245 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1245">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.isBBoxIntersect(bbox1, bbox2)<a href="#Snap.path.isBBoxIntersect" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1248 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1248">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.isBBoxIntersect-extra"></div> <div class="extra" id="Snap.path.isBBoxIntersect-extra"></div>
@ -11797,7 +11797,7 @@ Returns <code>true</code> if two bounding boxes intersect
<article id="Snap.path.intersection"> <article id="Snap.path.intersection">
<header> <header>
<h3 class="dr-method">Snap.path.intersection(path1, path2)<a href="#Snap.path.intersection" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1269 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1269">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.intersection(path1, path2)<a href="#Snap.path.intersection" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1272 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1272">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.intersection-extra"></div> <div class="extra" id="Snap.path.intersection-extra"></div>
@ -11953,7 +11953,7 @@ Finds intersections of two paths
<article id="Snap.path.isPointInside"> <article id="Snap.path.isPointInside">
<header> <header>
<h3 class="dr-method">Snap.path.isPointInside(path, x, y)<a href="#Snap.path.isPointInside" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1285 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1285">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.isPointInside(path, x, y)<a href="#Snap.path.isPointInside" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1288 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1288">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.isPointInside-extra"></div> <div class="extra" id="Snap.path.isPointInside-extra"></div>
@ -12021,7 +12021,7 @@ Returns <code>true</code> if given point is inside a given closed path.
<article id="Snap.path.getBBox"> <article id="Snap.path.getBBox">
<header> <header>
<h3 class="dr-method">Snap.path.getBBox(path)<a href="#Snap.path.getBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1304 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1304">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.getBBox(path)<a href="#Snap.path.getBBox" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1307 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1307">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.getBBox-extra"></div> <div class="extra" id="Snap.path.getBBox-extra"></div>
@ -12150,7 +12150,7 @@ Returns the bounding box of a given path
<article id="Snap.path.toRelative"> <article id="Snap.path.toRelative">
<header> <header>
<h3 class="dr-method">Snap.path.toRelative(path)<a href="#Snap.path.toRelative" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1316 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1316">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.toRelative(path)<a href="#Snap.path.toRelative" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1319 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1319">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.toRelative-extra"></div> <div class="extra" id="Snap.path.toRelative-extra"></div>
@ -12211,7 +12211,7 @@ Converts path coordinates into relative values
<article id="Snap.path.toAbsolute"> <article id="Snap.path.toAbsolute">
<header> <header>
<h3 class="dr-method">Snap.path.toAbsolute(path)<a href="#Snap.path.toAbsolute" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1327 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1327">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.toAbsolute(path)<a href="#Snap.path.toAbsolute" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1330 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1330">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.toAbsolute-extra"></div> <div class="extra" id="Snap.path.toAbsolute-extra"></div>
@ -12272,7 +12272,7 @@ Converts path coordinates into absolute values
<article id="Snap.path.toCubic"> <article id="Snap.path.toCubic">
<header> <header>
<h3 class="dr-method">Snap.path.toCubic(pathString)<a href="#Snap.path.toCubic" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1338 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1338">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.toCubic(pathString)<a href="#Snap.path.toCubic" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1341 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1341">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.toCubic-extra"></div> <div class="extra" id="Snap.path.toCubic-extra"></div>
@ -12333,7 +12333,7 @@ Converts path to a new path where all segments are cubic beziér curves
<article id="Snap.path.map"> <article id="Snap.path.map">
<header> <header>
<h3 class="dr-method">Snap.path.map(path, matrix)<a href="#Snap.path.map" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1348 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1348">&#x27ad;</a></h3> <h3 class="dr-method">Snap.path.map(path, matrix)<a href="#Snap.path.map" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 1351 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#1351">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Snap.path.map-extra"></div> <div class="extra" id="Snap.path.map-extra"></div>

View File

@ -523,6 +523,9 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
var bbox = el.getBBox(); var bbox = el.getBBox();
return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
}, },
line: function (el) {
return "M" + [el.attr("x1"), el.attr("y1"), el.attr("x2"), el.attr("y2")];
},
polyline: function (el) { polyline: function (el) {
return "M" + el.attr("points"); return "M" + el.attr("points");
}, },