diff --git a/.gitignore b/.gitignore index 5ca5bba7..991d855d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,12 @@ /typings +/dist +src/**/*.js.map +src/**/*.d.ts +src/**/*.js +runtime/*.js +index.js.map +index.d.ts +index.js ################# ## Misc ################# diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7589c9ed..00000000 --- a/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './src/imageCropperComponent'; -export * from './src/imageCropper'; -export * from './src/cropperSettings'; -export * from './src/cropperDrawSettings'; -export * from './src/model/bounds'; diff --git a/index.html b/index.html index e7be216f..670e3071 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,4 @@ - @@ -10,14 +9,10 @@ - Loading... - - - \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 2ba1351f..00000000 --- a/index.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -__export(require('./src/imageCropperComponent')); -__export(require('./src/imageCropper')); -__export(require('./src/cropperSettings')); -__export(require('./src/cropperDrawSettings')); -__export(require('./src/model/bounds')); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.js.map b/index.js.map deleted file mode 100644 index e0a7efe6..00000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,6BAA6B,CAAC,EAAA;AAC5C,iBAAc,oBAAoB,CAAC,EAAA;AACnC,iBAAc,uBAAuB,CAAC,EAAA;AACtC,iBAAc,2BAA2B,CAAC,EAAA;AAC1C,iBAAc,oBAAoB,CAAC,EAAA"} \ No newline at end of file diff --git a/index.ts b/index.ts index eeda989d..6fc3b4b7 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,5 @@ -export * from './src/imageCropperComponent'; -export * from './src/imageCropper'; -export * from './src/cropperSettings'; -export * from './src/cropperDrawSettings'; -export * from './src/model/bounds'; \ No newline at end of file +export * from "./src/imageCropperComponent"; +export * from "./src/imageCropper"; +export * from "./src/cropperSettings"; +export * from "./src/cropperDrawSettings"; +export * from "./src/model/bounds"; \ No newline at end of file diff --git a/package.json b/package.json index 191c2c68..cef74997 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,26 @@ { "name": "ng2-img-cropper", - "version": "0.6.1", + "version": "0.6.4", "description": "Angular2 Image Cropper Component", "repository": { "type": "git", "url": "git+https://github.com/cstefanache/angular2-img-cropper.git" }, "scripts": { - "prepublish": "tsc", + "tsc": "tsc", + "postinstall": "typings install", + "build": "tsc -p ./", + "preversion": "npm test && npm run build", + "version": "git commit -am \"Prerelease updates\" && git checkout -b release && git add -f ./", + "postversion": "git push --tags && git checkout master && git branch -D release && git push && npm publish", + "release:patch": "npm version patch && npm publish", + "release:minor": "npm version minor && npm publish", + "release:major": "npm version major && npm publish", + "compile": "npm run compile:ts", + "compile:ts": "tsc", + "typings": "typings", "all": "concurrently \"tsc -w \" \"tsc -p runtime -w \" \"npm run lite\" ", + "start": "concurrently \"tsc -w \" \"tsc -p runtime -w \" \"npm run lite\" ", "watch": "tsc -w ", "lite": "lite-server" }, @@ -28,11 +40,10 @@ "bootstrap": "^3.3.6", "concurrently": "^2.0.0", "es6-shim": "^0.35.0", - "jquery": "^2.2.3", "lite-server": "^2.2.0", "ng2-styler": "^0.1.2", "reflect-metadata": "^0.1.3", - "rxjs": "5.0.0-beta.6", + "rxjs": "^5.0.0-beta.6", "systemjs": "0.19.27", "typescript": "^1.8.10", "typings": "^1.3.0", diff --git a/runtime/main.ts b/runtime/main.ts index 70f06cc0..34e6962d 100644 --- a/runtime/main.ts +++ b/runtime/main.ts @@ -1,5 +1,5 @@ -import { bootstrap } from '@angular/platform-browser-dynamic'; -import {AppComponent} from './app'; - +import {bootstrap} from "@angular/platform-browser-dynamic"; +import {AppComponent} from "./app"; +// todo: update to angular2 rc.5 with ngModule. bootstrap(AppComponent, []); diff --git a/runtime/tsconfig.json b/runtime/tsconfig.json index 76994741..394e5b80 100644 --- a/runtime/tsconfig.json +++ b/runtime/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "out": "dist/img-cropper-test-app.js", - "noImplicitAny": false, + "noImplicitAny": true, "module": "system", "target": "es5", "emitDecoratorMetadata": true, diff --git a/src/cropperDrawSettings.d.ts b/src/cropperDrawSettings.d.ts deleted file mode 100644 index b22a145c..00000000 --- a/src/cropperDrawSettings.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare class CropperDrawSettings { - strokeWidth: number; - strokeColor: string; - constructor(strokeWidth?: number, strokeColor?: string); -} diff --git a/src/cropperDrawSettings.js b/src/cropperDrawSettings.js deleted file mode 100644 index 71bc163b..00000000 --- a/src/cropperDrawSettings.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; -var CropperDrawSettings = (function () { - function CropperDrawSettings(strokeWidth, strokeColor) { - if (strokeWidth === void 0) { strokeWidth = 1; } - if (strokeColor === void 0) { strokeColor = 'rgba(255,255,255,0.9)'; } - this.strokeWidth = strokeWidth; - this.strokeColor = strokeColor; - } - return CropperDrawSettings; -}()); -exports.CropperDrawSettings = CropperDrawSettings; -//# sourceMappingURL=cropperDrawSettings.js.map \ No newline at end of file diff --git a/src/cropperDrawSettings.js.map b/src/cropperDrawSettings.js.map deleted file mode 100644 index e74430f1..00000000 --- a/src/cropperDrawSettings.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cropperDrawSettings.js","sourceRoot":"","sources":["cropperDrawSettings.ts"],"names":[],"mappings":";AAAA;IACI,6BAAmB,WAAsB,EAAS,WAA4C;QAAlF,2BAA6B,GAA7B,eAA6B;QAAE,2BAAmD,GAAnD,qCAAmD;QAA3E,gBAAW,GAAX,WAAW,CAAW;QAAS,gBAAW,GAAX,WAAW,CAAiC;IAC9F,CAAC;IACL,0BAAC;AAAD,CAAC,AAHD,IAGC;AAHY,2BAAmB,sBAG/B,CAAA"} \ No newline at end of file diff --git a/src/cropperDrawSettings.ts b/src/cropperDrawSettings.ts index 4d2f3a7c..e1ffd63f 100644 --- a/src/cropperDrawSettings.ts +++ b/src/cropperDrawSettings.ts @@ -1,4 +1,4 @@ export class CropperDrawSettings { - constructor(public strokeWidth:number = 1, public strokeColor:string = 'rgba(255,255,255,0.9)') { - } -} \ No newline at end of file + public strokeWidth: number = 1; + public strokeColor: string = "rgba(255,255,255,1)"; +} diff --git a/src/cropperSettings.d.ts b/src/cropperSettings.d.ts deleted file mode 100644 index a661a902..00000000 --- a/src/cropperSettings.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { CropperDrawSettings } from "./cropperDrawSettings"; -export declare class CropperSettings { - canvasWidth: number; - canvasHeight: number; - width: number; - height: number; - minWidth: number; - minHeight: number; - minWithRelativeToResolution: boolean; - croppedWidth: number; - croppedHeight: number; - cropperDrawSettings: CropperDrawSettings; - touchRadius: number; - noFileInput: boolean; - allowedFilesRegex: RegExp; - private _rounded; - private _keepAspect; - rounded: boolean; - keepAspect: boolean; -} diff --git a/src/cropperSettings.js b/src/cropperSettings.js deleted file mode 100644 index eee812c3..00000000 --- a/src/cropperSettings.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -var cropperDrawSettings_1 = require("./cropperDrawSettings"); -var CropperSettings = (function () { - function CropperSettings() { - this.canvasWidth = 300; - this.canvasHeight = 300; - this.width = 200; - this.height = 200; - this.minWidth = 50; - this.minHeight = 50; - this.minWithRelativeToResolution = true; - this.croppedWidth = 100; - this.croppedHeight = 100; - this.cropperDrawSettings = new cropperDrawSettings_1.CropperDrawSettings(); - this.touchRadius = 20; - this.noFileInput = false; - this.allowedFilesRegex = /\.(jpe?g|png|gif)$/i; - this._rounded = false; - this._keepAspect = true; - } - Object.defineProperty(CropperSettings.prototype, "rounded", { - get: function () { - return this._rounded; - }, - set: function (val) { - this._rounded = val; - if (val) { - this._keepAspect = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CropperSettings.prototype, "keepAspect", { - get: function () { - return this._keepAspect; - }, - set: function (val) { - if (val === false && this._rounded) { - throw new Error("Cannot set keep aspect to false on rounded cropper. Ellipsis not supported"); - } - this._keepAspect = val; - }, - enumerable: true, - configurable: true - }); - return CropperSettings; -}()); -exports.CropperSettings = CropperSettings; -//# sourceMappingURL=cropperSettings.js.map \ No newline at end of file diff --git a/src/cropperSettings.js.map b/src/cropperSettings.js.map deleted file mode 100644 index 9d6cf358..00000000 --- a/src/cropperSettings.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cropperSettings.js","sourceRoot":"","sources":["cropperSettings.ts"],"names":[],"mappings":";AAAA,oCAAkC,uBAAuB,CAAC,CAAA;AAC1D;IAAA;QACI,gBAAW,GAAU,GAAG,CAAC;QACzB,iBAAY,GAAU,GAAG,CAAC;QAE1B,UAAK,GAAU,GAAG,CAAC;QACnB,WAAM,GAAU,GAAG,CAAC;QAEpB,aAAQ,GAAU,EAAE,CAAC;QACrB,cAAS,GAAU,EAAE,CAAC;QACtB,gCAA2B,GAAW,IAAI,CAAC;QAE3C,iBAAY,GAAU,GAAG,CAAC;QAC1B,kBAAa,GAAU,GAAG,CAAC;QAG3B,wBAAmB,GAAuB,IAAI,yCAAmB,EAAE,CAAC;QACpE,gBAAW,GAAU,EAAE,CAAC;QACxB,gBAAW,GAAW,KAAK,CAAC;QAE5B,sBAAiB,GAAU,qBAAqB,CAAC;QAEzC,aAAQ,GAAW,KAAK,CAAC;QACzB,gBAAW,GAAW,IAAI,CAAC;IAyBvC,CAAC;IAvBG,sBAAI,oCAAO;aAOX;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aATD,UAAY,GAAW;YACnB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;YACpB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACN,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YAC5B,CAAC;QACL,CAAC;;;OAAA;IAMD,sBAAI,uCAAU;aAQd;YACI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QAC5B,CAAC;aAVD,UAAe,GAAW;YACtB,EAAE,CAAC,CAAC,GAAG,KAAK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;YAClG,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QAC3B,CAAC;;;OAAA;IAML,sBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,uBAAe,kBA+C3B,CAAA"} \ No newline at end of file diff --git a/src/cropperSettings.ts b/src/cropperSettings.ts index 86d1fc4f..f282caea 100644 --- a/src/cropperSettings.ts +++ b/src/cropperSettings.ts @@ -1,40 +1,65 @@ import {CropperDrawSettings} from "./cropperDrawSettings"; -export class CropperSettings { - canvasWidth:number = 300; - canvasHeight:number = 300; - width:number = 200; - height:number = 200; +export interface ICropperSettings { + canvasWidth?: number; + canvasHeight?: number; + width?: number; + height?: number; + minWidth?: number; + minHeight?: number; + minWithRelativeToResolution?: boolean; + croppedWidth?: number; + croppedHeight?: number; + touchRadius?: number; + cropperDrawSettings?: any; + noFileInput?: boolean; + allowedFilesRegex?: RegExp; + rounded: boolean; + keepAspect: boolean; +} - minWidth:number = 50; - minHeight:number = 50; - minWithRelativeToResolution:boolean = true; +export class CropperSettings implements ICropperSettings { - croppedWidth:number = 100; - croppedHeight:number = 100; + public canvasWidth: number = 300; + public canvasHeight: number = 300; + public width: number = 200; + public height: number = 200; - cropperDrawSettings:CropperDrawSettings = new CropperDrawSettings(); - touchRadius:number = 20; - noFileInput:boolean = false; + public minWidth: number = 50; + public minHeight: number = 50; + public minWithRelativeToResolution: boolean = true; - allowedFilesRegex:RegExp = /\.(jpe?g|png|gif)$/i; + public responsive: boolean = false; - private _rounded:boolean = false; - private _keepAspect:boolean = true; + public croppedWidth: number = 100; + public croppedHeight: number = 100; - set rounded(val:boolean) { + public cropperDrawSettings: CropperDrawSettings = new CropperDrawSettings(); + public touchRadius: number = 20; + public noFileInput: boolean = false; + + public allowedFilesRegex: RegExp = /\.(jpe?g|png|gif)$/i; + + private _rounded: boolean = false; + private _keepAspect: boolean = true; + + constructor() { + // init + } + + set rounded(val: boolean) { this._rounded = val; if (val) { this._keepAspect = true; } } - get rounded() { + get rounded(): boolean { return this._rounded; } - set keepAspect(val:boolean) { + set keepAspect(val: boolean) { if (val === false && this._rounded) { throw new Error("Cannot set keep aspect to false on rounded cropper. Ellipsis not supported"); } @@ -42,8 +67,7 @@ export class CropperSettings { this._keepAspect = val; } - get keepAspect() { + get keepAspect(): boolean { return this._keepAspect; } - -} \ No newline at end of file +} diff --git a/src/exif.d.ts b/src/exif.d.ts deleted file mode 100644 index 5edfa1dd..00000000 --- a/src/exif.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -export declare class Exif { - static debug: boolean; - static IptcFieldMap: Object; - static Tags: Object; - static TiffTags: Object; - static GPSTags: Object; - static StringValues: Object; - static addEvent(element: any, event: any, handler: any): void; - static imageHasData(img: any): boolean; - static base64ToArrayBuffer(base64: any, contentType?: any): ArrayBuffer; - static objectURLToBlob(url: any, callback: any): void; - static getImageData(img: any, callback: any): void; - static findEXIFinJPEG(file: any): any; - static findIPTCinJPEG(file: any): {}; - static readIPTCData(file: any, startOffset: any, sectionLength: any): {}; - static readTags(file: any, tiffStart: any, dirStart: any, strings: any, bigEnd: any): {}; - static readTagValue(file: any, entryOffset: any, tiffStart: any, dirStart: any, bigEnd: any): any; - static getStringFromDB(buffer: any, start: any, length: any): string; - static readEXIFData(file: any, start: any): any; - static getData(img: any, callback: Function): boolean; - static getTag(img: any, tag: any): any; - static getAllTags(img: any): {}; - static pretty(img: any): string; - readFromBinaryFile(file: any): any; -} diff --git a/src/exif.js b/src/exif.js deleted file mode 100644 index 2bcb42b8..00000000 --- a/src/exif.js +++ /dev/null @@ -1,699 +0,0 @@ -"use strict"; -var Exif = (function () { - function Exif() { - } - Exif.addEvent = function (element, event, handler) { - if (element.addEventListener) { - element.addEventListener(event, handler, false); - } - else if (element.attachEvent) { - element.attachEvent("on" + event, handler); - } - }; - Exif.imageHasData = function (img) { - return !!(img.exifdata); - }; - Exif.base64ToArrayBuffer = function (base64, contentType) { - contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; - base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, ''); - var binary = atob(base64); - var len = binary.length; - var buffer = new ArrayBuffer(len); - var view = new Uint8Array(buffer); - for (var i = 0; i < len; i++) { - view[i] = binary.charCodeAt(i); - } - return buffer; - }; - Exif.objectURLToBlob = function (url, callback) { - var http = new XMLHttpRequest(); - http.open("GET", url, true); - http.responseType = "blob"; - http.onload = function (e) { - if (this.status == 200 || this.status === 0) { - callback(this.response); - } - }; - http.send(); - }; - Exif.getImageData = function (img, callback) { - function handleBinaryFile(binFile) { - var data = Exif.findEXIFinJPEG(binFile); - var iptcdata = Exif.findIPTCinJPEG(binFile); - img.exifdata = data || {}; - img.iptcdata = iptcdata || {}; - if (callback) { - callback.call(img); - } - } - if (img.src) { - if (/^data\:/i.test(img.src)) { - var arrayBuffer = Exif.base64ToArrayBuffer(img.src); - handleBinaryFile(arrayBuffer); - } - else if (/^blob\:/i.test(img.src)) { - var fileReader = new FileReader(); - fileReader.onload = function (e) { - handleBinaryFile(e.target.result); - }; - Exif.objectURLToBlob(img.src, function (blob) { - fileReader.readAsArrayBuffer(blob); - }); - } - else { - var http = new XMLHttpRequest(); - http.onload = function () { - if (this.status == 200 || this.status === 0) { - handleBinaryFile(http.response); - } - else { - throw "Could not load image"; - } - http = null; - }; - http.open("GET", img.src, true); - http.responseType = "arraybuffer"; - http.send(null); - } - } - else if (FileReader && (img instanceof Blob || img instanceof File)) { - var fileReader = new FileReader(); - fileReader.onload = function (e) { - if (Exif.debug) - console.log("Got file of length " + e.target.result.byteLength); - handleBinaryFile(e.target.result); - }; - fileReader.readAsArrayBuffer(img); - } - }; - Exif.findEXIFinJPEG = function (file) { - var dataView = new DataView(file); - if (Exif.debug) - console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (Exif.debug) - console.log("Not a valid JPEG"); - return false; - } - var offset = 2, length = file.byteLength, marker; - while (offset < length) { - if (dataView.getUint8(offset) != 0xFF) { - if (Exif.debug) - console.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8(offset)); - return false; - } - marker = dataView.getUint8(offset + 1); - if (Exif.debug) - console.log(marker); - if (marker == 225) { - if (Exif.debug) - console.log("Found 0xFFE1 marker"); - return Exif.readEXIFData(dataView, offset + 4); - } - else { - offset += 2 + dataView.getUint16(offset + 2); - } - } - }; - Exif.findIPTCinJPEG = function (file) { - var dataView = new DataView(file); - if (Exif.debug) - console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (Exif.debug) - console.log("Not a valid JPEG"); - return false; - } - var offset = 2, length = file.byteLength; - var isFieldSegmentStart = function (dataView, offset) { - return (dataView.getUint8(offset) === 0x38 && - dataView.getUint8(offset + 1) === 0x42 && - dataView.getUint8(offset + 2) === 0x49 && - dataView.getUint8(offset + 3) === 0x4D && - dataView.getUint8(offset + 4) === 0x04 && - dataView.getUint8(offset + 5) === 0x04); - }; - while (offset < length) { - if (isFieldSegmentStart(dataView, offset)) { - var nameHeaderLength = dataView.getUint8(offset + 7); - if (nameHeaderLength % 2 !== 0) - nameHeaderLength += 1; - if (nameHeaderLength === 0) { - nameHeaderLength = 4; - } - var startOffset = offset + 8 + nameHeaderLength; - var sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength); - return Exif.readIPTCData(file, startOffset, sectionLength); - } - offset++; - } - }; - Exif.readIPTCData = function (file, startOffset, sectionLength) { - var dataView = new DataView(file); - var data = {}; - var fieldValue, fieldName, dataSize, segmentType, segmentSize; - var segmentStartPos = startOffset; - while (segmentStartPos < startOffset + sectionLength) { - if (dataView.getUint8(segmentStartPos) === 0x1C && dataView.getUint8(segmentStartPos + 1) === 0x02) { - segmentType = dataView.getUint8(segmentStartPos + 2); - if (segmentType in Exif.IptcFieldMap) { - dataSize = dataView.getInt16(segmentStartPos + 3); - segmentSize = dataSize + 5; - fieldName = Exif.IptcFieldMap[segmentType]; - fieldValue = Exif.getStringFromDB(dataView, segmentStartPos + 5, dataSize); - if (data.hasOwnProperty(fieldName)) { - if (data[fieldName] instanceof Array) { - data[fieldName].push(fieldValue); - } - else { - data[fieldName] = [data[fieldName], fieldValue]; - } - } - else { - data[fieldName] = fieldValue; - } - } - } - segmentStartPos++; - } - return data; - }; - Exif.readTags = function (file, tiffStart, dirStart, strings, bigEnd) { - var entries = file.getUint16(dirStart, !bigEnd), tags = {}, entryOffset, tag, i; - for (i = 0; i < entries; i++) { - entryOffset = dirStart + i * 12 + 2; - tag = strings[file.getUint16(entryOffset, !bigEnd)]; - if (!tag && Exif.debug) - console.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd)); - tags[tag] = Exif.readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd); - } - return tags; - }; - Exif.readTagValue = function (file, entryOffset, tiffStart, dirStart, bigEnd) { - var type = file.getUint16(entryOffset + 2, !bigEnd), numValues = file.getUint32(entryOffset + 4, !bigEnd), valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart, offset, vals, val, n, numerator, denominator; - switch (type) { - case 1: - case 7: - if (numValues == 1) { - return file.getUint8(entryOffset + 8, !bigEnd); - } - else { - offset = numValues > 4 ? valueOffset : (entryOffset + 8); - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint8(offset + n); - } - return vals; - } - case 2: - offset = numValues > 4 ? valueOffset : (entryOffset + 8); - return Exif.getStringFromDB(file, offset, numValues - 1); - case 3: - if (numValues == 1) { - return file.getUint16(entryOffset + 8, !bigEnd); - } - else { - offset = numValues > 2 ? valueOffset : (entryOffset + 8); - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint16(offset + 2 * n, !bigEnd); - } - return vals; - } - case 4: - if (numValues == 1) { - return file.getUint32(entryOffset + 8, !bigEnd); - } - else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint32(valueOffset + 4 * n, !bigEnd); - } - return vals; - } - case 5: - if (numValues == 1) { - numerator = file.getUint32(valueOffset, !bigEnd); - denominator = file.getUint32(valueOffset + 4, !bigEnd); - val = new Number(numerator / denominator); - val.numerator = numerator; - val.denominator = denominator; - return val; - } - else { - vals = []; - for (n = 0; n < numValues; n++) { - numerator = file.getUint32(valueOffset + 8 * n, !bigEnd); - denominator = file.getUint32(valueOffset + 4 + 8 * n, !bigEnd); - vals[n] = new Number(numerator / denominator); - vals[n].numerator = numerator; - vals[n].denominator = denominator; - } - return vals; - } - case 9: - if (numValues == 1) { - return file.getInt32(entryOffset + 8, !bigEnd); - } - else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getInt32(valueOffset + 4 * n, !bigEnd); - } - return vals; - } - case 10: - if (numValues == 1) { - return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset + 4, !bigEnd); - } - else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getInt32(valueOffset + 8 * n, !bigEnd) / file.getInt32(valueOffset + 4 + 8 * n, !bigEnd); - } - return vals; - } - } - }; - Exif.getStringFromDB = function (buffer, start, length) { - var outstr = ""; - for (var n = start; n < start + length; n++) { - outstr += String.fromCharCode(buffer.getUint8(n)); - } - return outstr; - }; - Exif.readEXIFData = function (file, start) { - if (Exif.getStringFromDB(file, start, 4) != "Exif") { - if (Exif.debug) - console.log("Not valid EXIF data! " + Exif.getStringFromDB(file, start, 4)); - return false; - } - var bigEnd, tags, tag, exifData, gpsData, tiffOffset = start + 6; - if (file.getUint16(tiffOffset) == 0x4949) { - bigEnd = false; - } - else if (file.getUint16(tiffOffset) == 0x4D4D) { - bigEnd = true; - } - else { - if (Exif.debug) - console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"); - return false; - } - if (file.getUint16(tiffOffset + 2, !bigEnd) != 0x002A) { - if (Exif.debug) - console.log("Not valid TIFF data! (no 0x002A)"); - return false; - } - var firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd); - if (firstIFDOffset < 0x00000008) { - if (Exif.debug) - console.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset + 4, !bigEnd)); - return false; - } - tags = Exif.readTags(file, tiffOffset, tiffOffset + firstIFDOffset, Exif.TiffTags, bigEnd); - if (tags.ExifIFDPointer) { - exifData = Exif.readTags(file, tiffOffset, tiffOffset + tags.ExifIFDPointer, Exif.Tags, bigEnd); - for (tag in exifData) { - switch (tag) { - case "LightSource": - case "Flash": - case "MeteringMode": - case "ExposureProgram": - case "SensingMethod": - case "SceneCaptureType": - case "SceneType": - case "CustomRendered": - case "WhiteBalance": - case "GainControl": - case "Contrast": - case "Saturation": - case "Sharpness": - case "SubjectDistanceRange": - case "FileSource": - exifData[tag] = Exif.StringValues[tag][exifData[tag]]; - break; - case "ExifVersion": - case "FlashpixVersion": - exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], exifData[tag][3]); - break; - case "ComponentsConfiguration": - exifData[tag] = - Exif.StringValues['Components'][exifData[tag][0]] + - Exif.StringValues['Components'][exifData[tag][1]] + - Exif.StringValues['Components'][exifData[tag][2]] + - Exif.StringValues['Components'][exifData[tag][3]]; - break; - } - tags[tag] = exifData[tag]; - } - } - if (tags.GPSInfoIFDPointer) { - gpsData = Exif.readTags(file, tiffOffset, tiffOffset + tags.GPSInfoIFDPointer, Exif.GPSTags, bigEnd); - for (tag in gpsData) { - switch (tag) { - case "GPSVersionID": - gpsData[tag] = gpsData[tag][0] + - "." + gpsData[tag][1] + - "." + gpsData[tag][2] + - "." + gpsData[tag][3]; - break; - } - tags[tag] = gpsData[tag]; - } - } - return tags; - }; - Exif.getData = function (img, callback) { - if ((img instanceof Image || img instanceof HTMLImageElement) && !img.complete) - return false; - if (!Exif.imageHasData(img)) { - Exif.getImageData(img, callback); - } - else { - if (callback) { - callback.call(img); - } - } - return true; - }; - Exif.getTag = function (img, tag) { - if (!Exif.imageHasData(img)) - return; - return img.exifdata[tag]; - }; - Exif.getAllTags = function (img) { - if (!Exif.imageHasData(img)) - return {}; - var a, data = img.exifdata, tags = {}; - for (a in data) { - if (data.hasOwnProperty(a)) { - tags[a] = data[a]; - } - } - return tags; - }; - Exif.pretty = function (img) { - if (!Exif.imageHasData(img)) - return ""; - var a, data = img.exifdata, strPretty = ""; - for (a in data) { - if (data.hasOwnProperty(a)) { - if (typeof data[a] == "object") { - if (data[a] instanceof Number) { - strPretty += a + " : " + data[a] + " [" + data[a].numerator + "/" + data[a].denominator + "]\r\n"; - } - else { - strPretty += a + " : [" + data[a].length + " values]\r\n"; - } - } - else { - strPretty += a + " : " + data[a] + "\r\n"; - } - } - } - return strPretty; - }; - Exif.prototype.readFromBinaryFile = function (file) { - return Exif.findEXIFinJPEG(file); - }; - Exif.debug = false; - Exif.IptcFieldMap = { - 0x78: 'caption', - 0x6E: 'credit', - 0x19: 'keywords', - 0x37: 'dateCreated', - 0x50: 'byline', - 0x55: 'bylineTitle', - 0x7A: 'captionWriter', - 0x69: 'headline', - 0x74: 'copyright', - 0x0F: 'category' - }; - Exif.Tags = { - 0x9000: "ExifVersion", - 0xA000: "FlashpixVersion", - 0xA001: "ColorSpace", - 0xA002: "PixelXDimension", - 0xA003: "PixelYDimension", - 0x9101: "ComponentsConfiguration", - 0x9102: "CompressedBitsPerPixel", - 0x927C: "MakerNote", - 0x9286: "UserComment", - 0xA004: "RelatedSoundFile", - 0x9003: "DateTimeOriginal", - 0x9004: "DateTimeDigitized", - 0x9290: "SubsecTime", - 0x9291: "SubsecTimeOriginal", - 0x9292: "SubsecTimeDigitized", - 0x829A: "ExposureTime", - 0x829D: "FNumber", - 0x8822: "ExposureProgram", - 0x8824: "SpectralSensitivity", - 0x8827: "ISOSpeedRatings", - 0x8828: "OECF", - 0x9201: "ShutterSpeedValue", - 0x9202: "ApertureValue", - 0x9203: "BrightnessValue", - 0x9204: "ExposureBias", - 0x9205: "MaxApertureValue", - 0x9206: "SubjectDistance", - 0x9207: "MeteringMode", - 0x9208: "LightSource", - 0x9209: "Flash", - 0x9214: "SubjectArea", - 0x920A: "FocalLength", - 0xA20B: "FlashEnergy", - 0xA20C: "SpatialFrequencyResponse", - 0xA20E: "FocalPlaneXResolution", - 0xA20F: "FocalPlaneYResolution", - 0xA210: "FocalPlaneResolutionUnit", - 0xA214: "SubjectLocation", - 0xA215: "ExposureIndex", - 0xA217: "SensingMethod", - 0xA300: "FileSource", - 0xA301: "SceneType", - 0xA302: "CFAPattern", - 0xA401: "CustomRendered", - 0xA402: "ExposureMode", - 0xA403: "WhiteBalance", - 0xA404: "DigitalZoomRation", - 0xA405: "FocalLengthIn35mmFilm", - 0xA406: "SceneCaptureType", - 0xA407: "GainControl", - 0xA408: "Contrast", - 0xA409: "Saturation", - 0xA40A: "Sharpness", - 0xA40B: "DeviceSettingDescription", - 0xA40C: "SubjectDistanceRange", - 0xA005: "InteroperabilityIFDPointer", - 0xA420: "ImageUniqueID" - }; - Exif.TiffTags = { - 0x0100: "ImageWidth", - 0x0101: "ImageHeight", - 0x8769: "ExifIFDPointer", - 0x8825: "GPSInfoIFDPointer", - 0xA005: "InteroperabilityIFDPointer", - 0x0102: "BitsPerSample", - 0x0103: "Compression", - 0x0106: "PhotometricInterpretation", - 0x0112: "Orientation", - 0x0115: "SamplesPerPixel", - 0x011C: "PlanarConfiguration", - 0x0212: "YCbCrSubSampling", - 0x0213: "YCbCrPositioning", - 0x011A: "XResolution", - 0x011B: "YResolution", - 0x0128: "ResolutionUnit", - 0x0111: "StripOffsets", - 0x0116: "RowsPerStrip", - 0x0117: "StripByteCounts", - 0x0201: "JPEGInterchangeFormat", - 0x0202: "JPEGInterchangeFormatLength", - 0x012D: "TransferFunction", - 0x013E: "WhitePoint", - 0x013F: "PrimaryChromaticities", - 0x0211: "YCbCrCoefficients", - 0x0214: "ReferenceBlackWhite", - 0x0132: "DateTime", - 0x010E: "ImageDescription", - 0x010F: "Make", - 0x0110: "Model", - 0x0131: "Software", - 0x013B: "Artist", - 0x8298: "Copyright" - }; - Exif.GPSTags = { - 0x0000: "GPSVersionID", - 0x0001: "GPSLatitudeRef", - 0x0002: "GPSLatitude", - 0x0003: "GPSLongitudeRef", - 0x0004: "GPSLongitude", - 0x0005: "GPSAltitudeRef", - 0x0006: "GPSAltitude", - 0x0007: "GPSTimeStamp", - 0x0008: "GPSSatellites", - 0x0009: "GPSStatus", - 0x000A: "GPSMeasureMode", - 0x000B: "GPSDOP", - 0x000C: "GPSSpeedRef", - 0x000D: "GPSSpeed", - 0x000E: "GPSTrackRef", - 0x000F: "GPSTrack", - 0x0010: "GPSImgDirectionRef", - 0x0011: "GPSImgDirection", - 0x0012: "GPSMapDatum", - 0x0013: "GPSDestLatitudeRef", - 0x0014: "GPSDestLatitude", - 0x0015: "GPSDestLongitudeRef", - 0x0016: "GPSDestLongitude", - 0x0017: "GPSDestBearingRef", - 0x0018: "GPSDestBearing", - 0x0019: "GPSDestDistanceRef", - 0x001A: "GPSDestDistance", - 0x001B: "GPSProcessingMethod", - 0x001C: "GPSAreaInformation", - 0x001D: "GPSDateStamp", - 0x001E: "GPSDifferential" - }; - Exif.StringValues = { - ExposureProgram: { - 0: "Not defined", - 1: "Manual", - 2: "Normal program", - 3: "Aperture priority", - 4: "Shutter priority", - 5: "Creative program", - 6: "Action program", - 7: "Portrait mode", - 8: "Landscape mode" - }, - MeteringMode: { - 0: "Unknown", - 1: "Average", - 2: "CenterWeightedAverage", - 3: "Spot", - 4: "MultiSpot", - 5: "Pattern", - 6: "Partial", - 255: "Other" - }, - LightSource: { - 0: "Unknown", - 1: "Daylight", - 2: "Fluorescent", - 3: "Tungsten (incandescent light)", - 4: "Flash", - 9: "Fine weather", - 10: "Cloudy weather", - 11: "Shade", - 12: "Daylight fluorescent (D 5700 - 7100K)", - 13: "Day white fluorescent (N 4600 - 5400K)", - 14: "Cool white fluorescent (W 3900 - 4500K)", - 15: "White fluorescent (WW 3200 - 3700K)", - 17: "Standard light A", - 18: "Standard light B", - 19: "Standard light C", - 20: "D55", - 21: "D65", - 22: "D75", - 23: "D50", - 24: "ISO studio tungsten", - 255: "Other" - }, - Flash: { - 0x0000: "Flash did not fire", - 0x0001: "Flash fired", - 0x0005: "Strobe return light not detected", - 0x0007: "Strobe return light detected", - 0x0009: "Flash fired, compulsory flash mode", - 0x000D: "Flash fired, compulsory flash mode, return light not detected", - 0x000F: "Flash fired, compulsory flash mode, return light detected", - 0x0010: "Flash did not fire, compulsory flash mode", - 0x0018: "Flash did not fire, auto mode", - 0x0019: "Flash fired, auto mode", - 0x001D: "Flash fired, auto mode, return light not detected", - 0x001F: "Flash fired, auto mode, return light detected", - 0x0020: "No flash function", - 0x0041: "Flash fired, red-eye reduction mode", - 0x0045: "Flash fired, red-eye reduction mode, return light not detected", - 0x0047: "Flash fired, red-eye reduction mode, return light detected", - 0x0049: "Flash fired, compulsory flash mode, red-eye reduction mode", - 0x004D: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", - 0x004F: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", - 0x0059: "Flash fired, auto mode, red-eye reduction mode", - 0x005D: "Flash fired, auto mode, return light not detected, red-eye reduction mode", - 0x005F: "Flash fired, auto mode, return light detected, red-eye reduction mode" - }, - SensingMethod: { - 1: "Not defined", - 2: "One-chip color area sensor", - 3: "Two-chip color area sensor", - 4: "Three-chip color area sensor", - 5: "Color sequential area sensor", - 7: "Trilinear sensor", - 8: "Color sequential linear sensor" - }, - SceneCaptureType: { - 0: "Standard", - 1: "Landscape", - 2: "Portrait", - 3: "Night scene" - }, - SceneType: { - 1: "Directly photographed" - }, - CustomRendered: { - 0: "Normal process", - 1: "Custom process" - }, - WhiteBalance: { - 0: "Auto white balance", - 1: "Manual white balance" - }, - GainControl: { - 0: "None", - 1: "Low gain up", - 2: "High gain up", - 3: "Low gain down", - 4: "High gain down" - }, - Contrast: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - Saturation: { - 0: "Normal", - 1: "Low saturation", - 2: "High saturation" - }, - Sharpness: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - SubjectDistanceRange: { - 0: "Unknown", - 1: "Macro", - 2: "Close view", - 3: "Distant view" - }, - FileSource: { - 3: "DSC" - }, - Components: { - 0: "", - 1: "Y", - 2: "Cb", - 3: "Cr", - 4: "R", - 5: "G", - 6: "B" - } - }; - return Exif; -}()); -exports.Exif = Exif; -//# sourceMappingURL=exif.js.map \ No newline at end of file diff --git a/src/exif.js.map b/src/exif.js.map deleted file mode 100644 index 7282d936..00000000 --- a/src/exif.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"exif.js","sourceRoot":"","sources":["exif.ts"],"names":[],"mappings":";AAAA;IAAA;IAwxBA,CAAC;IAxeU,aAAQ,GAAf,UAAgB,OAAO,EAAE,KAAK,EAAE,OAAO;QACnC,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAC3B,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YAC7B,OAAO,CAAC,WAAW,CAAC,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAGM,iBAAY,GAAnB,UAAoB,GAAG;QACnB,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAGM,wBAAmB,GAA1B,UAA2B,MAAM,EAAE,WAAgB;QAC/C,WAAW,GAAG,WAAW,IAAI,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE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;YACN,CAAC,EAAE,GAAG;SACT;KACJ,CAAC;IA2eN,WAAC;AAAD,CAAC,AAxxBD,IAwxBC;AAxxBY,YAAI,OAwxBhB,CAAA"} \ No newline at end of file diff --git a/src/exif.ts b/src/exif.ts index 456ef52c..8489116d 100644 --- a/src/exif.ts +++ b/src/exif.ts @@ -1,21 +1,41 @@ +export class Fraction extends Number { + numerator: number; + denominator: number; +} + + +export interface IImageExtended extends HTMLImageElement { + exifdata: any; + iptcdata: any; +} + +// Console debug wrapper that makes code looks a little bit cleaner +export class Debug { + public static log(...args: any[]) { + if (Exif.debug) { + console.log(args); + } + } +} + export class Exif { - static debug:boolean = false; - - static IptcFieldMap:Object = { - 0x78: 'caption', - 0x6E: 'credit', - 0x19: 'keywords', - 0x37: 'dateCreated', - 0x50: 'byline', - 0x55: 'bylineTitle', - 0x7A: 'captionWriter', - 0x69: 'headline', - 0x74: 'copyright', - 0x0F: 'category' + public static debug: boolean = false; + + public static IptcFieldMap: any = { + 0x78: "caption", + 0x6E: "credit", + 0x19: "keywords", + 0x37: "dateCreated", + 0x50: "byline", + 0x55: "bylineTitle", + 0x7A: "captionWriter", + 0x69: "headline", + 0x74: "copyright", + 0x0F: "category" }; - static Tags:Object = { + public static Tags: any = { // version tags 0x9000: "ExifVersion", // EXIF version @@ -87,12 +107,10 @@ export class Exif { 0xA40C: "SubjectDistanceRange", // Distance to subject // other tags - 0xA005: "InteroperabilityIFDPointer", - 0xA420: "ImageUniqueID" // Identifier assigned uniquely to each image + 0xA005: "InteroperabilityIFDPointer", 0xA420: "ImageUniqueID" // Identifier assigned uniquely to each image }; - - static TiffTags:Object = { + public static TiffTags: any = { 0x0100: "ImageWidth", 0x0101: "ImageHeight", 0x8769: "ExifIFDPointer", @@ -128,7 +146,7 @@ export class Exif { 0x8298: "Copyright" }; - static GPSTags:Object = { + public static GPSTags: any = { 0x0000: "GPSVersionID", 0x0001: "GPSLatitudeRef", 0x0002: "GPSLatitude", @@ -162,8 +180,7 @@ export class Exif { 0x001E: "GPSDifferential" }; - - static StringValues:Object = { + public static StringValues: any = { ExposureProgram: { 0: "Not defined", 1: "Manual", @@ -174,8 +191,7 @@ export class Exif { 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" - }, - MeteringMode: { + }, MeteringMode: { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", @@ -184,8 +200,7 @@ export class Exif { 5: "Pattern", 6: "Partial", 255: "Other" - }, - LightSource: { + }, LightSource: { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", @@ -207,8 +222,7 @@ export class Exif { 23: "D50", 24: "ISO studio tungsten", 255: "Other" - }, - Flash: { + }, Flash: { 0x0000: "Flash did not fire", 0x0001: "Flash fired", 0x0005: "Strobe return light not detected", @@ -231,8 +245,7 @@ export class Exif { 0x0059: "Flash fired, auto mode, red-eye reduction mode", 0x005D: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 0x005F: "Flash fired, auto mode, return light detected, red-eye reduction mode" - }, - SensingMethod: { + }, SensingMethod: { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", @@ -240,221 +253,178 @@ export class Exif { 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" - }, - SceneCaptureType: { - 0: "Standard", - 1: "Landscape", - 2: "Portrait", - 3: "Night scene" - }, - SceneType: { + }, SceneCaptureType: { + 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night scene" + }, SceneType: { 1: "Directly photographed" - }, - CustomRendered: { - 0: "Normal process", - 1: "Custom process" - }, - WhiteBalance: { - 0: "Auto white balance", - 1: "Manual white balance" - }, - GainControl: { - 0: "None", - 1: "Low gain up", - 2: "High gain up", - 3: "Low gain down", - 4: "High gain down" - }, - Contrast: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - Saturation: { - 0: "Normal", - 1: "Low saturation", - 2: "High saturation" - }, - Sharpness: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - SubjectDistanceRange: { - 0: "Unknown", - 1: "Macro", - 2: "Close view", - 3: "Distant view" - }, - FileSource: { + }, CustomRendered: { + 0: "Normal process", 1: "Custom process" + }, WhiteBalance: { + 0: "Auto white balance", 1: "Manual white balance" + }, GainControl: { + 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" + }, Contrast: { + 0: "Normal", 1: "Soft", 2: "Hard" + }, Saturation: { + 0: "Normal", 1: "Low saturation", 2: "High saturation" + }, Sharpness: { + 0: "Normal", 1: "Soft", 2: "Hard" + }, SubjectDistanceRange: { + 0: "Unknown", 1: "Macro", 2: "Close view", 3: "Distant view" + }, FileSource: { 3: "DSC" }, Components: { - 0: "", - 1: "Y", - 2: "Cb", - 3: "Cr", - 4: "R", - 5: "G", - 6: "B" + 0: "", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" } }; - - static addEvent(element, event, handler) { + public static addEvent(element: EventTarget | any, event: string, handler: EventListener) { if (element.addEventListener) { element.addEventListener(event, handler, false); - } else if (element.attachEvent) { - element.attachEvent("on" + event, handler); + } else { + // Hello, IE! + if (element.attachEvent) { + element.attachEvent("on" + event, handler); + } } } - - static imageHasData(img) { + public static imageHasData(img: IImageExtended) { return !!(img.exifdata); } - - static base64ToArrayBuffer(base64, contentType?:any) { - contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg' - base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, ''); - var binary = atob(base64); - var len = binary.length; - var buffer = new ArrayBuffer(len); - var view = new Uint8Array(buffer); - for (var i = 0; i < len; i++) { + public static base64ToArrayBuffer(base64: string, contentType?: string): ArrayBuffer { + // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg' + contentType = contentType || base64.match(/^data:([^;]+);base64,/mi)[1] || ""; + base64 = base64.replace(/^data:([^;]+);base64,/gmi, ""); + let binary: string = atob(base64); + let len: number = binary.length; + let buffer: ArrayBuffer = new ArrayBuffer(len); + let view: Uint8Array = new Uint8Array(buffer); + for (let i = 0; i < len; i++) { view[i] = binary.charCodeAt(i); } return buffer; } - - static objectURLToBlob(url, callback) { - var http = new XMLHttpRequest(); + public static objectURLToBlob(url: string, callback: Function) { + let http: XMLHttpRequest = new XMLHttpRequest(); http.open("GET", url, true); http.responseType = "blob"; - http.onload = function (e) { - if (this.status == 200 || this.status === 0) { - callback(this.response); + http.onload = function () { + if (this.status === 200 || this.status === 0) { + callback(http.response); } }; http.send(); } - - static getImageData(img, callback) { - function handleBinaryFile(binFile) { - var data = Exif.findEXIFinJPEG(binFile); - var iptcdata = Exif.findIPTCinJPEG(binFile); - img.exifdata = data || {}; - img.iptcdata = iptcdata || {}; + public static getImageData(img: IImageExtended | Blob | File, callback: Function) { + function handleBinaryFile(binFile: ArrayBuffer) { + let data = Exif.findEXIFinJPEG(binFile); + let iptcdata = Exif.findIPTCinJPEG(binFile); + (img as IImageExtended).exifdata = data || {}; + (img as IImageExtended).iptcdata = iptcdata || {}; if (callback) { callback.call(img); } } - if (img.src) { - if (/^data\:/i.test(img.src)) { // Data URI - var arrayBuffer = Exif.base64ToArrayBuffer(img.src); + if ("src" in img && (img as IImageExtended).src) { + if (/^data:/i.test((img as IImageExtended).src)) { // Data URI + let arrayBuffer = Exif.base64ToArrayBuffer((img as IImageExtended).src); handleBinaryFile(arrayBuffer); - - } else if (/^blob\:/i.test(img.src)) { // Object URL - var fileReader = new FileReader(); - fileReader.onload = function (e:any) { - handleBinaryFile(e.target.result); - }; - Exif.objectURLToBlob(img.src, function (blob) { - fileReader.readAsArrayBuffer(blob); - }); } else { - var http = new XMLHttpRequest(); - http.onload = function () { - if (this.status == 200 || this.status === 0) { - handleBinaryFile(http.response); - } else { - throw "Could not load image"; - } - http = null; + if (/^blob:/i.test((img as IImageExtended).src)) { // Object URL + let fileReader = new FileReader(); + fileReader.onload = (e: any) => { + handleBinaryFile(e.target.result); + }; + Exif.objectURLToBlob((img as IImageExtended).src, (blob: Blob) => { + fileReader.readAsArrayBuffer(blob); + }); + } else { + let http = new XMLHttpRequest(); + http.onload = function () { + if (this.status === 200 || this.status === 0) { + handleBinaryFile(http.response); + } else { + throw "Could not load image"; + } + http = null; + }; + http.open("GET", (img as IImageExtended).src, true); + http.responseType = "arraybuffer"; + http.send(null); + } + } + } else { + if (FileReader && (img instanceof Blob || img instanceof File)) { + let fileReader = new FileReader(); + fileReader.onload = function (e: any) { + Debug.log("Got file of length " + e.target.result.byteLength); + handleBinaryFile(e.target.result); }; - http.open("GET", img.src, true); - http.responseType = "arraybuffer"; - http.send(null); + + fileReader.readAsArrayBuffer(img); } - } else if (FileReader && (img instanceof Blob || img instanceof File)) { - var fileReader = new FileReader(); - fileReader.onload = function (e:any) { - if (Exif.debug) console.log("Got file of length " + e.target.result.byteLength); - handleBinaryFile(e.target.result); - }; - - fileReader.readAsArrayBuffer(img); } } + public static findEXIFinJPEG(file: ArrayBuffer) { + let dataView = new DataView(file); - static findEXIFinJPEG(file) { - var dataView = new DataView(file); - - if (Exif.debug) console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (Exif.debug) console.log("Not a valid JPEG"); + Debug.log("Got file of length " + file.byteLength); + if ((dataView.getUint8(0) !== 0xFF) || (dataView.getUint8(1) !== 0xD8)) { + Debug.log("Not a valid JPEG"); return false; // not a valid jpeg } - var offset = 2, - length = file.byteLength, - marker; + let offset = 2; + let length: number = file.byteLength; + let marker: number; while (offset < length) { - if (dataView.getUint8(offset) != 0xFF) { - if (Exif.debug) console.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8(offset)); + if (dataView.getUint8(offset) !== 0xFF) { + Debug.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8(offset)); return false; // not a valid marker, something is wrong } marker = dataView.getUint8(offset + 1); - if (Exif.debug) console.log(marker); + Debug.log(marker); // we could implement handling for other markers here, // but we're only looking for 0xFFE1 for EXIF data - - if (marker == 225) { - if (Exif.debug) console.log("Found 0xFFE1 marker"); - - return Exif.readEXIFData(dataView, offset + 4); //, dataView.getUint16(offset + 2) - 2); - + if (marker === 225) { + Debug.log("Found 0xFFE1 marker"); + return Exif.readEXIFData(dataView, offset + 4); // , dataView.getUint16(offset + 2) - 2); // offset += 2 + file.getShortAt(offset+2, true); } else { offset += 2 + dataView.getUint16(offset + 2); } - } - } + public static findIPTCinJPEG(file: ArrayBuffer) { + let dataView = new DataView(file); - static findIPTCinJPEG(file) { - var dataView = new DataView(file); - - if (Exif.debug) console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (Exif.debug) console.log("Not a valid JPEG"); + Debug.log("Got file of length " + file.byteLength); + if ((dataView.getUint8(0) !== 0xFF) || (dataView.getUint8(1) !== 0xD8)) { + Debug.log("Not a valid JPEG"); return false; // not a valid jpeg } - var offset = 2, - length = file.byteLength; - + let offset = 2; + let length = file.byteLength; - var isFieldSegmentStart = function (dataView, offset) { + let isFieldSegmentStart = function (_dataView: DataView, _offset: number) { return ( - dataView.getUint8(offset) === 0x38 && - dataView.getUint8(offset + 1) === 0x42 && - dataView.getUint8(offset + 2) === 0x49 && - dataView.getUint8(offset + 3) === 0x4D && - dataView.getUint8(offset + 4) === 0x04 && - dataView.getUint8(offset + 5) === 0x04 + _dataView.getUint8(_offset) === 0x38 && _dataView.getUint8(_offset + 1) === 0x42 && _dataView.getUint8( + _offset + 2) === 0x49 && _dataView.getUint8(_offset + 3) === 0x4D && _dataView.getUint8( + _offset + 4) === 0x04 && _dataView.getUint8(_offset + 5) === 0x04 ); }; @@ -463,22 +433,22 @@ export class Exif { if (isFieldSegmentStart(dataView, offset)) { // Get the length of the name header (which is padded to an even number of bytes) - var nameHeaderLength = dataView.getUint8(offset + 7); - if (nameHeaderLength % 2 !== 0) nameHeaderLength += 1; + let nameHeaderLength = dataView.getUint8(offset + 7); + if (nameHeaderLength % 2 !== 0) { + nameHeaderLength += 1; + } // Check for pre photoshop 6 format if (nameHeaderLength === 0) { // Always 4 nameHeaderLength = 4; } - var startOffset = offset + 8 + nameHeaderLength; - var sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength); + let startOffset = offset + 8 + nameHeaderLength; + let sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength); return Exif.readIPTCData(file, startOffset, sectionLength); - } - // Not the marker, continue searching offset++; @@ -486,12 +456,11 @@ export class Exif { } - - static readIPTCData(file, startOffset, sectionLength) { - var dataView = new DataView(file); - var data = {}; - var fieldValue, fieldName, dataSize, segmentType, segmentSize; - var segmentStartPos = startOffset; + public static readIPTCData(file: ArrayBuffer, startOffset: number, sectionLength: number) { + let dataView = new DataView(file); + let data: any = {}; + let fieldValue: any, fieldName: string, dataSize: number, segmentType: any, segmentSize: number; + let segmentStartPos = startOffset; while (segmentStartPos < startOffset + sectionLength) { if (dataView.getUint8(segmentStartPos) === 0x1C && dataView.getUint8(segmentStartPos + 1) === 0x02) { segmentType = dataView.getUint8(segmentStartPos + 2); @@ -505,51 +474,51 @@ export class Exif { // Value already stored with this name, create multivalue field if (data[fieldName] instanceof Array) { data[fieldName].push(fieldValue); - } - else { + } else { data[fieldName] = [data[fieldName], fieldValue]; } - } - else { + } else { data[fieldName] = fieldValue; } } - } segmentStartPos++; } return data; } + public static readTags(file: DataView, tiffStart: number, dirStart: number, strings: string[], + bigEnd: boolean): Object { + let entries: number = file.getUint16(dirStart, !bigEnd); + let tags: any = {}; + let entryOffset: number; + let tag: string; - static readTags(file, tiffStart, dirStart, strings, bigEnd) { - var entries = file.getUint16(dirStart, !bigEnd), - tags = {}, - entryOffset, tag, - i; - - for (i = 0; i < entries; i++) { + for (let i = 0; i < entries; i++) { entryOffset = dirStart + i * 12 + 2; tag = strings[file.getUint16(entryOffset, !bigEnd)]; - if (!tag && Exif.debug) console.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd)); + if (!tag) { + Debug.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd)); + } tags[tag] = Exif.readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd); } return tags; } - - static readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) { - var type = file.getUint16(entryOffset + 2, !bigEnd), - numValues = file.getUint32(entryOffset + 4, !bigEnd), - valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart, - offset, - vals, val, n, - numerator, denominator; + public static readTagValue(file: any, entryOffset: number, tiffStart: number, dirStart: number, + bigEnd: boolean): any { + let type: number = file.getUint16(entryOffset + 2, !bigEnd); + let numValues = file.getUint32(entryOffset + 4, !bigEnd); + let valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart; + let offset: number; + let vals: any[], val: any, n: number; + let numerator: any; + let denominator: any; switch (type) { case 1: // byte, 8-bit unsigned int case 7: // undefined, 8-bit byte, value depending on field - if (numValues == 1) { + if (numValues === 1) { return file.getUint8(entryOffset + 8, !bigEnd); } else { offset = numValues > 4 ? valueOffset : (entryOffset + 8); @@ -565,7 +534,7 @@ export class Exif { return Exif.getStringFromDB(file, offset, numValues - 1); case 3: // short, 16 bit int - if (numValues == 1) { + if (numValues === 1) { return file.getUint16(entryOffset + 8, !bigEnd); } else { offset = numValues > 2 ? valueOffset : (entryOffset + 8); @@ -577,7 +546,7 @@ export class Exif { } case 4: // long, 32 bit int - if (numValues == 1) { + if (numValues === 1) { return file.getUint32(entryOffset + 8, !bigEnd); } else { vals = []; @@ -588,10 +557,10 @@ export class Exif { } case 5: // rational = two long values, first is numerator, second is denominator - if (numValues == 1) { + if (numValues === 1) { numerator = file.getUint32(valueOffset, !bigEnd); denominator = file.getUint32(valueOffset + 4, !bigEnd); - val = new Number(numerator / denominator); + val = new Fraction(numerator / denominator); val.numerator = numerator; val.denominator = denominator; return val; @@ -600,7 +569,7 @@ export class Exif { for (n = 0; n < numValues; n++) { numerator = file.getUint32(valueOffset + 8 * n, !bigEnd); denominator = file.getUint32(valueOffset + 4 + 8 * n, !bigEnd); - vals[n] = new Number(numerator / denominator); + vals[n] = new Fraction(numerator / denominator); vals[n].numerator = numerator; vals[n].denominator = denominator; } @@ -608,7 +577,7 @@ export class Exif { } case 9: // slong, 32 bit signed int - if (numValues == 1) { + if (numValues === 1) { return file.getInt32(entryOffset + 8, !bigEnd); } else { vals = []; @@ -619,58 +588,59 @@ export class Exif { } case 10: // signed rational, two slongs, first is numerator, second is denominator - if (numValues == 1) { + if (numValues === 1) { return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset + 4, !bigEnd); } else { vals = []; for (n = 0; n < numValues; n++) { - vals[n] = file.getInt32(valueOffset + 8 * n, !bigEnd) / file.getInt32(valueOffset + 4 + 8 * n, !bigEnd); + vals[n] = file.getInt32(valueOffset + 8 * n, !bigEnd) / file.getInt32(valueOffset + 4 + 8 * n, + !bigEnd); } return vals; } + default: + break; } } - - static getStringFromDB(buffer, start, length) { - var outstr = ""; - for (var n = start; n < start + length; n++) { + public static getStringFromDB(buffer: DataView, start: number, length: number): string { + let outstr = ""; + for (let n = start; n < start + length; n++) { outstr += String.fromCharCode(buffer.getUint8(n)); } return outstr; } + public static readEXIFData(file: DataView, start: number): any { + if (Exif.getStringFromDB(file, start, 4) !== "Exif") { + Debug.log("Not valid EXIF data! " + Exif.getStringFromDB(file, start, 4)); - static readEXIFData(file, start) { - if (Exif.getStringFromDB(file, start, 4) != "Exif") { - if (Exif.debug) console.log("Not valid EXIF data! " + Exif.getStringFromDB(file, start, 4)); return false; } - var bigEnd, - tags, tag, - exifData, gpsData, - tiffOffset = start + 6; + let bigEnd: boolean, tags: any, tag: string, exifData: any, gpsData: any, tiffOffset: number = start + 6; // test for TIFF validity and endianness - if (file.getUint16(tiffOffset) == 0x4949) { + if (file.getUint16(tiffOffset) === 0x4949) { bigEnd = false; - } else if (file.getUint16(tiffOffset) == 0x4D4D) { - bigEnd = true; } else { - if (Exif.debug) console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"); - return false; + if (file.getUint16(tiffOffset) === 0x4D4D) { + bigEnd = true; + } else { + Debug.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"); + return false; + } } - if (file.getUint16(tiffOffset + 2, !bigEnd) != 0x002A) { - if (Exif.debug) console.log("Not valid TIFF data! (no 0x002A)"); + if (file.getUint16(tiffOffset + 2, !bigEnd) !== 0x002A) { + Debug.log("Not valid TIFF data! (no 0x002A)"); return false; } - var firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd); + let firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd); if (firstIFDOffset < 0x00000008) { - if (Exif.debug) console.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset + 4, !bigEnd)); + Debug.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset + 4, !bigEnd)); return false; } @@ -679,66 +649,69 @@ export class Exif { if (tags.ExifIFDPointer) { exifData = Exif.readTags(file, tiffOffset, tiffOffset + tags.ExifIFDPointer, Exif.Tags, bigEnd); for (tag in exifData) { - switch (tag) { - case "LightSource" : - case "Flash" : - case "MeteringMode" : - case "ExposureProgram" : - case "SensingMethod" : - case "SceneCaptureType" : - case "SceneType" : - case "CustomRendered" : - case "WhiteBalance" : - case "GainControl" : - case "Contrast" : - case "Saturation" : - case "Sharpness" : - case "SubjectDistanceRange" : - case "FileSource" : - exifData[tag] = Exif.StringValues[tag][exifData[tag]]; - break; - - case "ExifVersion" : - case "FlashpixVersion" : - exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], exifData[tag][3]); - break; - - case "ComponentsConfiguration" : - exifData[tag] = - Exif.StringValues['Components'][exifData[tag][0]] + - Exif.StringValues['Components'][exifData[tag][1]] + - Exif.StringValues['Components'][exifData[tag][2]] + - Exif.StringValues['Components'][exifData[tag][3]]; - break; + if ({}.hasOwnProperty.call(exifData, tag)) { + switch (tag) { + case "LightSource" : + case "Flash" : + case "MeteringMode" : + case "ExposureProgram" : + case "SensingMethod" : + case "SceneCaptureType" : + case "SceneType" : + case "CustomRendered" : + case "WhiteBalance" : + case "GainControl" : + case "Contrast" : + case "Saturation" : + case "Sharpness" : + case "SubjectDistanceRange" : + case "FileSource" : + exifData[tag] = Exif.StringValues[tag][exifData[tag]]; + break; + case "ExifVersion" : + case "FlashpixVersion" : + exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], + exifData[tag][3]); + break; + case "ComponentsConfiguration" : + let compopents = "Components"; + exifData[tag] = Exif.StringValues[compopents][exifData[tag][0]] + Exif.StringValues[compopents][exifData[tag][1]] + Exif.StringValues[compopents][exifData[tag][2]] + Exif.StringValues[compopents][exifData[tag][3]]; + break; + default: + break; + } + tags[tag] = exifData[tag]; } - tags[tag] = exifData[tag]; } } if (tags.GPSInfoIFDPointer) { gpsData = Exif.readTags(file, tiffOffset, tiffOffset + tags.GPSInfoIFDPointer, Exif.GPSTags, bigEnd); for (tag in gpsData) { - switch (tag) { - case "GPSVersionID" : - gpsData[tag] = gpsData[tag][0] + - "." + gpsData[tag][1] + - "." + gpsData[tag][2] + - "." + gpsData[tag][3]; - break; + if ({}.hasOwnProperty.call(gpsData, tag)) { + switch (tag) { + case "GPSVersionID" : + gpsData[tag] = gpsData[tag][0] + "." + gpsData[tag][1] + "." + gpsData[tag][2] + "." + gpsData[tag][3]; + break; + default: + break; + } + tags[tag] = gpsData[tag]; } - tags[tag] = gpsData[tag]; } } return tags; } - static getData(img:any, callback:Function) { + public static getData(img: IImageExtended | HTMLImageElement, callback: Function) { - if ((img instanceof Image || img instanceof HTMLImageElement) && !img.complete) return false; + if ((img instanceof Image || img instanceof HTMLImageElement) && !img.complete) { + return false; + } - if (!Exif.imageHasData(img)) { - Exif.getImageData(img, callback); + if (!Exif.imageHasData((img as IImageExtended))) { + Exif.getImageData((img as IImageExtended), callback); } else { if (callback) { callback.call(img); @@ -747,16 +720,18 @@ export class Exif { return true; } - static getTag(img, tag) { - if (!Exif.imageHasData(img)) return; + public static getTag(img: any, tag: string) { + if (!Exif.imageHasData(img)) { + return; + } return img.exifdata[tag]; }; - static getAllTags(img) { - if (!Exif.imageHasData(img)) return {}; - var a, - data = img.exifdata, - tags = {}; + public static getAllTags(img: any) { + if (!Exif.imageHasData(img)) { + return {}; + } + let a: string, data: any = img.exifdata, tags: any = {}; for (a in data) { if (data.hasOwnProperty(a)) { tags[a] = data[a]; @@ -765,29 +740,28 @@ export class Exif { return tags; }; - static pretty(img) { - if (!Exif.imageHasData(img)) return ""; - var a, - data = img.exifdata, - strPretty = ""; + public static pretty(img: IImageExtended) { + if (!Exif.imageHasData(img)) { + return ""; + } + let a: any, data: any = img.exifdata, strPretty = ""; for (a in data) { if (data.hasOwnProperty(a)) { - if (typeof data[a] == "object") { + if (typeof data[a] === "object") { if (data[a] instanceof Number) { - strPretty += a + " : " + data[a] + " [" + data[a].numerator + "/" + data[a].denominator + "]\r\n"; + strPretty += `${a} : ${data[a]} [${data[a].numerator}/${data[a].denominator}]\r\n`; } else { - strPretty += a + " : [" + data[a].length + " values]\r\n"; + strPretty += `${a} : [${data[a].length} values]\r\n`; } } else { - strPretty += a + " : " + data[a] + "\r\n"; + strPretty += `${a} : ${data[a]}\r\n`; } } } return strPretty; } - readFromBinaryFile(file) { + public static readFromBinaryFile(file: ArrayBuffer) { return Exif.findEXIFinJPEG(file); } - -} \ No newline at end of file +} diff --git a/src/imageCropper.d.ts b/src/imageCropper.d.ts deleted file mode 100644 index f1046eb9..00000000 --- a/src/imageCropper.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Point } from './model/point'; -import { Bounds } from './model/bounds'; -import { ImageCropperModel } from "./model/imageCropperModel"; -import { CropperSettings } from "./cropperSettings"; -export declare class ImageCropper extends ImageCropperModel { - private crop; - private cropperSettings; - private previousDistance; - constructor(cropperSettings: CropperSettings); - static sign(x: any): any; - static getMousePos(canvas: any, evt: any): Point; - static getTouchPos(canvas: any, touch: any): Point; - static detectVerticalSquash(img: any): number; - prepare(canvas: HTMLCanvasElement): void; - resizeCanvas(width: any, height: any): void; - draw(ctx: any): void; - dragCrop(x: any, y: any, marker: any): void; - enforceMinSize(x: any, y: any, marker: any): Point; - dragCorner(x: any, y: any, marker: any): void; - getSide(a: any, b: any, c: any): any; - handleRelease(newCropTouch: any): void; - handleMove(newCropTouch: any): void; - updateClampBounds(): void; - getCropBounds(): Bounds; - clampPosition(x: any, y: any): Point; - isImageSet(): boolean; - setImage(img: any): void; - getCroppedImage(fillWidth?: number, fillHeight?: number): HTMLImageElement; - getBounds(): Bounds; - setBounds(bounds: any): void; - onTouchMove(event: TouchEvent): void; - onMouseMove(e: any): void; - move(cropTouch: any): void; - getDragTouchForID(id: any): any; - drawCursors(cropTouch: any): void; - drawCornerCursor(marker: any, x: any, y: any): boolean; - onTouchStart(event: TouchEvent): void; - onTouchEnd(event: TouchEvent): void; - drawImageIOSFix(ctx: any, img: any, sx: any, sy: any, sw: any, sh: any, dx: any, dy: any, dw: any, dh: any): void; - onMouseDown(): void; - onMouseUp(): void; -} diff --git a/src/imageCropper.js b/src/imageCropper.js deleted file mode 100644 index eab90ebc..00000000 --- a/src/imageCropper.js +++ /dev/null @@ -1,877 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var pointPool_1 = require('./model/pointPool'); -var bounds_1 = require('./model/bounds'); -var cornerMarker_1 = require('./model/cornerMarker'); -var dragMarker_1 = require('./model/dragMarker'); -var cropTouch_1 = require('./model/cropTouch'); -var imageCropperModel_1 = require("./model/imageCropperModel"); -var imageCropperDataShare_1 = require("./imageCropperDataShare"); -var ImageCropper = (function (_super) { - __extends(ImageCropper, _super); - function ImageCropper(cropperSettings) { - _super.call(this); - var x = 0; - var y = 0; - var width = cropperSettings.width; - var height = cropperSettings.height; - var keepAspect = cropperSettings.keepAspect; - var touchRadius = cropperSettings.touchRadius; - var minWidth = cropperSettings.minWidth; - var minHeight = cropperSettings.minHeight; - var croppedWidth = cropperSettings.croppedWidth; - var croppedHeight = cropperSettings.croppedHeight; - this.cropperSettings = cropperSettings; - this.crop = this; - this.x = x; - this.y = y; - if (width === void 0) { - this.width = 100; - } - if (height === void 0) { - this.height = 50; - } - if (keepAspect === void 0) { - this.keepAspect = true; - } - if (touchRadius === void 0) { - this.touchRadius = 20; - } - this.minWidth = minWidth; - this.minHeight = minHeight; - this.keepAspect = false; - this.aspectRatio = 0; - this.currentDragTouches = []; - this.isMouseDown = false; - this.ratioW = 1; - this.ratioH = 1; - this.fileType = 'png'; - this.imageSet = false; - this.pointPool = new pointPool_1.PointPool(200); - this.tl = new cornerMarker_1.CornerMarker(x, y, touchRadius, this.cropperSettings); - this.tr = new cornerMarker_1.CornerMarker(x + width, y, touchRadius, this.cropperSettings); - this.bl = new cornerMarker_1.CornerMarker(x, y + height, touchRadius, this.cropperSettings); - this.br = new cornerMarker_1.CornerMarker(x + width, y + height, touchRadius, this.cropperSettings); - this.tl.addHorizontalNeighbour(this.tr); - this.tl.addVerticalNeighbour(this.bl); - this.tr.addHorizontalNeighbour(this.tl); - this.tr.addVerticalNeighbour(this.br); - this.bl.addHorizontalNeighbour(this.br); - this.bl.addVerticalNeighbour(this.tl); - this.br.addHorizontalNeighbour(this.bl); - this.br.addVerticalNeighbour(this.tr); - this.markers = [this.tl, this.tr, this.bl, this.br]; - this.center = new dragMarker_1.DragMarker(x + (width / 2), y + (height / 2), touchRadius, this.cropperSettings); - this.keepAspect = keepAspect; - this.aspectRatio = height / width; - this.croppedImage = new Image(); - this.currentlyInteracting = false; - this.cropWidth = croppedWidth; - this.cropHeight = croppedHeight; - } - ImageCropper.sign = function (x) { - if (+x === x) { - return (x === 0) ? x : (x > 0) ? 1 : -1; - } - return NaN; - }; - ImageCropper.getMousePos = function (canvas, evt) { - var rect = canvas.getBoundingClientRect(); - return pointPool_1.PointPool.instance.borrow(evt.clientX - rect.left, evt.clientY - rect.top); - }; - ImageCropper.getTouchPos = function (canvas, touch) { - var rect = canvas.getBoundingClientRect(); - return pointPool_1.PointPool.instance.borrow(touch.clientX - rect.left, touch.clientY - rect.top); - }; - ImageCropper.detectVerticalSquash = function (img) { - var ih = img.height; - var canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = ih; - var ctx = canvas.getContext('2d'); - ctx.drawImage(img, 0, 0); - var data = ctx.getImageData(0, 0, 1, ih).data; - var sy = 0; - var ey = ih; - var py = ih; - while (py > sy) { - var alpha = data[(py - 1) * 4 + 3]; - if (alpha === 0) { - ey = py; - } - else { - sy = py; - } - py = (ey + sy) >> 1; - } - var ratio = (py / ih); - return (ratio === 0) ? 1 : ratio; - }; - ImageCropper.prototype.prepare = function (canvas) { - this.buffer = document.createElement('canvas'); - this.cropCanvas = document.createElement('canvas'); - this.cropCanvas.width = this.cropWidth; - this.cropCanvas.height = this.cropHeight; - this.buffer.width = canvas.width; - this.buffer.height = canvas.height; - this.canvas = canvas; - this.ctx = this.canvas.getContext("2d"); - this.draw(this.ctx); - }; - ImageCropper.prototype.resizeCanvas = function (width, height) { - this.canvas.width = width; - this.canvas.height = height; - this.buffer.width = width; - this.buffer.height = height; - this.draw(this.ctx); - }; - ImageCropper.prototype.draw = function (ctx) { - var bounds = this.getBounds(); - if (this.srcImage) { - ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight); - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvasHeight / this.canvasWidth; - var w = this.canvasWidth; - var h = this.canvasHeight; - if (canvasAspect > sourceAspect) { - w = this.canvasWidth; - h = this.canvasWidth * sourceAspect; - } - else { - h = this.canvasHeight; - w = this.canvasHeight / sourceAspect; - } - this.ratioW = w / this.srcImage.width; - this.ratioH = h / this.srcImage.height; - if (canvasAspect < sourceAspect) { - this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, this.buffer.width / 2 - w / 2, 0, w, h); - } - else { - this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, 0, this.buffer.height / 2 - h / 2, w, h); - } - this.buffer.getContext('2d').drawImage(this.canvas, 0, 0, this.canvasWidth, this.canvasHeight); - ctx.lineWidth = this.cropperSettings.cropperDrawSettings.strokeWidth; - ctx.strokeStyle = this.cropperSettings.cropperDrawSettings.strokeColor; - if (!this.cropperSettings.rounded) { - ctx.fillStyle = "rgba(0, 0, 0, 0.6)"; - ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight); - ctx.drawImage(this.buffer, bounds.left, bounds.top, Math.max(bounds.getWidth(), 1), Math.max(bounds.getHeight(), 1), bounds.left, bounds.top, bounds.getWidth(), bounds.getHeight()); - ctx.strokeRect(bounds.left, bounds.top, bounds.getWidth(), bounds.getHeight()); - } - else { - ctx.beginPath(); - ctx.arc(bounds.left + bounds.getWidth() / 2, bounds.top + bounds.getHeight() / 2, bounds.getWidth() / 2, 0, Math.PI * 2, true); - ctx.closePath(); - ctx.stroke(); - } - var marker; - for (var i = 0; i < this.markers.length; i++) { - marker = this.markers[i]; - marker.draw(ctx); - } - this.center.draw(ctx); - } - else { - ctx.fillStyle = 'rgba(192,192,192,1)'; - ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); - } - }; - ImageCropper.prototype.dragCrop = function (x, y, marker) { - var bounds = this.getBounds(); - var left = x - (bounds.getWidth() / 2); - var right = x + (bounds.getWidth() / 2); - var top = y - (bounds.getHeight() / 2); - var bottom = y + (bounds.getHeight() / 2); - if (right >= this.maxXClamp) { - x = this.maxXClamp - bounds.getWidth() / 2; - } - if (left <= this.minXClamp) { - x = bounds.getWidth() / 2 + this.minXClamp; - } - if (top < this.minYClamp) { - y = bounds.getHeight() / 2 + this.minYClamp; - } - if (bottom >= this.maxYClamp) { - y = this.maxYClamp - bounds.getHeight() / 2; - } - this.tl.moveX(x - (bounds.getWidth() / 2)); - this.tl.moveY(y - (bounds.getHeight() / 2)); - this.tr.moveX(x + (bounds.getWidth() / 2)); - this.tr.moveY(y - (bounds.getHeight() / 2)); - this.bl.moveX(x - (bounds.getWidth() / 2)); - this.bl.moveY(y + (bounds.getHeight() / 2)); - this.br.moveX(x + (bounds.getWidth() / 2)); - this.br.moveY(y + (bounds.getHeight() / 2)); - marker.setPosition(x, y); - }; - ImageCropper.prototype.enforceMinSize = function (x, y, marker) { - var xLength = x - marker.getHorizontalNeighbour().getPosition().x; - var yLength = y - marker.getVerticalNeighbour().getPosition().y; - var xOver = this.minWidth - Math.abs(xLength); - var yOver = this.minHeight - Math.abs(yLength); - if (xLength == 0 || yLength == 0) { - x = marker.getPosition().x; - y = marker.getPosition().y; - return pointPool_1.PointPool.instance.borrow(x, y); - } - if (this.keepAspect) { - if (xOver > 0 && (yOver / this.aspectRatio) > 0) { - if (xOver > (yOver / this.aspectRatio)) { - if (xLength < 0) { - x -= xOver; - if (yLength < 0) { - y -= xOver * this.aspectRatio; - } - else { - y += xOver * this.aspectRatio; - } - } - else { - x += xOver; - if (yLength < 0) { - y -= xOver * this.aspectRatio; - } - else { - y += xOver * this.aspectRatio; - } - } - } - else { - if (yLength < 0) { - y -= yOver; - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; - } - } - else { - y += yOver; - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; - } - } - } - } - else { - if (xOver > 0) { - if (xLength < 0) { - x -= xOver; - if (yLength < 0) { - y -= xOver * this.aspectRatio; - } - else { - y += xOver * this.aspectRatio; - } - } - else { - x += xOver; - if (yLength < 0) { - y -= xOver * this.aspectRatio; - } - else { - y += xOver * this.aspectRatio; - } - } - } - else if (yOver > 0) { - if (yLength < 0) { - y -= yOver; - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; - } - } - else { - y += yOver; - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; - } - } - } - } - } - else { - if (xOver > 0) { - if (xLength < 0) { - x -= xOver; - } - else { - x += xOver; - } - } - if (yOver > 0) { - if (yLength < 0) { - y -= yOver; - } - else { - y += yOver; - } - } - } - if (x < this.minXClamp || x > this.maxXClamp || y < this.minYClamp || y > this.maxYClamp) { - x = marker.getPosition().x; - y = marker.getPosition().y; - } - return pointPool_1.PointPool.instance.borrow(x, y); - }; - ImageCropper.prototype.dragCorner = function (x, y, marker) { - var iX = 0; - var iY = 0; - var ax = 0; - var ay = 0; - var newHeight = 0; - var newWidth = 0; - var newY = 0; - var newX = 0; - var anchorMarker; - var fold = 0; - if (this.keepAspect) { - anchorMarker = marker.getHorizontalNeighbour().getVerticalNeighbour(); - ax = anchorMarker.getPosition().x; - ay = anchorMarker.getPosition().y; - if (x <= anchorMarker.getPosition().x) { - if (y <= anchorMarker.getPosition().y) { - iX = ax - (100 / this.aspectRatio); - iY = ay - (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(pointPool_1.PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), pointPool_1.PointPool.instance.borrow(x, y)); - if (fold > 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - else if (fold < 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - } - else { - iX = ax - (100 / this.aspectRatio); - iY = ay + (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(pointPool_1.PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), pointPool_1.PointPool.instance.borrow(x, y)); - if (fold > 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - else if (fold < 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - } - } - else { - if (y <= anchorMarker.getPosition().y) { - iX = ax + (100 / this.aspectRatio); - iY = ay - (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(pointPool_1.PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), pointPool_1.PointPool.instance.borrow(x, y)); - if (fold < 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - else if (fold > 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - } - else { - iX = ax + (100 / this.aspectRatio); - iY = ay + (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(pointPool_1.PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), pointPool_1.PointPool.instance.borrow(x, y)); - if (fold < 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - else if (fold > 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - } - } - } - else { - var min = this.enforceMinSize(x, y, marker); - marker.move(min.x, min.y); - pointPool_1.PointPool.instance.returnPoint(min); - } - this.center.recalculatePosition(this.getBounds()); - }; - ImageCropper.prototype.getSide = function (a, b, c) { - var n = ImageCropper.sign((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)); - pointPool_1.PointPool.instance.returnPoint(a); - pointPool_1.PointPool.instance.returnPoint(c); - return n; - }; - ImageCropper.prototype.handleRelease = function (newCropTouch) { - if (newCropTouch == null) { - return; - } - var index = 0; - for (var k = 0; k < this.currentDragTouches.length; k++) { - if (newCropTouch.id == this.currentDragTouches[k].id) { - this.currentDragTouches[k].dragHandle.setDrag(false); - newCropTouch.dragHandle = null; - index = k; - } - } - this.currentDragTouches.splice(index, 1); - this.draw(this.ctx); - }; - ImageCropper.prototype.handleMove = function (newCropTouch) { - var matched = false; - for (var k = 0; k < this.currentDragTouches.length; k++) { - if (newCropTouch.id == this.currentDragTouches[k].id && this.currentDragTouches[k].dragHandle != null) { - var dragTouch = this.currentDragTouches[k]; - var clampedPositions = this.clampPosition(newCropTouch.x - dragTouch.dragHandle.offset.x, newCropTouch.y - dragTouch.dragHandle.offset.y); - newCropTouch.x = clampedPositions.x; - newCropTouch.y = clampedPositions.y; - pointPool_1.PointPool.instance.returnPoint(clampedPositions); - if (dragTouch.dragHandle instanceof cornerMarker_1.CornerMarker) { - this.dragCorner(newCropTouch.x, newCropTouch.y, dragTouch.dragHandle); - } - else { - this.dragCrop(newCropTouch.x, newCropTouch.y, dragTouch.dragHandle); - } - this.currentlyInteracting = true; - matched = true; - imageCropperDataShare_1.ImageCropperDataShare.setPressed(this.canvas); - break; - } - } - if (!matched) { - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; - if (marker.touchInBounds(newCropTouch.x, newCropTouch.y)) { - newCropTouch.dragHandle = marker; - this.currentDragTouches.push(newCropTouch); - marker.setDrag(true); - newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.getPosition().x; - newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.getPosition().y; - this.dragCorner(newCropTouch.x - newCropTouch.dragHandle.offset.x, newCropTouch.y - newCropTouch.dragHandle.offset.y, newCropTouch.dragHandle); - break; - } - } - if (newCropTouch.dragHandle == null) { - if (this.center.touchInBounds(newCropTouch.x, newCropTouch.y)) { - newCropTouch.dragHandle = this.center; - this.currentDragTouches.push(newCropTouch); - newCropTouch.dragHandle.setDrag(true); - newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.getPosition().x; - newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.getPosition().y; - this.dragCrop(newCropTouch.x - newCropTouch.dragHandle.offset.x, newCropTouch.y - newCropTouch.dragHandle.offset.y, newCropTouch.dragHandle); - } - } - } - }; - ImageCropper.prototype.updateClampBounds = function () { - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvas.height / this.canvas.width; - var w = this.canvas.width; - var h = this.canvas.height; - if (canvasAspect > sourceAspect) { - w = this.canvas.width; - h = this.canvas.width * sourceAspect; - } - else { - h = this.canvas.height; - w = this.canvas.height / sourceAspect; - } - this.minXClamp = this.canvas.width / 2 - w / 2; - this.minYClamp = this.canvas.height / 2 - h / 2; - this.maxXClamp = this.canvas.width / 2 + w / 2; - this.maxYClamp = this.canvas.height / 2 + h / 2; - }; - ImageCropper.prototype.getCropBounds = function () { - var bounds = this.getBounds(); - bounds.top = Math.round((bounds.top + this.minYClamp) / this.ratioH); - bounds.bottom = Math.round((bounds.bottom + this.minYClamp) / this.ratioH); - bounds.left = Math.round((bounds.left - this.minXClamp) / this.ratioW); - bounds.right = Math.round((bounds.right - this.minXClamp) / this.ratioW); - return bounds; - }; - ImageCropper.prototype.clampPosition = function (x, y) { - if (x < this.minXClamp) { - x = this.minXClamp; - } - if (x > this.maxXClamp) { - x = this.maxXClamp; - } - if (y < this.minYClamp) { - y = this.minYClamp; - } - if (y > this.maxYClamp) { - y = this.maxYClamp; - } - return pointPool_1.PointPool.instance.borrow(x, y); - }; - ImageCropper.prototype.isImageSet = function () { - return this.imageSet; - }; - ImageCropper.prototype.setImage = function (img) { - if (!img) { - throw "Image is null"; - } - this.srcImage = img; - this.imageSet = true; - this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); - var bufferContext = this.buffer.getContext('2d'); - bufferContext.clearRect(0, 0, this.buffer.width, this.buffer.height); - var splitName = img.src.split('.'); - var fileType = splitName[1]; - if (fileType == 'png' || fileType == 'jpg') { - this.fileType = fileType; - } - if (this.cropperSettings.minWithRelativeToResolution) { - this.minWidth = (this.canvas.width * this.minWidth / this.srcImage.width); - this.minHeight = (this.canvas.height * this.minHeight / this.srcImage.height); - } - this.updateClampBounds(); - var sourceAspect = this.srcImage.height / this.srcImage.width; - var cropBounds = this.getBounds(); - var cropAspect = cropBounds.getHeight() / cropBounds.getWidth(); - var w = this.canvas.width; - var h = this.canvas.height; - this.canvasWidth = w; - this.canvasHeight = h; - var cX = this.canvas.width / 2; - var cY = this.canvas.height / 2; - var tlPos = pointPool_1.PointPool.instance.borrow(cX - cropBounds.getWidth() / 2, cY + cropBounds.getHeight() / 2); - var trPos = pointPool_1.PointPool.instance.borrow(cX + cropBounds.getWidth() / 2, cY + cropBounds.getHeight() / 2); - var blPos = pointPool_1.PointPool.instance.borrow(cX - cropBounds.getWidth() / 2, cY - cropBounds.getHeight() / 2); - var brPos = pointPool_1.PointPool.instance.borrow(cX + cropBounds.getWidth() / 2, cY - cropBounds.getHeight() / 2); - this.tl.setPosition(tlPos.x, tlPos.y); - this.tr.setPosition(trPos.x, trPos.y); - this.bl.setPosition(blPos.x, blPos.y); - this.br.setPosition(brPos.x, brPos.y); - pointPool_1.PointPool.instance.returnPoint(tlPos); - pointPool_1.PointPool.instance.returnPoint(trPos); - pointPool_1.PointPool.instance.returnPoint(blPos); - pointPool_1.PointPool.instance.returnPoint(brPos); - this.center.setPosition(cX, cY); - if (cropAspect > sourceAspect) { - var imageH = Math.min(w * sourceAspect, h); - var cropW = imageH / cropAspect; - tlPos = pointPool_1.PointPool.instance.borrow(cX - cropW / 2, cY + imageH / 2); - trPos = pointPool_1.PointPool.instance.borrow(cX + cropW / 2, cY + imageH / 2); - blPos = pointPool_1.PointPool.instance.borrow(cX - cropW / 2, cY - imageH / 2); - brPos = pointPool_1.PointPool.instance.borrow(cX + cropW / 2, cY - imageH / 2); - } - else { - var imageW = Math.min(h / sourceAspect, w); - var cropH = imageW * cropAspect; - tlPos = pointPool_1.PointPool.instance.borrow(cX - imageW / 2, cY + cropH / 2); - trPos = pointPool_1.PointPool.instance.borrow(cX + imageW / 2, cY + cropH / 2); - blPos = pointPool_1.PointPool.instance.borrow(cX - imageW / 2, cY - cropH / 2); - brPos = pointPool_1.PointPool.instance.borrow(cX + imageW / 2, cY - cropH / 2); - } - this.tl.setPosition(tlPos.x, tlPos.y); - this.tr.setPosition(trPos.x, trPos.y); - this.bl.setPosition(blPos.x, blPos.y); - this.br.setPosition(brPos.x, brPos.y); - pointPool_1.PointPool.instance.returnPoint(tlPos); - pointPool_1.PointPool.instance.returnPoint(trPos); - pointPool_1.PointPool.instance.returnPoint(blPos); - pointPool_1.PointPool.instance.returnPoint(brPos); - this.vertSquashRatio = ImageCropper.detectVerticalSquash(this.srcImage); - this.draw(this.ctx); - this.croppedImage = this.getCroppedImage(this.cropWidth, this.cropHeight); - }; - ImageCropper.prototype.getCroppedImage = function (fillWidth, fillHeight) { - var bounds = this.getBounds(); - if (!this.srcImage) { - throw "Source image not set."; - } - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvas.height / this.canvas.width; - var w = this.canvas.width; - var h = this.canvas.height; - if (canvasAspect > sourceAspect) { - w = this.canvas.width; - h = this.canvas.width * sourceAspect; - } - else if (canvasAspect < sourceAspect) { - h = this.canvas.height; - w = this.canvas.height / sourceAspect; - } - else { - h = this.canvas.height; - w = this.canvas.width; - } - this.ratioW = w / this.srcImage.width; - this.ratioH = h / this.srcImage.height; - var offsetH = (this.buffer.height - h) / 2 / this.ratioH; - var offsetW = (this.buffer.width - w) / 2 / this.ratioW; - this.drawImageIOSFix(this.cropCanvas.getContext('2d'), this.srcImage, Math.max(Math.round((bounds.left) / this.ratioW - offsetW), 0), Math.max(Math.round(bounds.top / this.ratioH - offsetH), 0), Math.max(Math.round(bounds.getWidth() / this.ratioW), 1), Math.max(Math.round(bounds.getHeight() / this.ratioH), 1), 0, 0, this.cropCanvas.width, this.cropCanvas.height); - this.croppedImage.width = this.cropCanvas.width; - this.croppedImage.height = this.cropCanvas.height; - this.croppedImage.src = this.cropCanvas.toDataURL("image/" + this.fileType); - return this.croppedImage; - }; - ImageCropper.prototype.getBounds = function () { - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - var maxX = -Number.MAX_VALUE; - var maxY = -Number.MAX_VALUE; - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; - if (marker.getPosition().x < minX) { - minX = marker.getPosition().x; - } - if (marker.getPosition().x > maxX) { - maxX = marker.getPosition().x; - } - if (marker.getPosition().y < minY) { - minY = marker.getPosition().y; - } - if (marker.getPosition().y > maxY) { - maxY = marker.getPosition().y; - } - } - var bounds = new bounds_1.Bounds(); - bounds.left = minX; - bounds.right = maxX; - bounds.top = minY; - bounds.bottom = maxY; - return bounds; - }; - ImageCropper.prototype.setBounds = function (bounds) { - var topLeft; - var topRight; - var bottomLeft; - var bottomRight; - var currentBounds = this.getBounds(); - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; - if (marker.getPosition().x == currentBounds.left) { - if (marker.getPosition().y == currentBounds.top) { - topLeft = marker; - } - else { - bottomLeft = marker; - } - } - else { - if (marker.getPosition().y == currentBounds.top) { - topRight = marker; - } - else { - bottomRight = marker; - } - } - } - topLeft.setPosition(bounds.left, bounds.top); - topRight.setPosition(bounds.right, bounds.top); - bottomLeft.setPosition(bounds.left, bounds.bottom); - bottomRight.setPosition(bounds.right, bounds.bottom); - this.center.recalculatePosition(bounds); - this.center.draw(this.ctx); - }; - ImageCropper.prototype.onTouchMove = function (event) { - if (this.crop.isImageSet()) { - event.preventDefault(); - if (event.touches.length === 1) { - for (var i = 0; i < event.touches.length; i++) { - var touch = event.touches[i]; - var touchPosition = ImageCropper.getTouchPos(this.canvas, touch); - var cropTouch = new cropTouch_1.CropTouch(touchPosition.x, touchPosition.y, touch.identifier); - pointPool_1.PointPool.instance.returnPoint(touchPosition); - this.move(cropTouch); - } - } - else if (event.touches.length === 2) { - var distance = ((event.touches[0].clientX - event.touches[1].clientX) * (event.touches[0].clientX - event.touches[1].clientX)) + - ((event.touches[0].clientY - event.touches[1].clientY) * (event.touches[0].clientY - event.touches[1].clientY)); - if (this.previousDistance && this.previousDistance !== distance) { - var increment = distance < this.previousDistance ? 1 : -1; - var bounds = this.getBounds(); - bounds.top += increment; - bounds.left += increment; - bounds.right -= increment; - bounds.bottom -= increment; - this.setBounds(bounds); - } - this.previousDistance = distance; - } - this.draw(this.ctx); - } - }; - ImageCropper.prototype.onMouseMove = function (e) { - if (this.crop.isImageSet()) { - var mousePosition = ImageCropper.getMousePos(this.canvas, e); - this.move(new cropTouch_1.CropTouch(mousePosition.x, mousePosition.y, 0)); - var dragTouch = this.getDragTouchForID(0); - if (dragTouch) { - dragTouch.x = mousePosition.x; - dragTouch.y = mousePosition.y; - } - else { - dragTouch = new cropTouch_1.CropTouch(mousePosition.x, mousePosition.y, 0); - } - pointPool_1.PointPool.instance.returnPoint(mousePosition); - this.drawCursors(dragTouch); - this.draw(this.ctx); - } - }; - ImageCropper.prototype.move = function (cropTouch) { - if (this.isMouseDown) { - this.handleMove(cropTouch); - } - }; - ImageCropper.prototype.getDragTouchForID = function (id) { - for (var i = 0; i < this.currentDragTouches.length; i++) { - if (id == this.currentDragTouches[i].id) { - return this.currentDragTouches[i]; - } - } - }; - ImageCropper.prototype.drawCursors = function (cropTouch) { - var cursorDrawn = false; - if (cropTouch != null) { - if (cropTouch.dragHandle == this.center) { - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'move'); - cursorDrawn = true; - } - if (cropTouch.dragHandle != null && cropTouch.dragHandle instanceof cornerMarker_1.CornerMarker) { - this.drawCornerCursor(cropTouch.dragHandle, cropTouch.dragHandle.getPosition().x, cropTouch.dragHandle.getPosition().y); - cursorDrawn = true; - } - } - var didDraw = false; - if (!cursorDrawn) { - for (var i = 0; i < this.markers.length; i++) { - didDraw = didDraw || this.drawCornerCursor(this.markers[i], cropTouch.x, cropTouch.y); - } - if (!didDraw) { - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'initial'); - } - } - if (!didDraw && !cursorDrawn && this.center.touchInBounds(cropTouch.x, cropTouch.y)) { - this.center.setOver(true); - imageCropperDataShare_1.ImageCropperDataShare.setOver(this.canvas); - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'move'); - } - else { - this.center.setOver(false); - } - }; - ImageCropper.prototype.drawCornerCursor = function (marker, x, y) { - if (marker.touchInBounds(x, y)) { - marker.setOver(true); - if (marker.getHorizontalNeighbour().getPosition().x > marker.getPosition().x) { - if (marker.getVerticalNeighbour().getPosition().y > marker.getPosition().y) { - imageCropperDataShare_1.ImageCropperDataShare.setOver(this.canvas); - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'nwse-resize'); - } - else { - imageCropperDataShare_1.ImageCropperDataShare.setOver(this.canvas); - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'nesw-resize'); - } - } - else { - if (marker.getVerticalNeighbour().getPosition().y > marker.getPosition().y) { - imageCropperDataShare_1.ImageCropperDataShare.setOver(this.canvas); - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'nesw-resize'); - } - else { - imageCropperDataShare_1.ImageCropperDataShare.setOver(this.canvas); - imageCropperDataShare_1.ImageCropperDataShare.setStyle(this.canvas, 'nwse-resize'); - } - } - return true; - } - marker.setOver(false); - return false; - }; - ImageCropper.prototype.onTouchStart = function (event) { - if (this.crop.isImageSet()) { - this.isMouseDown = true; - } - }; - ImageCropper.prototype.onTouchEnd = function (event) { - if (this.crop.isImageSet()) { - for (var i = 0; i < event.changedTouches.length; i++) { - var touch = event.changedTouches[i]; - var dragTouch = this.getDragTouchForID(touch.identifier); - if (dragTouch != null) { - if (dragTouch.dragHandle instanceof cornerMarker_1.CornerMarker || dragTouch.dragHandle instanceof dragMarker_1.DragMarker) { - dragTouch.dragHandle.setOver(false); - } - this.handleRelease(dragTouch); - } - } - if (this.currentDragTouches.length == 0) { - this.isMouseDown = false; - this.currentlyInteracting = false; - } - } - }; - ImageCropper.prototype.drawImageIOSFix = function (ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { - ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh); - }; - ImageCropper.prototype.onMouseDown = function () { - if (this.crop.isImageSet()) { - this.isMouseDown = true; - } - }; - ImageCropper.prototype.onMouseUp = function () { - if (this.crop.isImageSet()) { - imageCropperDataShare_1.ImageCropperDataShare.setReleased(this.canvas); - this.isMouseDown = false; - this.handleRelease(new cropTouch_1.CropTouch(0, 0, 0)); - } - }; - return ImageCropper; -}(imageCropperModel_1.ImageCropperModel)); -exports.ImageCropper = ImageCropper; -//# sourceMappingURL=imageCropper.js.map \ No newline at end of file diff --git a/src/imageCropper.js.map b/src/imageCropper.js.map deleted file mode 100644 index 4f35281d..00000000 --- a/src/imageCropper.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"imageCropper.js","sourceRoot":"","sources":["imageCropper.ts"],"names":[],"mappings":";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C,CAAC;QAC/C,CAAC;IACL,CAAC;IAGL,mBAAC;AAAD,CAAC,AAv8BD,CAAkC,qCAAiB,GAu8BlD;AAv8BY,oBAAY,eAu8BxB,CAAA"} \ No newline at end of file diff --git a/src/ImageCropper.ts b/src/imageCropper.ts similarity index 50% rename from src/ImageCropper.ts rename to src/imageCropper.ts index b6dc0678..b26c3b98 100644 --- a/src/ImageCropper.ts +++ b/src/imageCropper.ts @@ -1,34 +1,33 @@ -import {PointPool} from './model/pointPool'; -import {Point} from './model/point'; -import {Bounds} from './model/bounds'; -import {CornerMarker} from './model/cornerMarker'; -import {DragMarker} from './model/dragMarker'; -import {CropTouch} from './model/cropTouch'; +import {Bounds} from "./model/bounds"; +import {CornerMarker} from "./model/cornerMarker"; +import {CropTouch} from "./model/cropTouch"; +import {CropperSettings} from "./cropperSettings"; +import {DragMarker} from "./model/dragMarker"; import {ImageCropperModel} from "./model/imageCropperModel"; -import {CropperDrawSettings} from "./cropperDrawSettings"; import {ImageCropperDataShare} from "./imageCropperDataShare"; -import {CropperSettings} from "./cropperSettings"; +import {PointPool} from "./model/pointPool"; +import {Point} from "./model/point"; export class ImageCropper extends ImageCropperModel { - private crop:ImageCropper; - private cropperSettings:CropperSettings; - private previousDistance:number; - - constructor(cropperSettings:CropperSettings) { + private crop: ImageCropper; + private cropperSettings: CropperSettings; + private previousDistance: number; + constructor(cropperSettings: CropperSettings) { super(); - var x = 0; - var y = 0; - var width = cropperSettings.width; - var height = cropperSettings.height; - var keepAspect = cropperSettings.keepAspect; - var touchRadius = cropperSettings.touchRadius; - var minWidth = cropperSettings.minWidth; - var minHeight = cropperSettings.minHeight; - var croppedWidth = cropperSettings.croppedWidth; - var croppedHeight = cropperSettings.croppedHeight; + let x: number = 0; + let y: number = 0; + let width: number = cropperSettings.width; + let height: number = cropperSettings.height; + let keepAspect: boolean = cropperSettings.keepAspect; + let touchRadius: number = cropperSettings.touchRadius; + let minWidth: number = cropperSettings.minWidth; + let minHeight: number = cropperSettings.minHeight; + let croppedWidth: number = cropperSettings.croppedWidth; + let croppedHeight: number = cropperSettings.croppedHeight; + this.cropperSettings = cropperSettings; this.crop = this; @@ -55,11 +54,10 @@ export class ImageCropper extends ImageCropperModel { this.isMouseDown = false; this.ratioW = 1; this.ratioH = 1; - this.fileType = 'png'; + this.fileType = "png"; this.imageSet = false; this.pointPool = new PointPool(200); - this.tl = new CornerMarker(x, y, touchRadius, this.cropperSettings); this.tr = new CornerMarker(x + width, y, touchRadius, this.cropperSettings); this.bl = new CornerMarker(x, y + height, touchRadius, this.cropperSettings); @@ -74,6 +72,8 @@ export class ImageCropper extends ImageCropperModel { this.br.addHorizontalNeighbour(this.bl); this.br.addVerticalNeighbour(this.tr); this.markers = [this.tl, this.tr, this.bl, this.br]; + + this.center = new DragMarker(x + (width / 2), y + (height / 2), touchRadius, this.cropperSettings); this.keepAspect = keepAspect; this.aspectRatio = height / width; @@ -83,64 +83,72 @@ export class ImageCropper extends ImageCropperModel { this.cropHeight = croppedHeight; } - static sign(x) { + private static sign(x: number): number { if (+x === x) { return (x === 0) ? x : (x > 0) ? 1 : -1; } return NaN; } - static getMousePos(canvas, evt) { - var rect = canvas.getBoundingClientRect(); + private static getMousePos(canvas: HTMLCanvasElement, evt: MouseEvent): Point { + let rect = canvas.getBoundingClientRect(); return PointPool.instance.borrow(evt.clientX - rect.left, evt.clientY - rect.top); } - static getTouchPos(canvas, touch) { - var rect = canvas.getBoundingClientRect(); + private static getTouchPos(canvas: HTMLCanvasElement, touch: Touch): Point { + let rect = canvas.getBoundingClientRect(); return PointPool.instance.borrow(touch.clientX - rect.left, touch.clientY - rect.top); } - static detectVerticalSquash(img) { - var ih = img.height; - var canvas = document.createElement('canvas'); + private static detectVerticalSquash(img: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement) { + let ih = img.height; + let canvas = document.createElement("canvas"); canvas.width = 1; canvas.height = ih; - var ctx = canvas.getContext('2d'); + let ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0); - var data = ctx.getImageData(0, 0, 1, ih).data; + let data = ctx.getImageData(0, 0, 1, ih).data; // search image edge pixel position in case it is squashed vertically. - var sy = 0; - var ey = ih; - var py = ih; + let sy = 0; + let ey = ih; + let py = ih; while (py > sy) { - var alpha = data[(py - 1) * 4 + 3]; + let alpha = data[(py - 1) * 4 + 3]; if (alpha === 0) { ey = py; - } - else { + } else { sy = py; } py = (ey + sy) >> 1; } - var ratio = (py / ih); + let ratio = (py / ih); return (ratio === 0) ? 1 : ratio; } + public prepare(canvas: HTMLCanvasElement) { + this.buffer = document.createElement("canvas"); + this.cropCanvas = document.createElement("canvas"); + + // todo get more reliable parent width value. + let responsiveWidth: number = canvas.parentElement.clientWidth; + if (responsiveWidth > 0 && this.cropperSettings.responsive) { + this.cropCanvas.width = responsiveWidth; + this.buffer.width = responsiveWidth; + canvas.width = responsiveWidth; + } else { + this.cropCanvas.width = this.cropWidth; + this.buffer.width = canvas.width; + } - prepare(canvas:HTMLCanvasElement) { - this.buffer = document.createElement('canvas'); - this.cropCanvas = document.createElement('canvas'); - this.cropCanvas.width = this.cropWidth; this.cropCanvas.height = this.cropHeight; - this.buffer.width = canvas.width; this.buffer.height = canvas.height; this.canvas = canvas; this.ctx = this.canvas.getContext("2d"); + this.draw(this.ctx); } - - resizeCanvas(width, height):void { + public resizeCanvas(width: number, height: number): void { this.canvas.width = width; this.canvas.height = height; this.buffer.width = width; @@ -148,103 +156,101 @@ export class ImageCropper extends ImageCropperModel { this.draw(this.ctx); } - - draw(ctx):void { - var bounds = this.getBounds(); + public draw(ctx: CanvasRenderingContext2D): void { + let bounds: Bounds = this.getBounds(); if (this.srcImage) { ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight); - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvasHeight / this.canvasWidth; - var w = this.canvasWidth; - var h = this.canvasHeight; + let sourceAspect: number = this.srcImage.height / this.srcImage.width; + let canvasAspect: number = this.canvasHeight / this.canvasWidth; + let w: number = this.canvasWidth; + let h: number = this.canvasHeight; if (canvasAspect > sourceAspect) { w = this.canvasWidth; h = this.canvasWidth * sourceAspect; - } - else { + } else { h = this.canvasHeight; w = this.canvasHeight / sourceAspect; } this.ratioW = w / this.srcImage.width; this.ratioH = h / this.srcImage.height; if (canvasAspect < sourceAspect) { - this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, this.buffer.width / 2 - w / 2, 0, w, h); - } - else { - this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, 0, this.buffer.height / 2 - h / 2, w, h); + this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, + this.buffer.width / 2 - w / 2, 0, w, h); + } else { + this.drawImageIOSFix(ctx, this.srcImage, 0, 0, this.srcImage.width, this.srcImage.height, 0, + this.buffer.height / 2 - h / 2, w, h); } - this.buffer.getContext('2d').drawImage(this.canvas, 0, 0, this.canvasWidth, this.canvasHeight); + this.buffer.getContext("2d").drawImage(this.canvas, 0, 0, this.canvasWidth, this.canvasHeight); ctx.lineWidth = this.cropperSettings.cropperDrawSettings.strokeWidth; - ctx.strokeStyle = this.cropperSettings.cropperDrawSettings.strokeColor; //'rgba(255,228,0,1)'; + ctx.strokeStyle = this.cropperSettings.cropperDrawSettings.strokeColor; // "rgba(255,228,0,1)"; if (!this.cropperSettings.rounded) { ctx.fillStyle = "rgba(0, 0, 0, 0.6)"; ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight); - ctx.drawImage(this.buffer, bounds.left, bounds.top, Math.max(bounds.getWidth(), 1), Math.max(bounds.getHeight(), 1), bounds.left, bounds.top, bounds.getWidth(), bounds.getHeight()); - ctx.strokeRect(bounds.left, bounds.top, bounds.getWidth(), bounds.getHeight()); + ctx.drawImage(this.buffer, bounds.left, bounds.top, Math.max(bounds.width, 1), + Math.max(bounds.height, 1), bounds.left, bounds.top, bounds.width, bounds.height); + ctx.strokeRect(bounds.left, bounds.top, bounds.width, bounds.height); } else { ctx.beginPath(); - ctx.arc(bounds.left + bounds.getWidth() / 2, bounds.top + bounds.getHeight() / 2, bounds.getWidth() / 2, 0, Math.PI * 2, true); + ctx.arc(bounds.left + bounds.width / 2, bounds.top + bounds.height / 2, bounds.width / 2, 0, + Math.PI * 2, true); ctx.closePath(); ctx.stroke(); } - var marker; - for (var i = 0; i < this.markers.length; i++) { + let marker: CornerMarker; + + for (let i = 0; i < this.markers.length; i++) { marker = this.markers[i]; marker.draw(ctx); } this.center.draw(ctx); - } - else { - ctx.fillStyle = 'rgba(192,192,192,1)'; + } else { + ctx.fillStyle = "rgba(192,192,192,1)"; ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); } } - - dragCrop(x, y, marker) { - var bounds = this.getBounds(); - var left = x - (bounds.getWidth() / 2); - var right = x + (bounds.getWidth() / 2); - var top = y - (bounds.getHeight() / 2); - var bottom = y + (bounds.getHeight() / 2); + public dragCenter(x: number, y: number, marker: DragMarker) { + let bounds = this.getBounds(); + let left = x - (bounds.width / 2); + let right = x + (bounds.width / 2); + let top = y - (bounds.height / 2); + let bottom = y + (bounds.height / 2); if (right >= this.maxXClamp) { - x = this.maxXClamp - bounds.getWidth() / 2; + x = this.maxXClamp - bounds.width / 2; } if (left <= this.minXClamp) { - x = bounds.getWidth() / 2 + this.minXClamp; + x = bounds.width / 2 + this.minXClamp; } if (top < this.minYClamp) { - y = bounds.getHeight() / 2 + this.minYClamp; + y = bounds.height / 2 + this.minYClamp; } if (bottom >= this.maxYClamp) { - y = this.maxYClamp - bounds.getHeight() / 2; - } - this.tl.moveX(x - (bounds.getWidth() / 2)); - this.tl.moveY(y - (bounds.getHeight() / 2)); - this.tr.moveX(x + (bounds.getWidth() / 2)); - this.tr.moveY(y - (bounds.getHeight() / 2)); - this.bl.moveX(x - (bounds.getWidth() / 2)); - this.bl.moveY(y + (bounds.getHeight() / 2)); - this.br.moveX(x + (bounds.getWidth() / 2)); - this.br.moveY(y + (bounds.getHeight() / 2)); + y = this.maxYClamp - bounds.height / 2; + } + this.tl.moveX(x - (bounds.width / 2)); + this.tl.moveY(y - (bounds.height / 2)); + this.tr.moveX(x + (bounds.width / 2)); + this.tr.moveY(y - (bounds.height / 2)); + this.bl.moveX(x - (bounds.width / 2)); + this.bl.moveY(y + (bounds.height / 2)); + this.br.moveX(x + (bounds.width / 2)); + this.br.moveY(y + (bounds.height / 2)); marker.setPosition(x, y); - - } - enforceMinSize(x, y, marker) { + public enforceMinSize(x: number, y: number, marker: CornerMarker) { - var xLength = x - marker.getHorizontalNeighbour().getPosition().x; - var yLength = y - marker.getVerticalNeighbour().getPosition().y; - var xOver = this.minWidth - Math.abs(xLength); - var yOver = this.minHeight - Math.abs(yLength); + let xLength = x - marker.getHorizontalNeighbour().position.x; + let yLength = y - marker.getVerticalNeighbour().position.y; + let xOver = this.minWidth - Math.abs(xLength); + let yOver = this.minHeight - Math.abs(yLength); - if (xLength == 0 || yLength == 0) { - x = marker.getPosition().x; - y = marker.getPosition().y; + if (xLength === 0 || yLength === 0) { + x = marker.position.x; + y = marker.position.y; return PointPool.instance.borrow(x, y); } @@ -257,254 +263,241 @@ export class ImageCropper extends ImageCropperModel { if (yLength < 0) { y -= xOver * this.aspectRatio; - } - else { + } else { y += xOver * this.aspectRatio; } - } - else { + } else { x += xOver; if (yLength < 0) { y -= xOver * this.aspectRatio; - } - else { + } else { y += xOver * this.aspectRatio; } } - } - else { + } else { if (yLength < 0) { y -= yOver; if (xLength < 0) { x -= yOver / this.aspectRatio; - } - else { + } else { x += yOver / this.aspectRatio; } - } - else { + } else { y += yOver; if (xLength < 0) { x -= yOver / this.aspectRatio; - } - else { + } else { x += yOver / this.aspectRatio; } } } - } - else { + } else { if (xOver > 0) { if (xLength < 0) { x -= xOver; - if (yLength < 0) { y -= xOver * this.aspectRatio; - } - else { + } else { y += xOver * this.aspectRatio; } - } - else { + } else { x += xOver; if (yLength < 0) { y -= xOver * this.aspectRatio; - } - else { + } else { y += xOver * this.aspectRatio; } } - } - else if (yOver > 0) { - if (yLength < 0) { - y -= yOver; - - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; - } - } - else { - y += yOver; - if (xLength < 0) { - x -= yOver / this.aspectRatio; - } - else { - x += yOver / this.aspectRatio; + } else { + if (yOver > 0) { + if (yLength < 0) { + y -= yOver; + + if (xLength < 0) { + x -= yOver / this.aspectRatio; + } else { + x += yOver / this.aspectRatio; + } + } else { + y += yOver; + if (xLength < 0) { + x -= yOver / this.aspectRatio; + } else { + x += yOver / this.aspectRatio; + } } } } } - } - else { + } else { if (xOver > 0) { if (xLength < 0) { x -= xOver; - } - else { + } else { x += xOver; } } if (yOver > 0) { if (yLength < 0) { y -= yOver; - } - else { + } else { y += yOver; } } } if (x < this.minXClamp || x > this.maxXClamp || y < this.minYClamp || y > this.maxYClamp) { - x = marker.getPosition().x; - y = marker.getPosition().y; + x = marker.position.x; + y = marker.position.y; } return PointPool.instance.borrow(x, y); } - dragCorner(x, y, marker) { - var iX = 0; - var iY = 0; - var ax = 0; - var ay = 0; - var newHeight = 0; - var newWidth = 0; - var newY = 0; - var newX = 0; - var anchorMarker; - var fold = 0; - + public dragCorner(x: number, y: number, marker: CornerMarker) { + let iX: number = 0; + let iY: number = 0; + let ax: number = 0; + let ay: number = 0; + let newHeight: number = 0; + let newWidth: number = 0; + let newY: number = 0; + let newX: number = 0; + let anchorMarker: CornerMarker; + let fold: number = 0; if (this.keepAspect) { anchorMarker = marker.getHorizontalNeighbour().getVerticalNeighbour(); - ax = anchorMarker.getPosition().x; - ay = anchorMarker.getPosition().y; - if (x <= anchorMarker.getPosition().x) { - if (y <= anchorMarker.getPosition().y) { + ax = anchorMarker.position.x; + ay = anchorMarker.position.y; + if (x <= anchorMarker.position.x) { + if (y <= anchorMarker.position.y) { iX = ax - (100 / this.aspectRatio); iY = ay - (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), PointPool.instance.borrow(x, y)); + fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.position, + PointPool.instance.borrow(x, y)); if (fold > 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); + newHeight = Math.abs(anchorMarker.position.y - y); newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - PointPool.instance.returnPoint(min); - } - else if (fold < 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); + newY = anchorMarker.position.y - newHeight; + newX = anchorMarker.position.x - newWidth; + let min = this.enforceMinSize(newX, newY, marker); marker.move(min.x, min.y); PointPool.instance.returnPoint(min); + } else { + if (fold < 0) { + newWidth = Math.abs(anchorMarker.position.x - x); + newHeight = newWidth * this.aspectRatio; + newY = anchorMarker.position.y - newHeight; + newX = anchorMarker.position.x - newWidth; + let min = this.enforceMinSize(newX, newY, marker); + marker.move(min.x, min.y); + PointPool.instance.returnPoint(min); + } } - } - else { + } else { iX = ax - (100 / this.aspectRatio); iY = ay + (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), PointPool.instance.borrow(x, y)); + fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.position, + PointPool.instance.borrow(x, y)); if (fold > 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); + newWidth = Math.abs(anchorMarker.position.x - x); newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - PointPool.instance.returnPoint(min); - } - else if (fold < 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x - newWidth; - var min = this.enforceMinSize(newX, newY, marker); + newY = anchorMarker.position.y + newHeight; + newX = anchorMarker.position.x - newWidth; + let min = this.enforceMinSize(newX, newY, marker); marker.move(min.x, min.y); PointPool.instance.returnPoint(min); + } else { + if (fold < 0) { + newHeight = Math.abs(anchorMarker.position.y - y); + newWidth = newHeight / this.aspectRatio; + newY = anchorMarker.position.y + newHeight; + newX = anchorMarker.position.x - newWidth; + let min = this.enforceMinSize(newX, newY, marker); + marker.move(min.x, min.y); + PointPool.instance.returnPoint(min); + } } } - } - else { - if (y <= anchorMarker.getPosition().y) { + } else { + if (y <= anchorMarker.position.y) { iX = ax + (100 / this.aspectRatio); iY = ay - (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), PointPool.instance.borrow(x, y)); + fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.position, + PointPool.instance.borrow(x, y)); if (fold < 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); + newHeight = Math.abs(anchorMarker.position.y - y); newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - PointPool.instance.returnPoint(min); - } - else if (fold > 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); - newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y - newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); + newY = anchorMarker.position.y - newHeight; + newX = anchorMarker.position.x + newWidth; + let min = this.enforceMinSize(newX, newY, marker); marker.move(min.x, min.y); PointPool.instance.returnPoint(min); + } else { + if (fold > 0) { + newWidth = Math.abs(anchorMarker.position.x - x); + newHeight = newWidth * this.aspectRatio; + newY = anchorMarker.position.y - newHeight; + newX = anchorMarker.position.x + newWidth; + let min = this.enforceMinSize(newX, newY, marker); + marker.move(min.x, min.y); + PointPool.instance.returnPoint(min); + } } - } - else { + } else { iX = ax + (100 / this.aspectRatio); iY = ay + (100 / this.aspectRatio * this.aspectRatio); - fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.getPosition(), PointPool.instance.borrow(x, y)); + fold = this.getSide(PointPool.instance.borrow(iX, iY), anchorMarker.position, + PointPool.instance.borrow(x, y)); if (fold < 0) { - newWidth = Math.abs(anchorMarker.getPosition().x - x); + newWidth = Math.abs(anchorMarker.position.x - x); newHeight = newWidth * this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); - marker.move(min.x, min.y); - PointPool.instance.returnPoint(min); - } - else if (fold > 0) { - newHeight = Math.abs(anchorMarker.getPosition().y - y); - newWidth = newHeight / this.aspectRatio; - newY = anchorMarker.getPosition().y + newHeight; - newX = anchorMarker.getPosition().x + newWidth; - var min = this.enforceMinSize(newX, newY, marker); + newY = anchorMarker.position.y + newHeight; + newX = anchorMarker.position.x + newWidth; + let min = this.enforceMinSize(newX, newY, marker); marker.move(min.x, min.y); PointPool.instance.returnPoint(min); + } else { + if (fold > 0) { + newHeight = Math.abs(anchorMarker.position.y - y); + newWidth = newHeight / this.aspectRatio; + newY = anchorMarker.position.y + newHeight; + newX = anchorMarker.position.x + newWidth; + let min = this.enforceMinSize(newX, newY, marker); + marker.move(min.x, min.y); + PointPool.instance.returnPoint(min); + } } } } - } - else { - var min = this.enforceMinSize(x, y, marker); + } else { + let min = this.enforceMinSize(x, y, marker); marker.move(min.x, min.y); PointPool.instance.returnPoint(min); } this.center.recalculatePosition(this.getBounds()); } - getSide(a, b, c) { - var n = ImageCropper.sign((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)); - //TODO move the return of the pools to outside of this function + public getSide(a: Point, b: Point, c: Point): number { + let n: number = ImageCropper.sign((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)); + + // TODO move the return of the pools to outside of this function PointPool.instance.returnPoint(a); PointPool.instance.returnPoint(c); return n; } - handleRelease(newCropTouch) { + public handleRelease(newCropTouch: CropTouch) { if (newCropTouch == null) { return; } - var index = 0; - for (var k = 0; k < this.currentDragTouches.length; k++) { - if (newCropTouch.id == this.currentDragTouches[k].id) { + let index = 0; + for (let k = 0; k < this.currentDragTouches.length; k++) { + if (newCropTouch.id === this.currentDragTouches[k].id) { this.currentDragTouches[k].dragHandle.setDrag(false); newCropTouch.dragHandle = null; index = k; @@ -514,20 +507,20 @@ export class ImageCropper extends ImageCropperModel { this.draw(this.ctx); } - handleMove(newCropTouch) { - var matched = false; - for (var k = 0; k < this.currentDragTouches.length; k++) { - if (newCropTouch.id == this.currentDragTouches[k].id && this.currentDragTouches[k].dragHandle != null) { - var dragTouch = this.currentDragTouches[k]; - var clampedPositions = this.clampPosition(newCropTouch.x - dragTouch.dragHandle.offset.x, newCropTouch.y - dragTouch.dragHandle.offset.y); + public handleMove(newCropTouch: CropTouch) { + let matched = false; + for (let k = 0; k < this.currentDragTouches.length; k++) { + if (newCropTouch.id === this.currentDragTouches[k].id && this.currentDragTouches[k].dragHandle != null) { + let dragTouch: CropTouch = this.currentDragTouches[k]; + let clampedPositions = this.clampPosition(newCropTouch.x - dragTouch.dragHandle.offset.x, + newCropTouch.y - dragTouch.dragHandle.offset.y); newCropTouch.x = clampedPositions.x; newCropTouch.y = clampedPositions.y; PointPool.instance.returnPoint(clampedPositions); if (dragTouch.dragHandle instanceof CornerMarker) { - this.dragCorner(newCropTouch.x, newCropTouch.y, dragTouch.dragHandle); - } - else { - this.dragCrop(newCropTouch.x, newCropTouch.y, dragTouch.dragHandle); + this.dragCorner(newCropTouch.x, newCropTouch.y, (dragTouch.dragHandle as CornerMarker)); + } else { + this.dragCenter(newCropTouch.x, newCropTouch.y, (dragTouch.dragHandle as DragMarker)); } this.currentlyInteracting = true; matched = true; @@ -536,41 +529,42 @@ export class ImageCropper extends ImageCropperModel { } } if (!matched) { - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; + for (let i = 0; i < this.markers.length; i++) { + let marker: CornerMarker | DragMarker = this.markers[i]; if (marker.touchInBounds(newCropTouch.x, newCropTouch.y)) { newCropTouch.dragHandle = marker; this.currentDragTouches.push(newCropTouch); marker.setDrag(true); - newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.getPosition().x; - newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.getPosition().y; - this.dragCorner(newCropTouch.x - newCropTouch.dragHandle.offset.x, newCropTouch.y - newCropTouch.dragHandle.offset.y, newCropTouch.dragHandle); + newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.position.x; + newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.position.y; + this.dragCorner(newCropTouch.x - newCropTouch.dragHandle.offset.x, + newCropTouch.y - newCropTouch.dragHandle.offset.y, (newCropTouch.dragHandle as CornerMarker)); break; } } - if (newCropTouch.dragHandle == null) { + if (newCropTouch.dragHandle === null || typeof newCropTouch.dragHandle === "undefined") { if (this.center.touchInBounds(newCropTouch.x, newCropTouch.y)) { newCropTouch.dragHandle = this.center; this.currentDragTouches.push(newCropTouch); newCropTouch.dragHandle.setDrag(true); - newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.getPosition().x; - newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.getPosition().y; - this.dragCrop(newCropTouch.x - newCropTouch.dragHandle.offset.x, newCropTouch.y - newCropTouch.dragHandle.offset.y, newCropTouch.dragHandle); + newCropTouch.dragHandle.offset.x = newCropTouch.x - newCropTouch.dragHandle.position.x; + newCropTouch.dragHandle.offset.y = newCropTouch.y - newCropTouch.dragHandle.position.y; + this.dragCenter(newCropTouch.x - newCropTouch.dragHandle.offset.x, + newCropTouch.y - newCropTouch.dragHandle.offset.y, (newCropTouch.dragHandle as DragMarker)); } } } } - updateClampBounds() { - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvas.height / this.canvas.width; - var w = this.canvas.width; - var h = this.canvas.height; + public updateClampBounds() { + let sourceAspect = this.srcImage.height / this.srcImage.width; + let canvasAspect = this.canvas.height / this.canvas.width; + let w = this.canvas.width; + let h = this.canvas.height; if (canvasAspect > sourceAspect) { w = this.canvas.width; h = this.canvas.width * sourceAspect; - } - else { + } else { h = this.canvas.height; w = this.canvas.height / sourceAspect; } @@ -580,8 +574,8 @@ export class ImageCropper extends ImageCropperModel { this.maxYClamp = this.canvas.height / 2 + h / 2; } - getCropBounds() { - var bounds = this.getBounds(); + public getCropBounds() { + let bounds = this.getBounds(); bounds.top = Math.round(( bounds.top + this.minYClamp) / this.ratioH); bounds.bottom = Math.round(( bounds.bottom + this.minYClamp) / this.ratioH); bounds.left = Math.round((bounds.left - this.minXClamp) / this.ratioW); @@ -589,7 +583,7 @@ export class ImageCropper extends ImageCropperModel { return bounds; } - clampPosition(x, y) { + public clampPosition(x: number, y: number) { if (x < this.minXClamp) { x = this.minXClamp; } @@ -605,11 +599,11 @@ export class ImageCropper extends ImageCropperModel { return PointPool.instance.borrow(x, y); } - isImageSet() { + public isImageSet() { return this.imageSet; } - setImage(img:any) { + public setImage(img: any) { if (!img) { throw "Image is null"; } @@ -617,38 +611,36 @@ export class ImageCropper extends ImageCropperModel { this.srcImage = img; this.imageSet = true; this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); - var bufferContext = this.buffer.getContext('2d'); + let bufferContext = this.buffer.getContext("2d"); bufferContext.clearRect(0, 0, this.buffer.width, this.buffer.height); - var splitName = img.src.split('.'); - var fileType = splitName[1]; - if (fileType == 'png' || fileType == 'jpg') { + let splitName = img.src.split("."); + let fileType = splitName[1]; + if (fileType === "png" || fileType === "jpg") { this.fileType = fileType; } - //TODO: investigate better solution - //this.fileType = img.src.match(/^data:.+\/(.+);base64,(.*)$/)[1]; - - + // TODO: investigate better solution + // this.fileType = img.src.match(/^data:.+\/(.+);base64,(.*)$/)[1]; if (this.cropperSettings.minWithRelativeToResolution) { this.minWidth = (this.canvas.width * this.minWidth / this.srcImage.width); this.minHeight = (this.canvas.height * this.minHeight / this.srcImage.height); } this.updateClampBounds(); - var sourceAspect = this.srcImage.height / this.srcImage.width; - var cropBounds = this.getBounds(); - var cropAspect = cropBounds.getHeight() / cropBounds.getWidth(); - var w = this.canvas.width; - var h = this.canvas.height; + let sourceAspect: number = this.srcImage.height / this.srcImage.width; + let cropBounds: Bounds = this.getBounds(); + let cropAspect: number = cropBounds.height / cropBounds.width; + let w: number = this.canvas.width; + let h: number = this.canvas.height; this.canvasWidth = w; this.canvasHeight = h; - var cX = this.canvas.width / 2; - var cY = this.canvas.height / 2; - var tlPos = PointPool.instance.borrow(cX - cropBounds.getWidth() / 2, cY + cropBounds.getHeight() / 2); - var trPos = PointPool.instance.borrow(cX + cropBounds.getWidth() / 2, cY + cropBounds.getHeight() / 2); - var blPos = PointPool.instance.borrow(cX - cropBounds.getWidth() / 2, cY - cropBounds.getHeight() / 2); - var brPos = PointPool.instance.borrow(cX + cropBounds.getWidth() / 2, cY - cropBounds.getHeight() / 2); + let cX: number = this.canvas.width / 2; + let cY: number = this.canvas.height / 2; + let tlPos: Point = PointPool.instance.borrow(cX - cropBounds.width / 2, cY + cropBounds.height / 2); + let trPos: Point = PointPool.instance.borrow(cX + cropBounds.width / 2, cY + cropBounds.height / 2); + let blPos: Point = PointPool.instance.borrow(cX - cropBounds.width / 2, cY - cropBounds.height / 2); + let brPos: Point = PointPool.instance.borrow(cX + cropBounds.width / 2, cY - cropBounds.height / 2); this.tl.setPosition(tlPos.x, tlPos.y); this.tr.setPosition(trPos.x, trPos.y); this.bl.setPosition(blPos.x, blPos.y); @@ -659,15 +651,15 @@ export class ImageCropper extends ImageCropperModel { PointPool.instance.returnPoint(brPos); this.center.setPosition(cX, cY); if (cropAspect > sourceAspect) { - var imageH = Math.min(w * sourceAspect, h); - var cropW = imageH / cropAspect; + let imageH = Math.min(w * sourceAspect, h); + let cropW = imageH / cropAspect; tlPos = PointPool.instance.borrow(cX - cropW / 2, cY + imageH / 2); trPos = PointPool.instance.borrow(cX + cropW / 2, cY + imageH / 2); blPos = PointPool.instance.borrow(cX - cropW / 2, cY - imageH / 2); brPos = PointPool.instance.borrow(cX + cropW / 2, cY - imageH / 2); } else { - var imageW = Math.min(h / sourceAspect, w); - var cropH = imageW * cropAspect; + let imageW = Math.min(h / sourceAspect, w); + let cropH = imageW * cropAspect; tlPos = PointPool.instance.borrow(cX - imageW / 2, cY + cropH / 2); trPos = PointPool.instance.borrow(cX + imageW / 2, cY + cropH / 2); blPos = PointPool.instance.borrow(cX - imageW / 2, cY - cropH / 2); @@ -682,46 +674,42 @@ export class ImageCropper extends ImageCropperModel { PointPool.instance.returnPoint(trPos); PointPool.instance.returnPoint(blPos); PointPool.instance.returnPoint(brPos); - - this.vertSquashRatio = ImageCropper.detectVerticalSquash(this.srcImage); this.draw(this.ctx); this.croppedImage = this.getCroppedImage(this.cropWidth, this.cropHeight); } - getCroppedImage(fillWidth?:number, fillHeight?:number) { - var bounds = this.getBounds(); + // todo: Unused parameters? + public getCroppedImage(fillWidth?: number, fillHeight?: number): HTMLImageElement { + let bounds: Bounds = this.getBounds(); if (!this.srcImage) { throw "Source image not set."; } - var sourceAspect = this.srcImage.height / this.srcImage.width; - var canvasAspect = this.canvas.height / this.canvas.width; - var w = this.canvas.width; - var h = this.canvas.height; + let sourceAspect: number = this.srcImage.height / this.srcImage.width; + let canvasAspect: number = this.canvas.height / this.canvas.width; + let w: number = this.canvas.width; + let h: number = this.canvas.height; if (canvasAspect > sourceAspect) { w = this.canvas.width; h = this.canvas.width * sourceAspect; - } - else if (canvasAspect < sourceAspect) { - h = this.canvas.height; - w = this.canvas.height / sourceAspect; - } - else { - h = this.canvas.height; - w = this.canvas.width; + } else { + if (canvasAspect < sourceAspect) { + h = this.canvas.height; + w = this.canvas.height / sourceAspect; + } else { + h = this.canvas.height; + w = this.canvas.width; + } } this.ratioW = w / this.srcImage.width; this.ratioH = h / this.srcImage.height; - var offsetH = (this.buffer.height - h) / 2 / this.ratioH; - var offsetW = (this.buffer.width - w) / 2 / this.ratioW; + let offsetH: number = (this.buffer.height - h) / 2 / this.ratioH; + let offsetW: number = (this.buffer.width - w) / 2 / this.ratioW; - this.drawImageIOSFix( - this.cropCanvas.getContext('2d'), - this.srcImage, + this.drawImageIOSFix(this.cropCanvas.getContext("2d"), this.srcImage, Math.max(Math.round((bounds.left) / this.ratioW - offsetW), 0), Math.max(Math.round(bounds.top / this.ratioH - offsetH), 0), - Math.max(Math.round(bounds.getWidth() / this.ratioW), 1), - Math.max(Math.round(bounds.getHeight() / this.ratioH), 1), + Math.max(Math.round(bounds.width / this.ratioW), 1), Math.max(Math.round(bounds.height / this.ratioH), 1), 0, 0, this.cropCanvas.width, this.cropCanvas.height); this.croppedImage.width = this.cropCanvas.width; @@ -730,27 +718,27 @@ export class ImageCropper extends ImageCropperModel { return this.croppedImage; } - getBounds() { - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - var maxX = -Number.MAX_VALUE; - var maxY = -Number.MAX_VALUE; - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; - if (marker.getPosition().x < minX) { - minX = marker.getPosition().x; + public getBounds(): Bounds { + let minX = Number.MAX_VALUE; + let minY = Number.MAX_VALUE; + let maxX = -Number.MAX_VALUE; + let maxY = -Number.MAX_VALUE; + for (let i = 0; i < this.markers.length; i++) { + let marker = this.markers[i]; + if (marker.position.x < minX) { + minX = marker.position.x; } - if (marker.getPosition().x > maxX) { - maxX = marker.getPosition().x; + if (marker.position.x > maxX) { + maxX = marker.position.x; } - if (marker.getPosition().y < minY) { - minY = marker.getPosition().y; + if (marker.position.y < minY) { + minY = marker.position.y; } - if (marker.getPosition().y > maxY) { - maxY = marker.getPosition().y; + if (marker.position.y > maxY) { + maxY = marker.position.y; } } - var bounds = new Bounds(); + let bounds: Bounds = new Bounds(); bounds.left = minX; bounds.right = maxX; bounds.top = minY; @@ -758,30 +746,27 @@ export class ImageCropper extends ImageCropperModel { return bounds; } - setBounds(bounds) { + public setBounds(bounds: any) { - var topLeft; - var topRight; - var bottomLeft; - var bottomRight; + let topLeft: CornerMarker; + let topRight: CornerMarker; + let bottomLeft: CornerMarker; + let bottomRight: CornerMarker; - var currentBounds = this.getBounds(); - for (var i = 0; i < this.markers.length; i++) { - var marker = this.markers[i]; + let currentBounds = this.getBounds(); + for (let i = 0; i < this.markers.length; i++) { + let marker = this.markers[i]; - if (marker.getPosition().x == currentBounds.left) { - if (marker.getPosition().y == currentBounds.top) { + if (marker.position.x === currentBounds.left) { + if (marker.position.y === currentBounds.top) { topLeft = marker; - } - else { + } else { bottomLeft = marker; } - } - else { - if (marker.getPosition().y == currentBounds.top) { + } else { + if (marker.position.y === currentBounds.top) { topRight = marker; - } - else { + } else { bottomRight = marker; } } @@ -797,50 +782,48 @@ export class ImageCropper extends ImageCropperModel { } - onTouchMove(event:TouchEvent) { + public onTouchMove(event: TouchEvent) { if (this.crop.isImageSet()) { event.preventDefault(); if (event.touches.length === 1) { - for (var i = 0; i < event.touches.length; i++) { - var touch = event.touches[i]; - var touchPosition = ImageCropper.getTouchPos(this.canvas, touch); - var cropTouch = new CropTouch(touchPosition.x, touchPosition.y, touch.identifier); + for (let i = 0; i < event.touches.length; i++) { + let touch = event.touches[i]; + let touchPosition = ImageCropper.getTouchPos(this.canvas, touch); + let cropTouch = new CropTouch(touchPosition.x, touchPosition.y, touch.identifier); PointPool.instance.returnPoint(touchPosition); this.move(cropTouch); } - } else if (event.touches.length === 2) { - var distance = - ((event.touches[0].clientX - event.touches[1].clientX) * (event.touches[0].clientX - event.touches[1].clientX)) + - ((event.touches[0].clientY - event.touches[1].clientY) * (event.touches[0].clientY - event.touches[1].clientY)); - if (this.previousDistance && this.previousDistance !== distance) { - var increment:number = distance < this.previousDistance ? 1 : -1; - var bounds:Bounds = this.getBounds(); - - bounds.top += increment; - bounds.left += increment; - bounds.right -= increment; - bounds.bottom -= increment; - - this.setBounds(bounds); + } else { + if (event.touches.length === 2) { + let distance = ((event.touches[0].clientX - event.touches[1].clientX) * (event.touches[0].clientX - event.touches[1].clientX)) + ((event.touches[0].clientY - event.touches[1].clientY) * (event.touches[0].clientY - event.touches[1].clientY)); + if (this.previousDistance && this.previousDistance !== distance) { + let increment: number = distance < this.previousDistance ? 1 : -1; + let bounds: Bounds = this.getBounds(); + + bounds.top += increment; + bounds.left += increment; + bounds.right -= increment; + bounds.bottom -= increment; + + this.setBounds(bounds); + } + this.previousDistance = distance; } - - this.previousDistance = distance; } this.draw(this.ctx); } } - onMouseMove(e) { + public onMouseMove(e: MouseEvent) { if (this.crop.isImageSet()) { - var mousePosition = ImageCropper.getMousePos(this.canvas, e); + let mousePosition = ImageCropper.getMousePos(this.canvas, e); this.move(new CropTouch(mousePosition.x, mousePosition.y, 0)); - var dragTouch = this.getDragTouchForID(0); + let dragTouch = this.getDragTouchForID(0); if (dragTouch) { dragTouch.x = mousePosition.x; dragTouch.y = mousePosition.y; - } - else { + } else { dragTouch = new CropTouch(mousePosition.x, mousePosition.y, 0); } PointPool.instance.returnPoint(mousePosition); @@ -849,73 +832,70 @@ export class ImageCropper extends ImageCropperModel { } } - move(cropTouch) { + public move(cropTouch: CropTouch) { if (this.isMouseDown) { this.handleMove(cropTouch); } } - getDragTouchForID(id) { - for (var i = 0; i < this.currentDragTouches.length; i++) { - if (id == this.currentDragTouches[i].id) { + public getDragTouchForID(id: any) { + for (let i = 0; i < this.currentDragTouches.length; i++) { + if (id === this.currentDragTouches[i].id) { return this.currentDragTouches[i]; } } } - drawCursors(cropTouch) { - var cursorDrawn = false; + public drawCursors(cropTouch: CropTouch) { + let cursorDrawn = false; if (cropTouch != null) { - if (cropTouch.dragHandle == this.center) { - ImageCropperDataShare.setStyle(this.canvas, 'move'); + if (cropTouch.dragHandle === this.center) { + ImageCropperDataShare.setStyle(this.canvas, "move"); cursorDrawn = true; } - if (cropTouch.dragHandle != null && cropTouch.dragHandle instanceof CornerMarker) { + if (cropTouch.dragHandle !== null && cropTouch.dragHandle instanceof CornerMarker) { - this.drawCornerCursor(cropTouch.dragHandle, cropTouch.dragHandle.getPosition().x, cropTouch.dragHandle.getPosition().y); + this.drawCornerCursor(cropTouch.dragHandle, cropTouch.dragHandle.position.x, + cropTouch.dragHandle.position.y); cursorDrawn = true; } } - var didDraw = false; + let didDraw = false; if (!cursorDrawn) { - for (var i = 0; i < this.markers.length; i++) { + for (let i = 0; i < this.markers.length; i++) { didDraw = didDraw || this.drawCornerCursor(this.markers[i], cropTouch.x, cropTouch.y); } if (!didDraw) { - ImageCropperDataShare.setStyle(this.canvas, 'initial'); + ImageCropperDataShare.setStyle(this.canvas, "initial"); } } if (!didDraw && !cursorDrawn && this.center.touchInBounds(cropTouch.x, cropTouch.y)) { this.center.setOver(true); ImageCropperDataShare.setOver(this.canvas); - ImageCropperDataShare.setStyle(this.canvas, 'move'); - } - else { + ImageCropperDataShare.setStyle(this.canvas, "move"); + } else { this.center.setOver(false); } } - drawCornerCursor(marker, x, y) { + public drawCornerCursor(marker: any, x: number, y: number) { if (marker.touchInBounds(x, y)) { marker.setOver(true); - if (marker.getHorizontalNeighbour().getPosition().x > marker.getPosition().x) { - if (marker.getVerticalNeighbour().getPosition().y > marker.getPosition().y) { + if (marker.getHorizontalNeighbour().position.x > marker.position.x) { + if (marker.getVerticalNeighbour().position.y > marker.position.y) { ImageCropperDataShare.setOver(this.canvas); - ImageCropperDataShare.setStyle(this.canvas, 'nwse-resize'); - } - else { + ImageCropperDataShare.setStyle(this.canvas, "nwse-resize"); + } else { ImageCropperDataShare.setOver(this.canvas); - ImageCropperDataShare.setStyle(this.canvas, 'nesw-resize'); + ImageCropperDataShare.setStyle(this.canvas, "nesw-resize"); } - } - else { - if (marker.getVerticalNeighbour().getPosition().y > marker.getPosition().y) { + } else { + if (marker.getVerticalNeighbour().position.y > marker.position.y) { ImageCropperDataShare.setOver(this.canvas); - ImageCropperDataShare.setStyle(this.canvas, 'nesw-resize'); - } - else { + ImageCropperDataShare.setStyle(this.canvas, "nesw-resize"); + } else { ImageCropperDataShare.setOver(this.canvas); - ImageCropperDataShare.setStyle(this.canvas, 'nwse-resize'); + ImageCropperDataShare.setStyle(this.canvas, "nwse-resize"); } } return true; @@ -924,18 +904,19 @@ export class ImageCropper extends ImageCropperModel { return false; } - onTouchStart(event:TouchEvent) { + // todo: Unused param + public onTouchStart(event: TouchEvent) { if (this.crop.isImageSet()) { this.isMouseDown = true; } } - onTouchEnd(event:TouchEvent) { + public onTouchEnd(event: TouchEvent) { if (this.crop.isImageSet()) { - for (var i = 0; i < event.changedTouches.length; i++) { - var touch = event.changedTouches[i]; - var dragTouch = this.getDragTouchForID(touch.identifier); - if (dragTouch != null) { + for (let i = 0; i < event.changedTouches.length; i++) { + let touch = event.changedTouches[i]; + let dragTouch = this.getDragTouchForID(touch.identifier); + if (dragTouch !== null) { if (dragTouch.dragHandle instanceof CornerMarker || dragTouch.dragHandle instanceof DragMarker) { dragTouch.dragHandle.setOver(false); } @@ -943,37 +924,37 @@ export class ImageCropper extends ImageCropperModel { } } - if (this.currentDragTouches.length == 0) { + if (this.currentDragTouches.length === 0) { this.isMouseDown = false; this.currentlyInteracting = false; } } } - //http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios - drawImageIOSFix(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { + // http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios + public drawImageIOSFix(ctx: CanvasRenderingContext2D, img: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, + sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, + dh: number) { + // Works only if whole image is displayed: // ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio); // The following works correct also when only a part of the image is displayed: - //ctx.drawImage(img, sx * this.vertSquashRatio, sy * this.vertSquashRatio, sw * this.vertSquashRatio, sh * this.vertSquashRatio, dx, dy, dw, dh); + // ctx.drawImage(img, sx * this.vertSquashRatio, sy * this.vertSquashRatio, sw * this.vertSquashRatio, sh * + // this.vertSquashRatio, dx, dy, dw, dh); ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh); } - - onMouseDown() { + public onMouseDown() { if (this.crop.isImageSet()) { this.isMouseDown = true; } } - - onMouseUp() { + public onMouseUp() { if (this.crop.isImageSet()) { ImageCropperDataShare.setReleased(this.canvas); this.isMouseDown = false; this.handleRelease(new CropTouch(0, 0, 0)); } } - - } diff --git a/src/imageCropperComponent.d.ts b/src/imageCropperComponent.d.ts deleted file mode 100644 index 0ce7aba3..00000000 --- a/src/imageCropperComponent.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Renderer, ElementRef, EventEmitter, Type } from '@angular/core'; -import { ImageCropper } from "./imageCropper"; -import { CropperSettings } from "./cropperSettings"; -export declare class ImageCropperComponent extends Type { - cropcanvas: ElementRef; - onCrop: EventEmitter; - settings: CropperSettings; - image: any; - cropper: ImageCropper; - croppedWidth: number; - croppedHeight: number; - intervalRef: number; - private renderer; - constructor(renderer: Renderer); - ngAfterViewInit(): void; - onTouchMove(event: any): void; - onTouchStart(event: TouchEvent): void; - onTouchEnd(event: any): void; - onMouseDown(): void; - onMouseUp(): void; - onMouseMove(event: any): void; - fileChangeListener($event: any): void; - setImage(image: any): void; - private getOrientedImage(image, callback); -} diff --git a/src/imageCropperComponent.js b/src/imageCropperComponent.js deleted file mode 100644 index 1126da7e..00000000 --- a/src/imageCropperComponent.js +++ /dev/null @@ -1,167 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var core_1 = require('@angular/core'); -var imageCropper_1 = require("./imageCropper"); -var cropperSettings_1 = require("./cropperSettings"); -var exif_1 = require("./exif"); -var ImageCropperComponent = (function (_super) { - __extends(ImageCropperComponent, _super); - function ImageCropperComponent(renderer) { - _super.call(this); - this.onCrop = new core_1.EventEmitter(); - this.renderer = renderer; - } - ImageCropperComponent.prototype.ngAfterViewInit = function () { - var canvas = this.cropcanvas.nativeElement; - if (!this.settings) { - this.settings = new cropperSettings_1.CropperSettings(); - } - this.renderer.setElementAttribute(canvas, 'width', this.settings.canvasWidth.toString()); - this.renderer.setElementAttribute(canvas, 'height', this.settings.canvasHeight.toString()); - if (!this.cropper) { - this.cropper = new imageCropper_1.ImageCropper(this.settings); - } - this.cropper.prepare(canvas); - }; - ImageCropperComponent.prototype.onTouchMove = function (event) { - this.cropper.onTouchMove(event); - }; - ImageCropperComponent.prototype.onTouchStart = function (event) { - this.cropper.onTouchStart(event); - }; - ImageCropperComponent.prototype.onTouchEnd = function (event) { - this.cropper.onTouchEnd(event); - if (this.cropper.isImageSet()) { - this.image.image = this.cropper.getCroppedImage().src; - this.onCrop.emit(this.cropper.getCropBounds()); - } - }; - ImageCropperComponent.prototype.onMouseDown = function () { - this.cropper.onMouseDown(); - }; - ImageCropperComponent.prototype.onMouseUp = function () { - if (this.cropper.isImageSet()) { - this.cropper.onMouseUp(); - this.image.image = this.cropper.getCroppedImage().src; - this.onCrop.emit(this.cropper.getCropBounds()); - } - }; - ImageCropperComponent.prototype.onMouseMove = function (event) { - this.cropper.onMouseMove(event); - }; - ImageCropperComponent.prototype.fileChangeListener = function ($event) { - var file = $event.target.files[0]; - if (this.settings.allowedFilesRegex.test(file.name)) { - var image = new Image(); - var fileReader = new FileReader(); - var that = this; - fileReader.addEventListener('loadend', function (loadEvent) { - image.src = loadEvent.target.result; - that.setImage(image); - }); - fileReader.readAsDataURL(file); - } - }; - ImageCropperComponent.prototype.setImage = function (image) { - var self = this; - this.intervalRef = setInterval(function () { - if (this.intervalRef) { - clearInterval(this.intervalRef); - } - if (image.naturalHeight > 0) { - image.height = image.naturalHeight; - image.width = image.naturalWidth; - clearInterval(self.intervalRef); - self.getOrientedImage(image, function (img) { - self.cropper.setImage(img); - self.image.original = img; - self.image.image = self.cropper.getCroppedImage().src; - self.onCrop.emit(self.cropper.getCropBounds()); - }); - } - }, 10); - }; - ImageCropperComponent.prototype.getOrientedImage = function (image, callback) { - var img; - exif_1.Exif.getData(image, function () { - var orientation = exif_1.Exif.getTag(image, 'Orientation'); - if ([3, 6, 8].indexOf(orientation) > -1) { - var canvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), cw = image.width, ch = image.height, cx = 0, cy = 0, deg = 0; - switch (orientation) { - case 3: - cx = -image.width; - cy = -image.height; - deg = 180; - break; - case 6: - cw = image.height; - ch = image.width; - cy = -image.height; - deg = 90; - break; - case 8: - cw = image.height; - ch = image.width; - cx = -image.width; - deg = 270; - break; - } - canvas.width = cw; - canvas.height = ch; - ctx.rotate(deg * Math.PI / 180); - ctx.drawImage(image, cx, cy); - img = document.createElement("img"); - img.width = cw; - img.height = ch; - img.src = canvas.toDataURL("image/png"); - } - else { - img = image; - } - callback(img); - }); - }; - __decorate([ - core_1.ViewChild('cropcanvas', undefined), - __metadata('design:type', core_1.ElementRef) - ], ImageCropperComponent.prototype, "cropcanvas", void 0); - __decorate([ - core_1.Output(), - __metadata('design:type', core_1.EventEmitter) - ], ImageCropperComponent.prototype, "onCrop", void 0); - __decorate([ - core_1.Input(), - __metadata('design:type', cropperSettings_1.CropperSettings) - ], ImageCropperComponent.prototype, "settings", void 0); - __decorate([ - core_1.Input(), - __metadata('design:type', Object) - ], ImageCropperComponent.prototype, "image", void 0); - __decorate([ - core_1.Input(), - __metadata('design:type', imageCropper_1.ImageCropper) - ], ImageCropperComponent.prototype, "cropper", void 0); - ImageCropperComponent = __decorate([ - core_1.Component({ - selector: 'img-cropper', - template: "\n \n \n \n \n \n " - }), - __metadata('design:paramtypes', [core_1.Renderer]) - ], ImageCropperComponent); - return ImageCropperComponent; -}(core_1.Type)); -exports.ImageCropperComponent = ImageCropperComponent; -//# sourceMappingURL=imageCropperComponent.js.map \ No newline at end of file diff --git a/src/imageCropperComponent.js.map b/src/imageCropperComponent.js.map deleted file mode 100644 index 07d5fef4..00000000 --- a/src/imageCropperComponent.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"imageCropperComponent.js","sourceRoot":"","sources":["imageCropperComponent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qBAA4F,eAAe,CAAC,CAAA;AAC5G,6BAA2B,gBAAgB,CAAC,CAAA;AAC5C,gCAA8B,mBAAmB,CAAC,CAAA;AAClD,qBAAmB,QAAQ,CAAC,CAAA;AAkB5B;IAA2C,yCAAI;IAwB3C,+BAAY,QAAiB;QACzB,iBAAO,CAAC;QAnBF,WAAM,GAAqB,IAAI,mBAAY,EAAE,CAAC;QAoBpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,+CAAe,GAAf;QACI,IAAI,MAAM,GAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAE/C,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAe,EAAE,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EA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AC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IAlKD;QAAC,gBAAS,CAAC,YAAY,EAAE,SAAS,CAAC;;6DAAA;IAInC;QAAC,aAAM,EAAE;;yDAAA;IAET;QAAC,YAAK,EAAE;;2DAAA;IAGR;QAAC,YAAK,EAAE;;wDAAA;IAGR;QAAC,YAAK,EAAE;;0DAAA;IA9BZ;QAAC,gBAAS,CAAC;YACP,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,sfAYX;SACF,CAAC;;6BAAA;IAuKF,4BAAC;AAAD,CAAC,AAtKD,CAA2C,WAAI,GAsK9C;AAtKY,6BAAqB,wBAsKjC,CAAA"} \ No newline at end of file diff --git a/src/imageCropperComponent.ts b/src/imageCropperComponent.ts index 1908227f..8d0fc280 100644 --- a/src/imageCropperComponent.ts +++ b/src/imageCropperComponent.ts @@ -1,11 +1,10 @@ -import {Component, Input, Renderer, ViewChild, ElementRef, Output, EventEmitter, Type} from '@angular/core'; +import {Component, Input, Renderer, ViewChild, ElementRef, Output, EventEmitter, Type} from "@angular/core"; import {ImageCropper} from "./imageCropper"; import {CropperSettings} from "./cropperSettings"; import {Exif} from "./exif"; @Component({ - selector: 'img-cropper', - template: ` + selector: "img-cropper", template: ` ` }) -export class ImageCropperComponent extends Type { - - @ViewChild('cropcanvas', undefined) - cropcanvas:ElementRef; - - @Output() onCrop:EventEmitter = new EventEmitter(); +export class ImageCropperComponent extends Type { - @Input() - settings:CropperSettings; + @ViewChild("cropcanvas", undefined) private cropcanvas: ElementRef; - @Input() - image:any; + @Input() private settings: CropperSettings; + @Input() private image: any; + @Input() private cropper: ImageCropper; - @Input() - cropper:ImageCropper; + @Output() private onCrop: EventEmitter = new EventEmitter(); - croppedWidth:number; - croppedHeight:number; + public croppedWidth: number; + public croppedHeight: number; - intervalRef:number; + public intervalRef: number; - private renderer:Renderer; + public renderer: Renderer; - constructor(renderer:Renderer) { + constructor(renderer: Renderer) { super(); this.renderer = renderer; } - ngAfterViewInit() { - var canvas:any = this.cropcanvas.nativeElement; + public ngAfterViewInit() { + let canvas: HTMLCanvasElement = this.cropcanvas.nativeElement; if (!this.settings) { this.settings = new CropperSettings(); } - this.renderer.setElementAttribute(canvas, 'width', this.settings.canvasWidth.toString()); - this.renderer.setElementAttribute(canvas, 'height', this.settings.canvasHeight.toString()); + this.renderer.setElementAttribute(canvas, "width", this.settings.canvasWidth.toString()); + this.renderer.setElementAttribute(canvas, "height", this.settings.canvasHeight.toString()); if (!this.cropper) { this.cropper = new ImageCropper(this.settings); @@ -65,15 +58,15 @@ export class ImageCropperComponent extends Type { this.cropper.prepare(canvas); } - onTouchMove(event):void { + public onTouchMove(event: TouchEvent): void { this.cropper.onTouchMove(event); } - onTouchStart(event:TouchEvent):void { + public onTouchStart(event: TouchEvent): void { this.cropper.onTouchStart(event); } - onTouchEnd(event):void { + public onTouchEnd(event: TouchEvent): void { this.cropper.onTouchEnd(event); if (this.cropper.isImageSet()) { this.image.image = this.cropper.getCroppedImage().src; @@ -81,11 +74,11 @@ export class ImageCropperComponent extends Type { } } - onMouseDown():void { + public onMouseDown(): void { this.cropper.onMouseDown(); } - onMouseUp():void { + public onMouseUp(): void { if (this.cropper.isImageSet()) { this.cropper.onMouseUp(); this.image.image = this.cropper.getCroppedImage().src; @@ -93,18 +86,18 @@ export class ImageCropperComponent extends Type { } } - onMouseMove(event):void { + public onMouseMove(event: MouseEvent): void { this.cropper.onMouseMove(event); } - fileChangeListener($event) { - var file:File = $event.target.files[0]; + public fileChangeListener($event: any) { + let file: File = $event.target.files[0]; if (this.settings.allowedFilesRegex.test(file.name)) { - var image:any = new Image(); - var fileReader:FileReader = new FileReader(); - var that = this; + let image: any = new Image(); + let fileReader: FileReader = new FileReader(); + let that = this; - fileReader.addEventListener('loadend', function (loadEvent:any) { + fileReader.addEventListener("loadend", function (loadEvent: any) { image.src = loadEvent.target.result; that.setImage(image); }); @@ -113,9 +106,8 @@ export class ImageCropperComponent extends Type { } } - - setImage(image) { - var self = this; + public setImage(image: HTMLImageElement) { + let self = this; this.intervalRef = window.setInterval(function () { if (this.intervalRef) { @@ -127,7 +119,7 @@ export class ImageCropperComponent extends Type { image.width = image.naturalWidth; clearInterval(self.intervalRef); - self.getOrientedImage(image, function (img) { + self.getOrientedImage(image, function (img: HTMLImageElement) { self.cropper.setImage(img); self.image.original = img; self.image.image = self.cropper.getCroppedImage().src; @@ -138,16 +130,21 @@ export class ImageCropperComponent extends Type { } - private getOrientedImage(image, callback) { - var img:any; + private getOrientedImage(image: HTMLImageElement, callback: Function) { + let img: any; Exif.getData(image, function () { - var orientation = Exif.getTag(image, 'Orientation'); + let orientation = Exif.getTag(image, "Orientation"); if ([3, 6, 8].indexOf(orientation) > -1) { - var canvas:HTMLCanvasElement = document.createElement("canvas"), - ctx:CanvasRenderingContext2D = canvas.getContext("2d"), - cw:number = image.width, ch:number = image.height, cx:number = 0, cy:number = 0, deg:number = 0; + let canvas: HTMLCanvasElement = document.createElement("canvas"), + ctx: CanvasRenderingContext2D = canvas.getContext("2d"), + cw: number = image.width, + ch: number = image.height, + cx: number = 0, + cy: number = 0, + deg: number = 0; + switch (orientation) { case 3: cx = -image.width; @@ -166,6 +163,8 @@ export class ImageCropperComponent extends Type { cx = -image.width; deg = 270; break; + default: + break; } canvas.width = cw; @@ -176,7 +175,6 @@ export class ImageCropperComponent extends Type { img.width = cw; img.height = ch; img.src = canvas.toDataURL("image/png"); - } else { img = image; } @@ -184,6 +182,4 @@ export class ImageCropperComponent extends Type { callback(img); }); } - } - diff --git a/src/imageCropperDataShare.d.ts b/src/imageCropperDataShare.d.ts deleted file mode 100644 index f365adb3..00000000 --- a/src/imageCropperDataShare.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export declare class ImageCropperDataShare { - static share: any; - static pressed: any; - static over: any; - static setPressed(canvas: any): void; - static setReleased(canvas: any): void; - static setOver(canvas: any): void; - static setStyle(canvas: any, style: any): void; -} diff --git a/src/imageCropperDataShare.js b/src/imageCropperDataShare.js deleted file mode 100644 index d5c973de..00000000 --- a/src/imageCropperDataShare.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -var ImageCropperDataShare = (function () { - function ImageCropperDataShare() { - } - ImageCropperDataShare.setPressed = function (canvas) { - this.pressed = canvas; - }; - ; - ImageCropperDataShare.setReleased = function (canvas) { - if (canvas === this.pressed) { - this.pressed = undefined; - } - }; - ; - ImageCropperDataShare.setOver = function (canvas) { - this.over = canvas; - }; - ; - ImageCropperDataShare.setStyle = function (canvas, style) { - if (this.pressed !== undefined) { - if (this.pressed === canvas) { - } - } - else { - if (canvas === this.over) { - } - } - }; - ; - ImageCropperDataShare.share = {}; - return ImageCropperDataShare; -}()); -exports.ImageCropperDataShare = ImageCropperDataShare; -//# sourceMappingURL=imageCropperDataShare.js.map \ No newline at end of file diff --git a/src/imageCropperDataShare.js.map b/src/imageCropperDataShare.js.map deleted file mode 100644 index f6c62830..00000000 --- a/src/imageCropperDataShare.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"imageCropperDataShare.js","sourceRoot":"","sources":["imageCropperDataShare.ts"],"names":[],"mappings":";AAAA;IAAA;IAiCA,CAAC;IA5BiB,gCAAU,GAAxB,UAAyB,MAAM;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;;IAEa,iCAAW,GAAzB,UAA0B,MAAM;QAC5B,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAC7B,CAAC;IACL,CAAC;;IAEa,6BAAO,GAArB,UAAsB,MAAM;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IACvB,CAAC;;IAEa,8BAAQ,GAAtB,UAAuB,MAAM,EAAE,KAAK;QAChC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC;YAC7B,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;YAG9B,CAAC;QACL,CAAC;QACD,IAAI,CAAC,CAAC;YACF,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAG3B,CAAC;QACL,CAAC;IACL,CAAC;;IA/Ba,2BAAK,GAAO,EAAE,CAAC;IAgCjC,4BAAC;AAAD,CAAC,AAjCD,IAiCC;AAjCY,6BAAqB,wBAiCjC,CAAA"} \ No newline at end of file diff --git a/src/imageCropperDataShare.ts b/src/imageCropperDataShare.ts index 1db32735..2f35b8ee 100644 --- a/src/imageCropperDataShare.ts +++ b/src/imageCropperDataShare.ts @@ -1,33 +1,32 @@ export class ImageCropperDataShare { - public static share:any = {}; - public static pressed; - public static over; + public static share: any = {}; + public static pressed: HTMLCanvasElement; + public static over: HTMLCanvasElement; - public static setPressed(canvas):void { + public static setPressed(canvas: HTMLCanvasElement): void { this.pressed = canvas; }; - public static setReleased(canvas):void { + public static setReleased(canvas: HTMLCanvasElement): void { if (canvas === this.pressed) { this.pressed = undefined; } }; - public static setOver(canvas):void { + public static setOver(canvas: HTMLCanvasElement): void { this.over = canvas; }; - public static setStyle(canvas, style):void { + public static setStyle(canvas: HTMLCanvasElement, style: any): void { if (this.pressed !== undefined) { if (this.pressed === canvas) { - //TODO: check this - //angular.element(document.documentElement).css('cursor', style); + // TODO: check this + // angular.element(document.documentElement).css('cursor', style); } - } - else { + } else { if (canvas === this.over) { - //TODO: check this - //angular.element(document.documentElement).css('cursor', style); + // TODO: check this + // angular.element(document.documentElement).css('cursor', style); } } }; diff --git a/src/model/bounds.d.ts b/src/model/bounds.d.ts deleted file mode 100644 index d8a1cf0e..00000000 --- a/src/model/bounds.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Point } from './point'; -export declare class Bounds { - left: number; - right: number; - top: number; - bottom: number; - constructor(x?: number, y?: number, width?: number, height?: number); - getWidth(): number; - getHeight(): number; - getCentre(): Point; -} diff --git a/src/model/bounds.js b/src/model/bounds.js deleted file mode 100644 index 595e135c..00000000 --- a/src/model/bounds.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -var pointPool_1 = require('./pointPool'); -var Bounds = (function () { - function Bounds(x, y, width, height) { - if (x === void 0) { - x = 0; - } - if (y === void 0) { - y = 0; - } - if (width === void 0) { - width = 0; - } - if (height === void 0) { - height = 0; - } - this.left = x; - this.right = x + width; - this.top = y; - this.bottom = y + height; - } - Bounds.prototype.getWidth = function () { - return this.right - this.left; - }; - ; - Bounds.prototype.getHeight = function () { - return this.bottom - this.top; - }; - ; - Bounds.prototype.getCentre = function () { - var w = this.getWidth(); - var h = this.getHeight(); - return pointPool_1.PointPool.instance.borrow(this.left + (w / 2), this.top + (h / 2)); - }; - ; - return Bounds; -}()); -exports.Bounds = Bounds; -//# sourceMappingURL=bounds.js.map \ No newline at end of file diff --git a/src/model/bounds.js.map b/src/model/bounds.js.map deleted file mode 100644 index 9fa72e9f..00000000 --- a/src/model/bounds.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bounds.js","sourceRoot":"","sources":["bounds.ts"],"names":[],"mappings":";AACA,0BAAwB,aAAa,CAAC,CAAA;AAEtC;IAOI,gBAAY,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,MAAc;QAC3D,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,GAAG,CAAC,CAAC;QACV,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,GAAG,CAAC,CAAC;QACV,CAAC;QACD,EAAE,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,KAAK,GAAG,CAAC,CAAC;QACd,CAAC;QACD,EAAE,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,MAAM,GAAG,CAAC,CAAC;QACf,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED,yBAAQ,GAAR;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;IAClC,CAAC;;IAED,0BAAS,GAAT;QACI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;IAClC,CAAC;;IAED,0BAAS,GAAT;QACI,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACzB,MAAM,CAAC,qBAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;;IACL,aAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,cAAM,SAuClB,CAAA"} \ No newline at end of file diff --git a/src/model/bounds.ts b/src/model/bounds.ts index fa287769..4f8921a0 100644 --- a/src/model/bounds.ts +++ b/src/model/bounds.ts @@ -1,14 +1,14 @@ -import {Point} from './point'; -import {PointPool} from './pointPool'; +import {Point} from "./point"; +import {PointPool} from "./pointPool"; export class Bounds { - left:number; - right:number; - top:number; - bottom:number; + public left: number; + public right: number; + public top: number; + public bottom: number; - constructor(x?:number, y?:number, width?:number, height?:number) { + constructor(x?: number, y?: number, width?: number, height?: number) { if (x === void 0) { x = 0; } @@ -27,17 +27,17 @@ export class Bounds { this.bottom = y + height; } - getWidth():number { + public get width(): number { return this.right - this.left; }; - getHeight():number { + public get height(): number { return this.bottom - this.top; }; - getCentre():Point { - var w = this.getWidth(); - var h = this.getHeight(); + public getCentre(): Point { + let w = this.width; + let h = this.height; return PointPool.instance.borrow(this.left + (w / 2), this.top + (h / 2)); }; } diff --git a/src/model/cornerMarker.d.ts b/src/model/cornerMarker.d.ts deleted file mode 100644 index adecd35c..00000000 --- a/src/model/cornerMarker.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Handle } from './handle'; -export declare class CornerMarker extends Handle { - private horizontalNeighbour; - private verticalNeighbour; - drawCornerBorder(ctx: any): void; - drawCornerFill(ctx: any): void; - moveX(x: number): void; - moveY(y: number): void; - move(x: number, y: number): void; - addHorizontalNeighbour(neighbour: CornerMarker): void; - addVerticalNeighbour(neighbour: CornerMarker): void; - getHorizontalNeighbour(): CornerMarker; - getVerticalNeighbour(): CornerMarker; - draw(ctx: any): void; -} diff --git a/src/model/cornerMarker.js b/src/model/cornerMarker.js deleted file mode 100644 index 66bb2b9d..00000000 --- a/src/model/cornerMarker.js +++ /dev/null @@ -1,103 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var handle_1 = require('./handle'); -var CornerMarker = (function (_super) { - __extends(CornerMarker, _super); - function CornerMarker() { - _super.apply(this, arguments); - } - CornerMarker.prototype.drawCornerBorder = function (ctx) { - var sideLength = 10; - if (this.over || this.drag) { - sideLength = 12; - } - var hDirection = 1; - var vDirection = 1; - if (this.horizontalNeighbour.position.x < this.position.x) { - hDirection = -1; - } - if (this.verticalNeighbour.position.y < this.position.y) { - vDirection = -1; - } - if (this.cropperSettings.rounded) { - var width = this.position.x - this.horizontalNeighbour.position.x; - var height = this.position.y - this.verticalNeighbour.position.y; - var offX = Math.round(Math.sin(Math.PI / 2) * Math.abs(width / 2)) / 4; - var offY = Math.round(Math.sin(Math.PI / 2) * Math.abs(height / 2)) / 4; - this.offset.x = hDirection > 0 ? offX : -offX; - this.offset.y = vDirection > 0 ? offY : -offY; - } - else { - this.offset.x = 0; - this.offset.y = 0; - } - ctx.beginPath(); - ctx.lineJoin = "miter"; - ctx.moveTo(this.position.x + this.offset.x, this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + (sideLength * vDirection)); - ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y + (sideLength * vDirection)); - ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y); - ctx.closePath(); - ctx.lineWidth = this.cropperSettings.cropperDrawSettings.strokeWidth; - ctx.strokeStyle = this.cropperSettings.cropperDrawSettings.strokeColor; - ctx.stroke(); - }; - CornerMarker.prototype.drawCornerFill = function (ctx) { - var sideLength = 10; - if (this.over || this.drag) { - sideLength = 12; - } - var hDirection = 1; - var vDirection = 1; - if (this.horizontalNeighbour.position.x < this.position.x) { - hDirection = -1; - } - if (this.verticalNeighbour.position.y < this.position.y) { - vDirection = -1; - } - ctx.beginPath(); - ctx.moveTo(this.position.x + this.offset.x, this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + (sideLength * vDirection)); - ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y + (sideLength * vDirection)); - ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y); - ctx.closePath(); - ctx.fillStyle = 'rgba(0,0,0,1)'; - ctx.fill(); - }; - CornerMarker.prototype.moveX = function (x) { - this.setPosition(x, this.position.y); - }; - CornerMarker.prototype.moveY = function (y) { - this.setPosition(this.position.x, y); - }; - CornerMarker.prototype.move = function (x, y) { - this.setPosition(x, y); - this.verticalNeighbour.moveX(x); - this.horizontalNeighbour.moveY(y); - }; - CornerMarker.prototype.addHorizontalNeighbour = function (neighbour) { - this.horizontalNeighbour = neighbour; - }; - CornerMarker.prototype.addVerticalNeighbour = function (neighbour) { - this.verticalNeighbour = neighbour; - }; - CornerMarker.prototype.getHorizontalNeighbour = function () { - return this.horizontalNeighbour; - }; - CornerMarker.prototype.getVerticalNeighbour = function () { - return this.verticalNeighbour; - }; - CornerMarker.prototype.draw = function (ctx) { - this.drawCornerFill(ctx); - this.drawCornerBorder(ctx); - }; - return CornerMarker; -}(handle_1.Handle)); -exports.CornerMarker = CornerMarker; -//# sourceMappingURL=cornerMarker.js.map \ No newline at end of file diff --git a/src/model/cornerMarker.js.map b/src/model/cornerMarker.js.map deleted file mode 100644 index 4161faaa..00000000 --- a/src/model/cornerMarker.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cornerMarker.js","sourceRoot":"","sources":["cornerMarker.ts"],"names":[],"mappings":";;;;;;AAAA,uBAAqB,UAAU,CAAC,CAAA;AAKhC;IAAkC,gCAAM;IAAxC;QAAkC,8BAAM;IA0GxC,CAAC;IArGG,uCAAgB,GAAhB,UAAiB,GAAO;QACpB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACzB,UAAU,GAAG,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,UAAU,GAAG,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,UAAU,GAAG,CAAC,CAA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ACvC,CAAC;IAED,6CAAsB,GAAtB;QACI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED,2CAAoB,GAApB;QACI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAED,2BAAI,GAAJ,UAAK,GAAO;QACR,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAEL,mBAAC;AAAD,CAAC,AA1GD,CAAkC,eAAM,GA0GvC;AA1GY,oBAAY,eA0GxB,CAAA"} \ No newline at end of file diff --git a/src/model/cornerMarker.ts b/src/model/cornerMarker.ts index 9b8f9d48..7e16a953 100644 --- a/src/model/cornerMarker.ts +++ b/src/model/cornerMarker.ts @@ -1,21 +1,28 @@ -import {Handle} from './handle'; -import {PointPool} from './pointPool'; -import {Point} from './point'; -import {CropperDrawSettings} from "../cropperDrawSettings"; +import {Handle, IHandle} from "./handle"; +import {CropperSettings} from "../cropperSettings"; -export class CornerMarker extends Handle { +export interface ICornerMarker extends IHandle { + horizontalNeighbour: CornerMarker; + verticalNeighbour: CornerMarker; +} + +export class CornerMarker extends Handle implements ICornerMarker { - private horizontalNeighbour:CornerMarker; - private verticalNeighbour:CornerMarker; + public horizontalNeighbour: CornerMarker; + public verticalNeighbour: CornerMarker; + + constructor(x: number, y: number, radius: number, cropperSettings: CropperSettings) { + super(x, y, radius, cropperSettings); + } - drawCornerBorder(ctx:any):void { - var sideLength = 10; + public drawCornerBorder(ctx: CanvasRenderingContext2D): void { + let sideLength: number = 10; if (this.over || this.drag) { sideLength = 12; } - var hDirection = 1; - var vDirection = 1; + let hDirection: number = 1; + let vDirection: number = 1; if (this.horizontalNeighbour.position.x < this.position.x) { hDirection = -1; } @@ -24,11 +31,11 @@ export class CornerMarker extends Handle { } if (this.cropperSettings.rounded) { - var width = this.position.x - this.horizontalNeighbour.position.x; - var height = this.position.y - this.verticalNeighbour.position.y; + let width: number = this.position.x - this.horizontalNeighbour.position.x; + let height: number = this.position.y - this.verticalNeighbour.position.y; - var offX = Math.round(Math.sin(Math.PI / 2) * Math.abs(width/2)) / 4; - var offY = Math.round(Math.sin(Math.PI / 2) * Math.abs(height/2)) / 4; + let offX: number = Math.round(Math.sin(Math.PI / 2) * Math.abs(width / 2)) / 4; + let offY: number = Math.round(Math.sin(Math.PI / 2) * Math.abs(height / 2)) / 4; this.offset.x = hDirection > 0 ? offX : -offX; this.offset.y = vDirection > 0 ? offY : -offY; @@ -41,7 +48,8 @@ export class CornerMarker extends Handle { ctx.lineJoin = "miter"; ctx.moveTo(this.position.x + this.offset.x, this.position.y + this.offset.y); ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + (sideLength * vDirection)); + ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + + (sideLength * vDirection)); ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y + (sideLength * vDirection)); ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y); ctx.closePath(); @@ -50,13 +58,13 @@ export class CornerMarker extends Handle { ctx.stroke(); } - drawCornerFill(ctx:any):void { - var sideLength = 10; + public drawCornerFill(ctx: CanvasRenderingContext2D): void { + let sideLength: number = 10; if (this.over || this.drag) { sideLength = 12; } - var hDirection = 1; - var vDirection = 1; + let hDirection: number = 1; + let vDirection: number = 1; if (this.horizontalNeighbour.position.x < this.position.x) { hDirection = -1; } @@ -66,45 +74,46 @@ export class CornerMarker extends Handle { ctx.beginPath(); ctx.moveTo(this.position.x + this.offset.x, this.position.y + this.offset.y); ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y); - ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + (sideLength * vDirection)); + ctx.lineTo(this.position.x + this.offset.x + (sideLength * hDirection), this.position.y + this.offset.y + + (sideLength * vDirection)); ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y + (sideLength * vDirection)); ctx.lineTo(this.position.x + this.offset.x, this.position.y + this.offset.y); ctx.closePath(); - ctx.fillStyle = 'rgba(0,0,0,1)'; + ctx.fillStyle = "rgba(255,255,255,.7)"; ctx.fill(); } - moveX(x:number):void { + public moveX(x: number): void { this.setPosition(x, this.position.y); } - moveY(y:number):void { + public moveY(y: number): void { this.setPosition(this.position.x, y); } - move(x:number, y:number):void { + public move(x: number, y: number): void { this.setPosition(x, y); this.verticalNeighbour.moveX(x); this.horizontalNeighbour.moveY(y); } - addHorizontalNeighbour(neighbour:CornerMarker):void { + public addHorizontalNeighbour(neighbour: CornerMarker): void { this.horizontalNeighbour = neighbour; } - addVerticalNeighbour(neighbour:CornerMarker):void { + public addVerticalNeighbour(neighbour: CornerMarker): void { this.verticalNeighbour = neighbour; } - getHorizontalNeighbour():CornerMarker { + public getHorizontalNeighbour(): CornerMarker { return this.horizontalNeighbour; } - getVerticalNeighbour():CornerMarker { + public getVerticalNeighbour(): CornerMarker { return this.verticalNeighbour; } - draw(ctx:any):void { + public draw(ctx: CanvasRenderingContext2D): void { this.drawCornerFill(ctx); this.drawCornerBorder(ctx); } diff --git a/src/model/cropService.d.ts b/src/model/cropService.d.ts deleted file mode 100644 index 439f3e6d..00000000 --- a/src/model/cropService.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare class CropService { - canvas:any; - ctx:any; - DEG2RAD:number; - - init(canvas:any):void; -} diff --git a/src/model/cropService.js b/src/model/cropService.js deleted file mode 100644 index 025d235b..00000000 --- a/src/model/cropService.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var CropService = (function () { - function CropService() { - this.DEG2RAD = 0.0174532925; - } - - CropService.prototype.init = function (canvas) { - this.canvas = canvas; - this.ctx = this.canvas.getContext("2d"); - }; - ; - return CropService; -}()); -exports.CropService = CropService; -//# sourceMappingURL=cropService.js.map \ No newline at end of file diff --git a/src/model/cropService.js.map b/src/model/cropService.js.map deleted file mode 100644 index a49f3d08..00000000 --- a/src/model/cropService.js.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "cropService.js", - "sourceRoot": "", - "sources": [ - "cropService.ts" - ], - "names": [], - "mappings": ";AAAA;IAAA;QAIE,YAAO,GAAG,YAAY,CAAC;IAOzB,CAAC;IALC,0BAAI,GAAJ,UAAK,MAAM;QACT,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;;IAEH,kBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,mBAAW,cAWvB,CAAA" -} \ No newline at end of file diff --git a/src/model/cropService.ts b/src/model/cropService.ts index c959799b..835c8e47 100644 --- a/src/model/cropService.ts +++ b/src/model/cropService.ts @@ -1,12 +1,13 @@ export class CropService { - canvas:any; - ctx:any; - DEG2RAD = 0.0174532925; + public canvas: HTMLCanvasElement; + public ctx: CanvasRenderingContext2D; - init(canvas) { + // todo: Unused? + public static DEG2RAD = 0.0174532925; + + public init(canvas: HTMLCanvasElement) { this.canvas = canvas; this.ctx = this.canvas.getContext("2d"); }; - -} +} \ No newline at end of file diff --git a/src/model/cropTouch.d.ts b/src/model/cropTouch.d.ts deleted file mode 100644 index 83c4a840..00000000 --- a/src/model/cropTouch.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare class CropTouch { - x: number; - y: number; - id: number; - constructor(x: number, y: number, id: number); -} diff --git a/src/model/cropTouch.js b/src/model/cropTouch.js deleted file mode 100644 index cc85cd80..00000000 --- a/src/model/cropTouch.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var CropTouch = (function () { - function CropTouch(x, y, id) { - if (x === void 0) { - x = 0; - } - if (y === void 0) { - y = 0; - } - if (id === void 0) { - id = 0; - } - this.id = 0; - this.x = x; - this.y = y; - this.id = id; - } - return CropTouch; -}()); -exports.CropTouch = CropTouch; -//# sourceMappingURL=cropTouch.js.map \ No newline at end of file diff --git a/src/model/cropTouch.js.map b/src/model/cropTouch.js.map deleted file mode 100644 index a675ace2..00000000 --- a/src/model/cropTouch.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cropTouch.js","sourceRoot":"","sources":["cropTouch.ts"],"names":[],"mappings":";AAAA;IAMI,mBAAY,CAAQ,EAAE,CAAQ,EAAE,EAAS;QACrC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,GAAG,CAAC,CAAC;QACV,CAAC;QACD,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,GAAG,CAAC,CAAC;QACV,CAAC;QACD,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YAChB,EAAE,GAAG,CAAC,CAAC;QACX,CAAC;QACD,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACjB,CAAC;IAEL,gBAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,iBAAS,YAsBrB,CAAA"} \ No newline at end of file diff --git a/src/model/cropTouch.ts b/src/model/cropTouch.ts index da925399..c3626956 100644 --- a/src/model/cropTouch.ts +++ b/src/model/cropTouch.ts @@ -1,23 +1,18 @@ +import {DragMarker} from "./dragMarker"; +import {CornerMarker} from "./cornerMarker"; + export class CropTouch { - x:number; - y:number; - id:number; + public x: number; + public y: number; + public id: number; - constructor(x:number, y:number, id:number) { - if (x === void 0) { - x = 0; - } - if (y === void 0) { - y = 0; - } - if (id === void 0) { - id = 0; - } - this.id = 0; - this.x = x; - this.y = y; - this.id = id; - } + public dragHandle: CornerMarker | DragMarker; + constructor(x: number, y: number, id: number) { + this.id = id || 0; + this.x = x || 0; + this.y = y || 0; + this.dragHandle = null; + } } diff --git a/src/model/dragMarker.d.ts b/src/model/dragMarker.d.ts deleted file mode 100644 index c68f6cb5..00000000 --- a/src/model/dragMarker.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Handle } from './handle'; -import { Point } from './point'; -import { CropperSettings } from "../cropperSettings"; -export declare class DragMarker extends Handle { - iconPoints: Array; - scaledIconPoints: Array; - constructor(x: number, y: number, radius: number, cropperSettings: CropperSettings); - draw(ctx: any): void; - getDragIconPoints(arr: Array, scale: number): void; - drawIcon(ctx: any, points: Array): void; - recalculatePosition(bounds: any): void; -} diff --git a/src/model/dragMarker.js b/src/model/dragMarker.js deleted file mode 100644 index 4f1b2c16..00000000 --- a/src/model/dragMarker.js +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var handle_1 = require('./handle'); -var pointPool_1 = require('./pointPool'); -var DragMarker = (function (_super) { - __extends(DragMarker, _super); - function DragMarker(x, y, radius, cropperSettings) { - _super.call(this, x, y, radius, cropperSettings); - this.iconPoints = []; - this.scaledIconPoints = []; - this.getDragIconPoints(this.iconPoints, 1); - this.getDragIconPoints(this.scaledIconPoints, 1.2); - } - DragMarker.prototype.draw = function (ctx) { - if (this.over || this.drag) { - this.drawIcon(ctx, this.scaledIconPoints); - } - else { - this.drawIcon(ctx, this.iconPoints); - } - }; - DragMarker.prototype.getDragIconPoints = function (arr, scale) { - var maxLength = 17 * scale; - var arrowWidth = 14 * scale; - var arrowLength = 8 * scale; - var connectorThroat = 4 * scale; - arr.push(pointPool_1.PointPool.instance.borrow(-connectorThroat / 2, maxLength - arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(-arrowWidth / 2, maxLength - arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(0, maxLength)); - arr.push(pointPool_1.PointPool.instance.borrow(arrowWidth / 2, maxLength - arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(connectorThroat / 2, maxLength - arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(connectorThroat / 2, connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(maxLength - arrowLength, connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(maxLength - arrowLength, arrowWidth / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(maxLength, 0)); - arr.push(pointPool_1.PointPool.instance.borrow(maxLength - arrowLength, -arrowWidth / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(maxLength - arrowLength, -connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(connectorThroat / 2, -connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(connectorThroat / 2, -maxLength + arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(arrowWidth / 2, -maxLength + arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(0, -maxLength)); - arr.push(pointPool_1.PointPool.instance.borrow(-arrowWidth / 2, -maxLength + arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(-connectorThroat / 2, -maxLength + arrowLength)); - arr.push(pointPool_1.PointPool.instance.borrow(-connectorThroat / 2, -connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(-maxLength + arrowLength, -connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(-maxLength + arrowLength, -arrowWidth / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(-maxLength, 0)); - arr.push(pointPool_1.PointPool.instance.borrow(-maxLength + arrowLength, arrowWidth / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(-maxLength + arrowLength, connectorThroat / 2)); - arr.push(pointPool_1.PointPool.instance.borrow(-connectorThroat / 2, connectorThroat / 2)); - }; - DragMarker.prototype.drawIcon = function (ctx, points) { - ctx.beginPath(); - ctx.moveTo(points[0].x + this.position.x, points[0].y + this.position.y); - for (var k = 0; k < points.length; k++) { - var p = points[k]; - ctx.lineTo(p.x + this.position.x, p.y + this.position.y); - } - ctx.closePath(); - ctx.fillStyle = this.cropperSettings.cropperDrawSettings.strokeColor; - ctx.fill(); - }; - DragMarker.prototype.recalculatePosition = function (bounds) { - var c = bounds.getCentre(); - this.setPosition(c.x, c.y); - pointPool_1.PointPool.instance.returnPoint(c); - }; - return DragMarker; -}(handle_1.Handle)); -exports.DragMarker = DragMarker; -//# sourceMappingURL=dragMarker.js.map \ No newline at end of file diff --git a/src/model/dragMarker.js.map b/src/model/dragMarker.js.map deleted file mode 100644 index 26a11589..00000000 --- a/src/model/dragMarker.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dragMarker.js","sourceRoot":"","sources":["dragMarker.ts"],"names":[],"mappings":";;;;;;AAAA,uBAAqB,UAAU,CAAC,CAAA;AAChC,0BAAwB,aAAa,CAAC,CAAA;AAItC;IAAgC,8BAAM;IAKlC,oBAAY,CAAQ,EAAE,CAAQ,EAAE,MAAa,EAAE,eAAgC;QAC3E,kBAAM,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAED,yBAAI,GAAJ,UAAK,GAAG;QACJ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,gBAAg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I,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACzE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAClB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,WAAW,CAAC;QACrE,GAAG,CAAC,IAAI,EAAE,CAAC;IACf,CAAC;IAED,wCAAmB,GAAnB,UAAoB,MAAM;QAEtB,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,qBAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAEL,iBAAC;AAAD,CAAC,AAzED,CAAgC,eAAM,GAyErC;AAzEY,kBAAU,aAyEtB,CAAA"} \ No newline at end of file diff --git a/src/model/dragMarker.ts b/src/model/dragMarker.ts index 6644adf0..057b1fc3 100644 --- a/src/model/dragMarker.ts +++ b/src/model/dragMarker.ts @@ -1,14 +1,15 @@ -import {Handle} from './handle'; -import {PointPool} from './pointPool'; -import {Point} from './point'; +import {Handle} from "./handle"; +import {PointPool} from "./pointPool"; +import {Point} from "./point"; import {CropperSettings} from "../cropperSettings"; +import {Bounds} from "./bounds"; export class DragMarker extends Handle { - iconPoints:Array; - scaledIconPoints:Array; + private iconPoints: Array; + private scaledIconPoints: Array; - constructor(x:number, y:number, radius:number, cropperSettings: CropperSettings) { + constructor(x: number, y: number, radius: number, cropperSettings: CropperSettings) { super(x, y, radius, cropperSettings); this.iconPoints = []; this.scaledIconPoints = []; @@ -16,20 +17,19 @@ export class DragMarker extends Handle { this.getDragIconPoints(this.scaledIconPoints, 1.2); } - draw(ctx) { + public draw(ctx: CanvasRenderingContext2D) { if (this.over || this.drag) { this.drawIcon(ctx, this.scaledIconPoints); - } - else { + } else { this.drawIcon(ctx, this.iconPoints); } } - getDragIconPoints(arr:Array, scale:number) { - var maxLength = 17 * scale; - var arrowWidth = 14 * scale; - var arrowLength = 8 * scale; - var connectorThroat = 4 * scale; + public getDragIconPoints(arr: Array, scale: number) { + let maxLength = 17 * scale; + let arrowWidth = 14 * scale; + let arrowLength = 8 * scale; + let connectorThroat = 4 * scale; arr.push(PointPool.instance.borrow(-connectorThroat / 2, maxLength - arrowLength)); arr.push(PointPool.instance.borrow(-arrowWidth / 2, maxLength - arrowLength)); @@ -57,11 +57,11 @@ export class DragMarker extends Handle { arr.push(PointPool.instance.borrow(-connectorThroat / 2, connectorThroat / 2)); } - drawIcon(ctx:any, points:Array) { + public drawIcon(ctx: CanvasRenderingContext2D, points: Array) { ctx.beginPath(); ctx.moveTo(points[0].x + this.position.x, points[0].y + this.position.y); - for (var k = 0; k < points.length; k++) { - var p = points[k]; + for (let k = 0; k < points.length; k++) { + let p = points[k]; ctx.lineTo(p.x + this.position.x, p.y + this.position.y); } ctx.closePath(); @@ -69,9 +69,8 @@ export class DragMarker extends Handle { ctx.fill(); } - recalculatePosition(bounds) { - - var c = bounds.getCentre(); + public recalculatePosition(bounds: Bounds) { + let c = bounds.getCentre(); this.setPosition(c.x, c.y); PointPool.instance.returnPoint(c); } diff --git a/src/model/handle.d.ts b/src/model/handle.d.ts deleted file mode 100644 index 2228637d..00000000 --- a/src/model/handle.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Point } from './point'; -import { CropperSettings } from "../cropperSettings"; -export declare class Handle { - protected cropperSettings: CropperSettings; - over: Boolean; - drag: Boolean; - position: Point; - offset: Point; - radius: number; - constructor(x: any, y: any, radius: any, cropperSettings: CropperSettings); - setDrag(value: any): void; - draw(ctx: any): void; - setOver(over: any): void; - touchInBounds(x: any, y: any): boolean; - getPosition(): Point; - setPosition(x: any, y: any): void; -} diff --git a/src/model/handle.js b/src/model/handle.js deleted file mode 100644 index 9d64c5a9..00000000 --- a/src/model/handle.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -var point_1 = require('./point'); -var Handle = (function () { - function Handle(x, y, radius, cropperSettings) { - this.cropperSettings = cropperSettings; - this.over = false; - this.drag = false; - this.position = new point_1.Point(x, y); - this.offset = new point_1.Point(0, 0); - this.radius = radius; - } - Handle.prototype.setDrag = function (value) { - this.drag = value; - this.setOver(value); - }; - Handle.prototype.draw = function (ctx) { - }; - Handle.prototype.setOver = function (over) { - this.over = over; - }; - Handle.prototype.touchInBounds = function (x, y) { - return (x > this.position.x - this.radius + this.offset.x && - x < this.position.x + this.radius + this.offset.x && - y > this.position.y - this.radius + this.offset.y && - y < this.position.y + this.radius + this.offset.y); - }; - Handle.prototype.getPosition = function () { - return this.position; - }; - Handle.prototype.setPosition = function (x, y) { - this.position.x = x; - this.position.y = y; - }; - return Handle; -}()); -exports.Handle = Handle; -//# sourceMappingURL=handle.js.map \ No newline at end of file diff --git a/src/model/handle.js.map b/src/model/handle.js.map deleted file mode 100644 index a026a664..00000000 --- a/src/model/handle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"handle.js","sourceRoot":"","sources":["handle.ts"],"names":[],"mappings":";AAAA,sBAAoB,SAAS,CAAC,CAAA;AAG9B;IAQI,gBAAY,CAAC,EAAE,CAAC,EAAE,MAAM,EAAY,eAA+B;QAA/B,oBAAe,GAAf,eAAe,CAAgB;QAC/D,IAAI,CAAC,IAAI,GAA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AAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAEL,aAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,cAAM,SA6ClB,CAAA"} \ No newline at end of file diff --git a/src/model/handle.ts b/src/model/handle.ts index faa9293a..0ed4654d 100644 --- a/src/model/handle.ts +++ b/src/model/handle.ts @@ -1,49 +1,65 @@ -import {Point} from './point'; +import {Point} from "./point"; import {CropperSettings} from "../cropperSettings"; -export class Handle { +export interface IHandle { + over: boolean; + drag: boolean; + position: Point; + setPosition(x: number, y: number): void; + offset: Point; + radius: number; + cropperSettings: CropperSettings; + setDrag(value: boolean): void; + draw(ctx: CanvasRenderingContext2D): void; + setOver(over: boolean): void; + touchInBounds(x: number, y: number): boolean; +} + +export class Handle implements IHandle { + public over: boolean; + public drag: boolean; + private _position: Point; + public offset: Point; + public radius: number; - over:Boolean; - drag:Boolean; - position:Point; - offset:Point; - radius:number; + public cropperSettings: CropperSettings = new CropperSettings(); - constructor(x, y, radius, protected cropperSettings:CropperSettings) { + constructor(x: number, y: number, radius: number, settings: CropperSettings) { this.over = false; this.drag = false; - this.position = new Point(x, y); + this._position = new Point(x, y); this.offset = new Point(0, 0); this.radius = radius; + this.cropperSettings = settings; } - setDrag(value) { + public setDrag(value: boolean) { this.drag = value; this.setOver(value); } - draw(ctx) { + public draw(ctx: CanvasRenderingContext2D) { + // this should't be empty } - setOver(over) { + public setOver(over: boolean): void { this.over = over; } - touchInBounds(x, y) { - return ( - x > this.position.x - this.radius + this.offset.x && - x < this.position.x + this.radius + this.offset.x && - y > this.position.y - this.radius + this.offset.y && - y < this.position.y + this.radius + this.offset.y ); + public touchInBounds(x: number, y: number): boolean { + return (x > this.position.x - this.radius + this.offset.x) && + (x < this.position.x + this.radius + this.offset.x) && + (y > this.position.y - this.radius + this.offset.y) && + (y < this.position.y + this.radius + this.offset.y); } - getPosition() { - return this.position; + public get position(): Point { + return this._position; } - setPosition(x, y) { - this.position.x = x; - this.position.y = y; + public setPosition(x: number, y: number) { + this._position.x = x; + this._position.y = y; } } diff --git a/src/model/imageCropperModel.d.ts b/src/model/imageCropperModel.d.ts deleted file mode 100644 index e8108a15..00000000 --- a/src/model/imageCropperModel.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PointPool } from "./pointPool"; -import { CornerMarker } from "./cornerMarker"; -import { DragMarker } from "./dragMarker"; -export declare class ImageCropperModel { - protected canvas: HTMLCanvasElement; - protected x: number; - protected y: number; - protected width: number; - protected height: number; - protected canvasWidth: number; - protected canvasHeight: number; - protected keepAspect: boolean; - protected touchRadius: number; - protected currentDragTouches: Array; - protected isMouseDown: boolean; - protected ratioW: number; - protected ratioH: number; - protected fileType: string; - protected imageSet: boolean; - protected pointPool: PointPool; - protected buffer: HTMLCanvasElement; - protected cropCanvas: HTMLCanvasElement; - tl: CornerMarker; - tr: CornerMarker; - bl: CornerMarker; - br: CornerMarker; - markers: Array; - protected center: DragMarker; - protected ctx: any; - protected aspectRatio: number; - protected currentlyInteracting: boolean; - protected srcImage: ImageData; - protected vertSquashRatio: number; - protected minXClamp: number; - protected minYClamp: number; - protected maxXClamp: number; - protected maxYClamp: number; - protected minHeight: number; - protected minWidth: number; - protected cropWidth: number; - protected cropHeight: number; - protected croppedImage: HTMLImageElement; -} diff --git a/src/model/imageCropperModel.js b/src/model/imageCropperModel.js deleted file mode 100644 index 6325ee6d..00000000 --- a/src/model/imageCropperModel.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -var ImageCropperModel = (function () { - function ImageCropperModel() { - } - return ImageCropperModel; -}()); -exports.ImageCropperModel = ImageCropperModel; -//# sourceMappingURL=imageCropperModel.js.map \ No newline at end of file diff --git a/src/model/imageCropperModel.js.map b/src/model/imageCropperModel.js.map deleted file mode 100644 index 262671ad..00000000 --- a/src/model/imageCropperModel.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"imageCropperModel.js","sourceRoot":"","sources":["imageCropperModel.ts"],"names":[],"mappings":";AAIA;IAAA;IAuCA,CAAC;IAAD,wBAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,yBAAiB,oBAuC7B,CAAA"} \ No newline at end of file diff --git a/src/model/imageCropperModel.ts b/src/model/imageCropperModel.ts index dfe42943..a00da66c 100644 --- a/src/model/imageCropperModel.ts +++ b/src/model/imageCropperModel.ts @@ -1,44 +1,45 @@ import {PointPool} from "./pointPool"; import {CornerMarker} from "./cornerMarker"; import {DragMarker} from "./dragMarker"; +import {CropTouch} from "./cropTouch"; export class ImageCropperModel { - protected canvas:HTMLCanvasElement; - protected x:number; - protected y:number; - protected width:number; - protected height:number; - protected canvasWidth:number; - protected canvasHeight:number; - protected keepAspect:boolean; - protected touchRadius:number; - protected currentDragTouches:Array; - protected isMouseDown:boolean; - protected ratioW:number; - protected ratioH:number; - protected fileType:string; - protected imageSet:boolean; - protected pointPool:PointPool; - protected buffer:HTMLCanvasElement; - protected cropCanvas:HTMLCanvasElement; - tl:CornerMarker; - tr:CornerMarker; - bl:CornerMarker; - br:CornerMarker; - markers:Array; - protected center:DragMarker; - protected ctx:any; - protected aspectRatio:number; - protected currentlyInteracting:boolean; - protected srcImage:ImageData; - protected vertSquashRatio:number; - protected minXClamp:number; - protected minYClamp:number; - protected maxXClamp:number; - protected maxYClamp:number; - protected minHeight:number; - protected minWidth:number; - protected cropWidth:number; - protected cropHeight:number; - protected croppedImage:HTMLImageElement; -} \ No newline at end of file + protected canvas: HTMLCanvasElement; + protected x: number; + protected y: number; + protected width: number; + protected height: number; + protected canvasWidth: number; + protected canvasHeight: number; + protected keepAspect: boolean; + protected touchRadius: number; + protected currentDragTouches: Array; + protected isMouseDown: boolean; + protected ratioW: number; + protected ratioH: number; + protected fileType: string; + protected imageSet: boolean; + protected pointPool: PointPool; + protected buffer: HTMLCanvasElement; + protected cropCanvas: HTMLCanvasElement; + protected tl: CornerMarker; + protected tr: CornerMarker; + protected bl: CornerMarker; + protected br: CornerMarker; + protected markers: Array; + protected center: DragMarker; + protected ctx: CanvasRenderingContext2D; + protected aspectRatio: number; + protected currentlyInteracting: boolean; + protected srcImage: HTMLImageElement; + protected vertSquashRatio: number; + protected minXClamp: number; + protected minYClamp: number; + protected maxXClamp: number; + protected maxYClamp: number; + protected minHeight: number; + protected minWidth: number; + protected cropWidth: number; + protected cropHeight: number; + protected croppedImage: HTMLImageElement; +} diff --git a/src/model/point.d.ts b/src/model/point.d.ts deleted file mode 100644 index 5a72b689..00000000 --- a/src/model/point.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export declare class Point { - x: number; - y: number; - private _next; - private _prev; - constructor(x?: number, y?: number); - getNext(): Point; - setNext(p: Point): void; - getPrev(): Point; - setPrev(p: Point): void; -} diff --git a/src/model/point.js b/src/model/point.js deleted file mode 100644 index 9341979f..00000000 --- a/src/model/point.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var Point = (function () { - function Point(x, y) { - this.x = x; - this.y = y; - } - Point.prototype.getNext = function () { - return this._next; - }; - Point.prototype.setNext = function (p) { - this._next = p; - }; - Point.prototype.getPrev = function () { - return this._prev; - }; - Point.prototype.setPrev = function (p) { - this._prev = p; - }; - return Point; -}()); -exports.Point = Point; -//# sourceMappingURL=point.js.map \ No newline at end of file diff --git a/src/model/point.js.map b/src/model/point.js.map deleted file mode 100644 index d7c2b148..00000000 --- a/src/model/point.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"point.js","sourceRoot":"","sources":["point.ts"],"names":[],"mappings":";AAAA;IASI,eAAY,CAAS,EAAE,CAAS;QAC5B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED,uBAAO,GAAP;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,uBAAO,GAAP,UAAQ,CAAO;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,uBAAO,GAAP;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,uBAAO,GAAP,UAAQ,CAAO;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IAGL,YAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,aAAK,QA+BjB,CAAA"} \ No newline at end of file diff --git a/src/model/point.ts b/src/model/point.ts index 19f39b42..affeacd9 100644 --- a/src/model/point.ts +++ b/src/model/point.ts @@ -1,32 +1,36 @@ -export class Point { +export interface IPoint { + x: number; + y: number; + next: Point; + prev: Point; +} - public x:number; - public y:number; +export class Point implements IPoint { - private _next:Point; - private _prev:Point; + public x: number; + public y: number; + private _next: Point; + private _prev: Point; - constructor(x?:number, y?:number) { + constructor(x?: number, y?: number) { this.x = x; this.y = y; } - getNext():Point { + public get next(): Point { return this._next; } - setNext(p:Point) { + public set next(p: Point) { this._next = p; } - getPrev():Point { + public get prev(): Point { return this._prev; } - setPrev(p:Point) { + public set prev(p: Point) { this._prev = p; } - - } diff --git a/src/model/pointPool.d.ts b/src/model/pointPool.d.ts deleted file mode 100644 index 576cc478..00000000 --- a/src/model/pointPool.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Point } from './point'; -export declare class PointPool { - private static _instance; - private borrowed; - private firstAvailable; - constructor(initialSize: any); - static instance: PointPool; - borrow(x: any, y: any): Point; - returnPoint(p: Point): void; -} diff --git a/src/model/pointPool.js b/src/model/pointPool.js deleted file mode 100644 index 5c647e33..00000000 --- a/src/model/pointPool.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -var point_1 = require('./point'); -var PointPool = (function () { - function PointPool(initialSize) { - PointPool._instance = this; - var prev = null; - for (var i = 0; i < initialSize; i++) { - if (i === 0) { - this.firstAvailable = new point_1.Point(); - prev = this.firstAvailable; - } - else { - var p = new point_1.Point(); - prev.setNext(p); - prev = p; - } - } - } - Object.defineProperty(PointPool, "instance", { - get: function () { - return PointPool._instance; - }, - enumerable: true, - configurable: true - }); - PointPool.prototype.borrow = function (x, y) { - if (this.firstAvailable == null) { - throw "Pool exhausted"; - } - this.borrowed++; - var p = this.firstAvailable; - this.firstAvailable = p.getNext(); - p.x = x; - p.y = y; - return p; - }; - ; - PointPool.prototype.returnPoint = function (p) { - this.borrowed--; - p.x = 0; - p.y = 0; - p.setNext(this.firstAvailable); - this.firstAvailable = p; - }; - ; - return PointPool; -}()); -exports.PointPool = PointPool; -//# sourceMappingURL=pointPool.js.map \ No newline at end of file diff --git a/src/model/pointPool.js.map b/src/model/pointPool.js.map deleted file mode 100644 index bb5a6586..00000000 --- a/src/model/pointPool.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pointPool.js","sourceRoot":"","sources":["pointPool.ts"],"names":[],"mappings":";AAAA,sBAAoB,SAAS,CAAC,CAAA;AAE9B;IAOI,mBAAY,WAAW;QACnB,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACV,IAAI,CAAC,cAAc,GAAG,IAAI,aAAK,EAAE,CAAC;gBAClC,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC;YAC/B,CAAC;YACD,IAAI,CAAC,CAAC;gBACF,IAAI,CAAC,GAAG,IAAI,aAAK,EAAE,CAAC;gBACpB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAChB,IAAI,GAAG,CAAC,CAAC;YACb,CAAC;QACL,CAAC;IACL,CAAC;IAED,sBAAW,qBAAQ;aAAnB;YACI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QAC/B,CAAC;;;OAAA;IAEM,0BAAM,GAAb,UAAc,CAAC,EAAE,CAAC;QACd,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC;YAC9B,MAAM,gBAAgB,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACR,MAAM,CAAC,CAAC,CAAC;IACb,CAAC;;IAEM,+BAAW,GAAlB,UAAmB,CAAO;QACtB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACR,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;IAC5B,CAAC;;IACL,gBAAC;AAAD,CAAC,AA9CD,IA8CC;AA9CY,iBAAS,YA8CrB,CAAA"} \ No newline at end of file diff --git a/src/model/pointPool.ts b/src/model/pointPool.ts index 30777a84..0bcf06c5 100644 --- a/src/model/pointPool.ts +++ b/src/model/pointPool.ts @@ -1,49 +1,48 @@ -import {Point} from './point'; +import {Point} from "./point"; export class PointPool { - private static _instance:PointPool; + private static _instance: PointPool; - private borrowed:number; - private firstAvailable:Point; + private borrowed: number; + private firstAvailable: Point; - constructor(initialSize) { + constructor(initialSize: number) { PointPool._instance = this; - var prev = null; - for (var i = 0; i < initialSize; i++) { + let prev: Point = null; + for (let i = 0; i < initialSize; i++) { if (i === 0) { this.firstAvailable = new Point(); prev = this.firstAvailable; - } - else { - var p = new Point(); - prev.setNext(p); + } else { + let p = new Point(); + prev.next = p; prev = p; } } } - static get instance():PointPool { + static get instance(): PointPool { return PointPool._instance; } - public borrow(x, y):Point { + public borrow(x: number, y: number): Point { if (this.firstAvailable == null) { throw "Pool exhausted"; } this.borrowed++; - var p = this.firstAvailable; - this.firstAvailable = p.getNext(); + let p: Point = this.firstAvailable; + this.firstAvailable = p.next; p.x = x; p.y = y; return p; }; - public returnPoint(p:Point) { + public returnPoint(p: Point) { this.borrowed--; p.x = 0; p.y = 0; - p.setNext(this.firstAvailable); + p.next = this.firstAvailable; this.firstAvailable = p; }; } diff --git a/tsconfig.json b/tsconfig.json index 2ad28fc5..6420a353 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "removeComments": true, - "noImplicitAny": false, + "noImplicitAny": true, "module": "commonjs", "target": "es5", "emitDecoratorMetadata": true, diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..01150f5d --- /dev/null +++ b/tslint.json @@ -0,0 +1,23 @@ +{ + "extends": "tslint:latest", + "rules": { + "no-constructor-vars": true, + "ordered-imports": false, + "member-ordering": false, + "max-line-length": false, + "variable-name": false, + "only-arrow-functions": false, + "no-inferrable-types": true, + "one-variable-per-declaration": false, + "no-console": false, + "object-literal-sort-keys": false, + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ] + }, + "rulesDirectory": [] +} \ No newline at end of file