Mercurial > hg > digilib
comparison client/digitallibrary/jquery/jquery.digilib.js @ 668:9f8056d6c289 jquery
transformation with mirror works now too!
| author | robcast |
|---|---|
| date | Tue, 25 Jan 2011 22:04:27 +0100 |
| parents | 1e9d7d92135c |
| children | b2a1421572b5 |
comparison
equal
deleted
inserted
replaced
| 666:1e9d7d92135c | 668:9f8056d6c289 |
|---|---|
| 784 } | 784 } |
| 785 return isVisible; | 785 return isVisible; |
| 786 }; | 786 }; |
| 787 | 787 |
| 788 // create Transform from area and $img | 788 // create Transform from area and $img |
| 789 var getImgTrafo = function ($img, area, data) { | 789 var getImgTrafo = function ($img, area, rot, hmir, vmir) { |
| 790 var picrect = geom.rectangle($img); | 790 var picrect = geom.rectangle($img); |
| 791 var trafo = geom.transform(); | 791 var trafo = geom.transform(); |
| 792 // zoom area offset | 792 // move zoom area offset to center |
| 793 trafo.concat(trafo.getTranslation(geom.position(-area.x, -area.y))); | 793 trafo.concat(trafo.getTranslation(geom.position(-area.x, -area.y))); |
| 794 // zoom area size | 794 // scale zoom area size to [1,1] |
| 795 trafo.concat(trafo.getScale(geom.size(1/area.width, 1/area.height))); | 795 trafo.concat(trafo.getScale(geom.size(1/area.width, 1/area.height))); |
| 796 // rotate (around transformed image center i.e. [0.5,0.5]) | 796 // rotate and mirror (around transformed image center i.e. [0.5,0.5]) |
| 797 if (data) { | 797 if (rot || hmir || vmir) { |
| 798 var rot = trafo.getRotationAround(parseFloat(data.settings.rot), | 798 // move [0.5,0.5] to center |
| 799 geom.position(0.5, 0.5)); | 799 trafo.concat(trafo.getTranslation(geom.position(-0.5, -0.5))); |
| 800 trafo.concat(rot); | 800 if (hmir) { |
| 801 // mirror about center | |
| 802 trafo.concat(trafo.getMirror('y')); | |
| 803 } | |
| 804 if (vmir) { | |
| 805 // mirror about center | |
| 806 trafo.concat(trafo.getMirror('x')); | |
| 807 } | |
| 808 if (rot) { | |
| 809 // rotate around center | |
| 810 trafo.concat(trafo.getRotation(parseFloat(rot))); | |
| 811 } | |
| 812 // move back | |
| 813 trafo.concat(trafo.getTranslation(geom.position(0.5, 0.5))); | |
| 801 } | 814 } |
| 802 // scale to screen position and size | 815 // scale to screen position and size |
| 803 trafo.concat(trafo.getScale(picrect)); | 816 trafo.concat(trafo.getScale(picrect)); |
| 804 trafo.concat(trafo.getTranslation(picrect)); | 817 trafo.concat(trafo.getTranslation(picrect)); |
| 805 return trafo; | 818 return trafo; |
| 809 var scalerImgLoadedHandler = function (data) { | 822 var scalerImgLoadedHandler = function (data) { |
| 810 var $img = data.$img; | 823 var $img = data.$img; |
| 811 return function () { | 824 return function () { |
| 812 console.debug("img loaded! this=", this, " data=", data); | 825 console.debug("img loaded! this=", this, " data=", data); |
| 813 // create Transform from current area and picsize | 826 // create Transform from current area and picsize |
| 814 data.imgTrafo = getImgTrafo($img, data.zoomArea, data); | 827 data.imgTrafo = getImgTrafo($img, data.zoomArea, |
| 828 data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir); | |
| 815 // display marks | 829 // display marks |
| 816 renderMarks(data); | 830 renderMarks(data); |
| 817 //digilib.showArrows(); // show arrow overlays for zoom navigation | 831 //digilib.showArrows(); // show arrow overlays for zoom navigation |
| 818 var $birdImg = data.$birdImg; | 832 var $birdImg = data.$birdImg; |
| 819 if ($birdImg) { | 833 if ($birdImg) { |
