WIP no crop functionality

This commit is contained in:
Erik Tiekstra
2017-05-12 11:01:36 +02:00
parent 4544b96093
commit 7d41f6b2e2
6 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ var DragHandle = function (handler) {
};
this.init = function () {
var viewportData = this.getCanvas().getViewport().getCropData();
var viewportData = this.getCanvas().getViewport().getData();
var tracks = handler.getTracks();
if (this.__handles) {
+2 -2
View File
@@ -8,7 +8,7 @@ function GoreHandler(viewport) {
* @return {fabric.Line}
*/
function getLine(left) {
return new fabric.Line([0, 0, 0, viewport.getCropData().height], {
return new fabric.Line([0, 0, 0, viewport.getData().height], {
evented: false,
strokeDashArray: [5, 5],
stroke: '#000',
@@ -43,7 +43,7 @@ function GoreHandler(viewport) {
}
var bounds = viewport.getBounds();
var step = viewport.getCropData().ppmm * 450;
var step = viewport.getData().ppmm * 450;
var count = Math.ceil(bounds.width / step);
for (var i = 1; i < count; i++) {
@@ -16,10 +16,10 @@ function RulerHandler(viewport) {
var bounds = viewport.getBounds();
var pos = util.assertBetween(this[axis], bounds.min[axis], bounds.max[axis]);
this.marker[axis] = this[axis] = pos;
var dim = (this[axis] - bounds[axis]) / (viewport.getCropData().ppmm * 10);
var dim = (this[axis] - bounds[axis]) / (viewport.getData().ppmm * 10);
if (axis === 'top') {
dim = viewport.getCropData().dim.height - dim;
dim = viewport.getData().dim.height - dim;
}
this.setText(Math.round(dim * 100) / 100 + ' cm');
+1 -1
View File
@@ -124,7 +124,7 @@ function Viewport(canvas) {
canvas.getButtonMenu().bringToFront();
};
this.getCropData = function () {
this.getData = function () {
return _data;
};
+7 -2
View File
@@ -17,9 +17,14 @@ function calcCrop(obj, width, height) {
var returnValue = {
image: obj,
axis: objRatio > cropRatio ? 'x' : 'y',
dim: { width: width, height: height },
dim: {
width: Number(width),
height: Number(height)
},
width: obj.width,
height: obj.height
height: obj.height,
objectRatio: objRatio,
cropRatio: cropRatio
};
if (objRatio > cropRatio) {