Mercurial > hg > digilib
changeset 1374:3959d2bc4677
oval: some constraints; fixed a bug in line.length
author | hertzhaft |
---|---|
date | Tue, 24 Feb 2015 16:00:11 +0100 |
parents | 81ece2629d42 |
children | 4ca66f4bdd3e |
files | webapp/src/main/webapp/jquery/jquery.digilib.geometry.js webapp/src/main/webapp/jquery/jquery.digilib.measure.js |
diffstat | 2 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.geometry.js Tue Feb 24 10:37:09 2015 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.geometry.js Tue Feb 24 16:00:11 2015 +0100 @@ -151,6 +151,12 @@ top : this.y }); }; + // move this position to another + that.moveTo = function(other) { + this.x = other.x; + this.y = other.y; + return this; + }; // adjust this position so that is is inside rect that.clipTo = function (rect) { var p1 = rect.getPt1(); @@ -285,7 +291,7 @@ that.length = function(length) { var dist = this.dist(); if (length == null) { - return this.dist; + return dist; } var ratio = length/dist; this.dx *= ratio;
--- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Tue Feb 24 10:37:09 2015 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Tue Feb 24 16:00:11 2015 +0100 @@ -1251,7 +1251,14 @@ var mid3 = side3.mid(); var axis0 = side0.parallel(mid3); // short axis var axis1 = side1.parallel(mid0); // long axis - var handle = axis1.perpendicularPoint(p[3]); // drag point projected on long axis + var maxDiam = axis0.length()-1; // maximal diameter for small circles + var handle = axis1.perpendicularPoint(p[3]); // drag point projected on long axis + console.debug(handle.distance(mid2), maxDiam); + if (handle.distance(mid0) > axis1.length()) { // constrain handle + handle.moveTo(mid2); + } else if (handle.distance(mid2) > maxDiam) { + handle.moveTo(geom.line(mid2, handle).length(maxDiam).point()); + } var m1 = handle.mid(mid2); // midpoints of the small circles var m2 = axis0.mirror(m1); var rad1 = m1.distance(mid2); // radius of the small circles