yeyouzi-cropper.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. // components/yeyouzi-cropper/yeyouzi-cropper.js
  2. let success;
  3. let fail;
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. canvas: '',
  15. ctx: '',
  16. dpr: '',
  17. x1: 0,
  18. y1: 0,
  19. x2: 0,
  20. y2: 0,
  21. k1: 0,
  22. m1: 0,
  23. k2: 0,
  24. m2: 0,
  25. cutMove: false,
  26. endCut: {
  27. x: 0,
  28. y: 0
  29. },
  30. movePoint: '0',
  31. img: {
  32. path: '',
  33. width: 0,
  34. height: 0,
  35. type: 1 // 1:横向 2:纵向
  36. },
  37. imageWidth: 0,
  38. imageHeight: 0,
  39. imageLeft: 0,
  40. imageTop: 0,
  41. imgRotate: 0,
  42. imgMirror: 0,
  43. originWidthShow: 0.5,
  44. originHeightShow: 0.5,
  45. imgMove: false,
  46. imgStart: {
  47. x: 0,
  48. y: 0,
  49. left: 0,
  50. top: 0,
  51. distance: 0,
  52. width: 0,
  53. height: 0,
  54. cutImg: ''
  55. },
  56. imgScale: false,
  57. cutImg: {
  58. path: '',
  59. x: 0,
  60. y: 0,
  61. width: 0,
  62. height: 0
  63. }
  64. },
  65. /**
  66. * 组件的方法列表
  67. */
  68. methods: {
  69. /**
  70. * 公有方法
  71. */
  72. //初始化
  73. init(param){
  74. success = param.success
  75. fail = param.fail
  76. var that = this;
  77. this.setData({
  78. img: {
  79. path: param.imgPath
  80. }
  81. })
  82. const query = wx.createSelectorQuery().in(this)
  83. query.select('#cutCanvas')
  84. .fields({node: true, size: true})
  85. .exec((res) => {
  86. const canvas = res[0].node
  87. const ctx = canvas.getContext('2d')
  88. const dpr = wx.getSystemInfoSync().pixelRatio
  89. canvas.width = res[0].width * dpr
  90. canvas.height = res[0].height * dpr
  91. ctx.scale(dpr,dpr)
  92. var x1 = canvas.width * 0.15 / dpr;
  93. var y1 = (canvas.height - canvas.width * 0.7) / 2 / dpr;
  94. var x2 = x1 + canvas.width * 0.7 / dpr;
  95. var y2 = y1 + canvas.width * 0.7 / dpr;
  96. var k1 = (y2 -y1) / (x2 - x1);
  97. var m1 = (x2 * y1 - x1 * y2) / (x2 - x1)
  98. var k2 = (y1 - y2) / (x2 -x1);
  99. var m2 = (x2 * y2 - x1 * y1) / (x2 - x1);
  100. that.setData({
  101. canvas: canvas,
  102. ctx: ctx,
  103. dpr: dpr,
  104. x1: x1,
  105. y1: y1,
  106. x2: x2,
  107. y2: y2,
  108. k1: k1,
  109. m1: m1,
  110. k2: k2,
  111. m2: m2
  112. })
  113. this._drawCut(x1, y1, x2, y2)
  114. wx.getImageInfo({
  115. src: param.imgPath,
  116. success(img){
  117. var width = '';
  118. var height = '';
  119. var type = 0;
  120. var x = '';var y = '';var d = '';
  121. if(img.width > img.height){
  122. height = that.data.y2 - that.data.y1;
  123. width = (img.width * height) / img.height
  124. type = 1
  125. d = img.height
  126. x = (img.width - d) / 2
  127. y = 0
  128. }else{
  129. width = that.data.x2 - that.data.x1;
  130. height = (img.height * width) / img.width
  131. type = 2
  132. d = img.width
  133. x = 0
  134. y = (img.height - d) / 2
  135. }
  136. that.setData({
  137. img: {
  138. path: param.imgPath,
  139. width: img.width,
  140. height: img.height,
  141. type: type
  142. },
  143. cutImg: {
  144. x: x,
  145. y: y,
  146. width: d,
  147. height: d
  148. },
  149. imageWidth: ((x2 - x1) / d) * img.width,
  150. imageHeight: ((y2 - y1) / d) * img.height,
  151. imageLeft: x1 - ((x2 - x1) / d) * x,
  152. imageTop: y1 - ((y2 - y1) / d) * y,
  153. imgRotate: 0
  154. })
  155. }
  156. })
  157. })
  158. },
  159. /**
  160. * 私有方法
  161. */
  162. _drawCut(x1, y1, x2, y2){
  163. var ctx = this.data.ctx;
  164. var canvas = this.data.canvas;
  165. ctx.clearRect(0, 0, canvas.width, canvas.height)
  166. ctx.globalAlpha = '0.5'
  167. ctx.fillStyle = '#000000'
  168. ctx.fillRect(0, 0, canvas.width, canvas.height)
  169. ctx.strokeStyle = '#ffffff'
  170. ctx.lineWidth = '3'
  171. ctx.lineCap = 'square'
  172. ctx.globalAlpha = '1'
  173. ctx.strokeRect(x1, y1, x2 - x1, y2 - y1)
  174. ctx.fillStyle = '#ffffff'
  175. ctx.fillRect(x1 - 5, y1 - 5, 20, 20)//左上角 1
  176. ctx.fillRect(x2 - 15, y1 - 5, 20, 20)//右上角 2
  177. ctx.fillRect(x1 - 5, y2 - 15, 20, 20)//左下角 3
  178. ctx.fillRect(x2 - 15, y2 - 15, 20 , 20)//右下角 4
  179. ctx.clearRect(x1, y1, x2 - x1, y2 -y1)
  180. },
  181. _touchStart(e){
  182. //裁剪框是否移动
  183. var flag = false;
  184. var point = '0'
  185. if(e.touches[0].x >= this.data.x1 - 10 && this.data.x1 + 10 >= e.touches[0].x){
  186. if(e.touches[0].y >= this.data.y1 - 10 && this.data.y1 + 10 >= e.touches[0].y){
  187. flag = true; point = '1';
  188. this.setData({
  189. endCut:{
  190. x: this.data.x1,
  191. y: this.data.y1
  192. }
  193. })
  194. }else if(e.touches[0].y >= this.data.y2 - 10 && this.data.y2 + 10 >= e.touches[0].y){
  195. flag = true; point = '3';
  196. this.setData({
  197. endCut:{
  198. x: this.data.x1,
  199. y: this.data.y2
  200. }
  201. })
  202. }
  203. }else if(e.touches[0].x >= this.data.x2 - 10 && this.data.x2 + 10 >= e.touches[0].x){
  204. if(e.touches[0].y >= this.data.y1 - 10 && this.data.y1 + 10 >= e.touches[0].y){
  205. flag = true; point = '2'
  206. this.setData({
  207. endCut:{
  208. x: this.data.x2,
  209. y: this.data.y1
  210. }
  211. })
  212. }else if(e.touches[0].y >= this.data.y2 - 10 && this.data.y2 + 10 >= e.touches[0].y){
  213. flag = true; point = '4'
  214. this.setData({
  215. endCut:{
  216. x: this.data.x2,
  217. y: this.data.y2
  218. }
  219. })
  220. }
  221. }
  222. this.setData({
  223. cutMove: flag,
  224. movePoint: point
  225. })
  226. //图片是否移动
  227. if(e.touches[0].x >= this.data.x1 + 10 && this.data.x2 - 10 >= e.touches[0].x){
  228. if(e.touches[0].y >= this.data.y1 + 10 && this.data.y2 - 10 >= e.touches[0].y){
  229. if(e.touches.length == 1){
  230. this.setData({
  231. imgMove: true,
  232. imgStart: {
  233. x: e.touches[0].x,
  234. y: e.touches[0].y,
  235. left: this.data.imageLeft,
  236. top: this.data.imageTop
  237. },
  238. imgScale: false
  239. })
  240. }else if(e.touches.length == 2){
  241. this.setData({
  242. imgMove: false,
  243. imgStart: {
  244. distance: Math.sqrt(Math.pow(e.touches[1].x - e.touches[0].x, 2) + Math.pow(e.touches[1].y - e.touches[0].y, 2)),
  245. width: this.data.imageWidth,
  246. height: this.data.imageHeight,
  247. cutImg: this.data.cutImg
  248. },
  249. imgScale: true
  250. })
  251. }
  252. }
  253. }
  254. },
  255. _touchMove(e){
  256. if(this.data.cutMove){
  257. var x1;var y1;var x2;var y2;
  258. if(this.data.movePoint == '1'){
  259. x1 = e.touches[0].x
  260. y1 = this.data.k1 * x1 + this.data.m1
  261. x2 = this.data.x2
  262. y2 = this.data.y2
  263. if(x1 > x2 -100){
  264. x1 = x2 - 100
  265. y1 = this.data.k1 * x1 + this.data.m1
  266. }else if(x1 < this.data.x1){
  267. x1 = this.data.x1
  268. y1 = this.data.k1 * x1 + this.data.m1
  269. }
  270. this.setData({
  271. endCut:{
  272. x: x1,
  273. y: y1
  274. }
  275. })
  276. }else if(this.data.movePoint == '2'){
  277. x2 = e.touches[0].x
  278. y1 = this.data.k2 * x2 + this.data.m2
  279. x1 = this.data.x1
  280. y2 = this.data.y2
  281. if(x2 > this.data.x2){
  282. x2 = this.data.x2
  283. y1 = this.data.y1
  284. }else if(x2 < this.data.x1 + 100){
  285. x2 = this.data.x1 + 100
  286. y1 = this.data.k2 * x2 + this.data.m2
  287. }
  288. this.setData({
  289. endCut:{
  290. x: x2,
  291. y: y1
  292. }
  293. })
  294. }else if(this.data.movePoint == '3'){
  295. x1 = e.touches[0].x
  296. y2 = this.data.k2 * x1 + this.data.m2
  297. x2 = this.data.x2
  298. y1 = this.data.y1
  299. if(x1 > x2 - 100){
  300. x1 = x2 - 100
  301. y2 = this.data.k2 * x1 + this.data.m2
  302. }else if(x1 < this.data.x1){
  303. x1 = this.data.x1
  304. y2 = this.data.y2
  305. }
  306. this.setData({
  307. endCut:{
  308. x: x1,
  309. y: y2
  310. }
  311. })
  312. }else if(this.data.movePoint == '4'){
  313. x2 = e.touches[0].x
  314. y2 = this.data.k1 * x2 + this.data.m1
  315. x1 = this.data.x1
  316. y1 = this.data.y1
  317. if(x2 > this.data.x2){
  318. x2 = this.data.x2
  319. y2 = this.data.k1 * x2 + this.data.m1
  320. }else if(x2 < x1 + 100){
  321. x2 = x1 + 100
  322. y2 = this.data.k1 * x2 + this.data.m1
  323. }
  324. this.setData({
  325. endCut:{
  326. x: x2,
  327. y: y2
  328. }
  329. })
  330. }
  331. this._drawCut(x1, y1, x2, y2)
  332. }else if(this.data.imgMove){
  333. var dx = this.data.imgStart.x - e.touches[0].x
  334. var dy = this.data.imgStart.y - e.touches[0].y
  335. var rotate = this.data.imgRotate
  336. var left = this.data.imgStart.left - dx
  337. var top = this.data.imgStart.top - dy
  338. if(this.data.imgMirror == 180){
  339. dx = -dx
  340. rotate = -rotate
  341. }
  342. var tx = dx * Math.cos(rotate * Math.PI / 180) + dy * Math.sin(rotate * Math.PI / 180)
  343. var ty = dy * Math.cos(rotate * Math.PI / 180) - dx * Math.sin(rotate * Math.PI / 180)
  344. var x = (tx + this.data.originWidthShow * this.data.imageWidth) / this.data.imageWidth * this.data.img.width - this.data.cutImg.width / 2
  345. var y = (ty + this.data.originHeightShow * this.data.imageHeight) / this.data.imageHeight * this.data.img.height - this.data.cutImg.height / 2
  346. this.setData({
  347. cutImg: {
  348. width: this.data.cutImg.width,
  349. height: this.data.cutImg.height,
  350. x: x,
  351. y: y
  352. },
  353. imageLeft: left,
  354. imageTop: top,
  355. })
  356. }else if(this.data.imgScale){
  357. var nowDistance = Math.sqrt(Math.pow(e.touches[1].x - e.touches[0].x, 2) + Math.pow(e.touches[1].y - e.touches[0].y, 2))
  358. var m = nowDistance / this.data.imgStart.distance
  359. var width = this.data.imgStart.width * m
  360. var height = this.data.imgStart.height * m
  361. if(this.data.img.type == 1){
  362. height = height < this.data.y2 - this.data.y1 ? this.data.y2 - this.data.y1 : height
  363. height = height > (this.data.y2 - this.data.y1)*10 ? (this.data.y2 - this.data.y1)*10 : height
  364. width = (height * this.data.img.width) / this.data.img.height
  365. }else{
  366. width = width < this.data.x2 - this.data.x1 ? this.data.x2 - this.data.x1 : width
  367. width = width > (this.data.x2 - this.data.x1)*10 ? (this.data.x2 - this.data.x1)*10 : width
  368. height = (width * this.data.img.height) / this.data.img.width
  369. }
  370. var n = width / this.data.imgStart.width
  371. var cut = {
  372. x: this.data.imgStart.cutImg.x + ((n - 1) / (2 * n)) * this.data.imgStart.cutImg.width,
  373. y: this.data.imgStart.cutImg.y + ((n - 1) / (2 * n)) * this.data.imgStart.cutImg.height,
  374. width: this.data.imgStart.cutImg.width / n,
  375. height: this.data.imgStart.cutImg.height / n
  376. }
  377. var left = this.data.x1 - ((this.data.x2 - this.data.x1) / cut.width) * cut.x
  378. left = left > this.data.x1 ? this.data.x1 : left
  379. left = left < this.data.x2 - this.data.imageWidth ? this.data.x2 - this.data.imageWidth :left
  380. var top = this.data.y1 - ((this.data.y2 - this.data.y1) / cut.height) * cut.y
  381. top = top > this.data.y1 ? this.data.y1 : top
  382. top = top < this.data.y2 - this.data.imageHeight ? this.data.y2 - this.data.imageHeight : top
  383. this.setData({
  384. imageLeft: left,
  385. imageTop: top,
  386. imageWidth: width,
  387. imageHeight: height,
  388. cutImg: {
  389. x: cut.x,
  390. y: cut.y,
  391. width: cut.width,
  392. height: cut.height
  393. },
  394. })
  395. }
  396. },
  397. _touchEnd(e){
  398. if(this.data.cutMove){
  399. var dx;var dy;var d;
  400. var movePoint = this.data.movePoint
  401. if(movePoint % 2 == 0){
  402. d = ((this.data.endCut.x - this.data.x1) * this.data.cutImg.width) / (this.data.x2 - this.data.x1)
  403. if(this.data.imgMirror == 180){
  404. dx = -(this.data.endCut.x - this.data.x2) / this.data.imageWidth * this.data.img.width /2
  405. if(movePoint == '2'){
  406. dy = (this.data.endCut.y - this.data.y1) / this.data.imageHeight * this.data.img.height /2
  407. }else{
  408. dy = (this.data.endCut.y - this.data.y2) / this.data.imageHeight * this.data.img.height /2
  409. }
  410. }else{
  411. dx = (this.data.endCut.x - this.data.x2) / this.data.imageWidth * this.data.img.width /2
  412. if(movePoint == '2'){
  413. dy = (this.data.endCut.y - this.data.y1) / this.data.imageHeight * this.data.img.height /2
  414. }else{
  415. dy = (this.data.endCut.y - this.data.y2) / this.data.imageHeight * this.data.img.height /2
  416. }
  417. }
  418. }else{
  419. d = ((this.data.x2 - this.data.endCut.x) * this.data.cutImg.width) / (this.data.x2 - this.data.x1)
  420. if(this.data.imgMirror == 180){
  421. dx = -(this.data.endCut.x - this.data.x1) / this.data.imageWidth * this.data.img.width /2
  422. if(movePoint == '1'){
  423. dy = (this.data.endCut.y - this.data.y1) / this.data.imageHeight * this.data.img.height /2
  424. }else{
  425. dy = (this.data.endCut.y - this.data.y2) / this.data.imageHeight * this.data.img.height /2
  426. }
  427. }else{
  428. dx = (this.data.endCut.x - this.data.x1) / this.data.imageWidth * this.data.img.width /2
  429. if(movePoint == '1'){
  430. dy = (this.data.endCut.y - this.data.y1) / this.data.imageHeight * this.data.img.height /2
  431. }else{
  432. dy = (this.data.endCut.y - this.data.y2) / this.data.imageHeight * this.data.img.height /2
  433. }
  434. }
  435. }
  436. var rotate = this.data.imgMirror == 180 ? -this.data.imgRotate : this.data.imgRotate
  437. var x = ((dx * Math.cos(rotate * Math.PI / 180) + dy * Math.sin(rotate * Math.PI / 180)) + this.data.originWidthShow * this.data.img.width) - d / 2
  438. var y = ((dy * Math.cos(rotate * Math.PI / 180) - dx * Math.sin(rotate * Math.PI / 180)) + this.data.originHeightShow * this.data.img.height) - d / 2
  439. this.setData({
  440. cutImg:{
  441. x: x,
  442. y: y,
  443. width: d,
  444. height: d
  445. },
  446. imageWidth: ((this.data.x2 - this.data.x1) / d) * this.data.img.width,
  447. imageHeight: ((this.data.y2 - this.data.y1) / d) * this.data.img.height,
  448. imageLeft: this.data.x1 - ((this.data.x2 - this.data.x1) / d) * x,
  449. imageTop: this.data.y1 - ((this.data.y2 - this.data.y1) / d) * y,
  450. })
  451. this._drawCut(this.data.x1,this.data.y1,this.data.x2,this.data.y2)
  452. }
  453. if(this.data.imgMove){
  454. var left = this.data.x1 - ((this.data.x2 - this.data.x1) / this.data.cutImg.width) * this.data.cutImg.x
  455. var top = this.data.y1 - ((this.data.y2 - this.data.y1) / this.data.cutImg.height) * this.data.cutImg.y
  456. this.setData({
  457. imageLeft: left,
  458. imageTop: top,
  459. })
  460. }
  461. this.setData({
  462. originWidthShow: (this.data.cutImg.x + this.data.cutImg.width / 2) / this.data.img.width,
  463. originHeightShow: (this.data.cutImg.y + this.data.cutImg.height / 2) / this.data.img.height,
  464. cutMove: false,
  465. movePoint: '0',
  466. imgMove: false,
  467. imgScale: false
  468. })
  469. },
  470. _rotateChange(e){
  471. this.setData({
  472. imgRotate: e.detail.value
  473. })
  474. },
  475. _rotateNinety(){
  476. var r = this.data.imgRotate + 90 > 180 ? this.data.imgRotate - 270 : this.data.imgRotate + 90
  477. this.setData({
  478. imgRotate: r
  479. })
  480. },
  481. _imageMirror(){
  482. var m = this.data.imgMirror == 180 ? 0 : 180
  483. this.setData({
  484. imgMirror: m,
  485. })
  486. },
  487. _imgRestore(){
  488. this.setData({
  489. canvas: '',
  490. ctx: '',
  491. x1: 0,
  492. y1: 0,
  493. x2: 0,
  494. y2: 0,
  495. k1: 0,
  496. m1: 0,
  497. k2: 0,
  498. m2: 0,
  499. cutMove: false,
  500. endCut: {
  501. x: 0,
  502. y: 0
  503. },
  504. movePoint: '0',
  505. imageWidth: 0,
  506. imageHeight: 0,
  507. imageLeft: 0,
  508. imageTop: 0,
  509. imgRotate: 0,
  510. imgMirror: 0,
  511. originWidthShow: 0.5,
  512. originHeightShow: 0.5,
  513. imgMove: false,
  514. imgStart: {
  515. x: 0,
  516. y: 0,
  517. left: 0,
  518. top: 0,
  519. distance: 0,
  520. width: 0,
  521. height: 0,
  522. cutx: 0,
  523. cuty: 0
  524. },
  525. imgScale: false,
  526. cutImg: {
  527. path: '',
  528. x: 0,
  529. y: 0,
  530. width: 0,
  531. height: 0
  532. }
  533. })
  534. this.init(this.data.img.path)
  535. },
  536. _cancelCut(){
  537. this._restoreData()
  538. if(fail){
  539. fail('cancel')
  540. }
  541. },
  542. _confirmCut(){
  543. wx.showLoading({
  544. title: '裁剪中...',
  545. mask: true
  546. })
  547. var that = this
  548. const query = wx.createSelectorQuery().in(this)
  549. query.select('#imgCanvas')
  550. .fields({node: true, size: true})
  551. .exec((res) => {
  552. const canvas = res[0].node
  553. const ctx = canvas.getContext('2d')
  554. canvas.width = that.data.cutImg.width
  555. canvas.height = that.data.cutImg.height
  556. ctx.translate(canvas.width / 2, canvas.height / 2)
  557. ctx.rotate((that.data.imgRotate >= 0 ? that.data.imgRotate : that.data.imgRotate + 360) * Math.PI / 180)
  558. if(that.data.imgMirror == 180){
  559. ctx.scale(-1, 1); //左右镜像翻转
  560. }
  561. const img = canvas.createImage()
  562. img.src = that.data.img.path
  563. img.onload = () => {
  564. ctx.drawImage(img, 0, 0, that.data.img.width, that.data.img.height, -(that.data.cutImg.x+canvas.width/2), -(that.data.cutImg.y+canvas.height/2), that.data.img.width, that.data.img.height)
  565. wx.canvasToTempFilePath({
  566. canvas: canvas,
  567. success(img){
  568. success(img.tempFilePath)
  569. that._restoreData()
  570. wx.hideLoading({
  571. success: (res) => {},
  572. })
  573. },
  574. fail(){
  575. wx.hideLoading({
  576. success: (res) => {
  577. wx.showToast({
  578. title: '裁剪失败',
  579. icon: 'error'
  580. })
  581. if(fail){
  582. fail('fail')
  583. }
  584. },
  585. })
  586. }
  587. })
  588. }
  589. })
  590. },
  591. _restoreData(){
  592. this.setData({
  593. canvas: '',
  594. ctx: '',
  595. x1: 0,
  596. y1: 0,
  597. x2: 0,
  598. y2: 0,
  599. k1: 0,
  600. m1: 0,
  601. k2: 0,
  602. m2: 0,
  603. cutMove: false,
  604. endCut: {
  605. x: 0,
  606. y: 0
  607. },
  608. movePoint: '0',
  609. img: {
  610. path: '',
  611. width: 0,
  612. height: 0,
  613. type: 1 // 1:横向 2:纵向
  614. },
  615. imageWidth: 0,
  616. imageHeight: 0,
  617. imageLeft: 0,
  618. imageTop: 0,
  619. imgRotate: 0,
  620. imgMirror: 0,
  621. originWidthShow: 0.5,
  622. originHeightShow: 0.5,
  623. imgMove: false,
  624. imgStart: {
  625. x: 0,
  626. y: 0,
  627. left: 0,
  628. top: 0,
  629. distance: 0,
  630. width: 0,
  631. height: 0,
  632. cutx: 0,
  633. cuty: 0
  634. },
  635. imgScale: false,
  636. cutImg: {
  637. path: '',
  638. x: 0,
  639. y: 0,
  640. width: 0,
  641. height: 0
  642. }
  643. })
  644. },
  645. }
  646. })