Sfoglia il codice sorgente

fix: 图片标注显示修复

Suuuuuukang 1 mese fa
parent
commit
eabb4d82f6
1 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 8 5
      src/views/demo/components/img-maker.vue

+ 8 - 5
src/views/demo/components/img-maker.vue

@@ -66,6 +66,7 @@ const props = defineProps({
 const state = reactive({
   loading: true,
   radio: 1,
+  radioBackup: 1,
   realRadioX: 0.5,
   realRadioY: 0.5,
   imgPoint: { x: 0, y: 0 },
@@ -211,8 +212,9 @@ const loadInit = () => {
         let config = props.jsonData[i]
         let subArr = config.subArr
         console.log('ratio', state.radio)
-        const lW = imgInstance.width //* state.radio
-        const lH = imgInstance.height //* state.radio
+        state.radioBackup = state.radio
+        const lW = imgInstance.width * state.radio
+        const lH = imgInstance.height * state.radio
         let obj = new fabric.Path(
           'M ' +
             subArr[1] * lW +
@@ -754,7 +756,7 @@ const clearAll = () => {
   state.drawType = 'rectangle'
 }
 const getPoint = pi => {
-  return Math.floor(pi / state.radio)
+  return Math.floor(pi)// / state.radio
 }
 const getRealPoint = poi => {
   let dx = Math.abs(state.imgPoint.x > poi.x ? state.imgPoint.x - poi.x : state.imgPoint.x + poi.x) * state.realRadioX
@@ -807,8 +809,9 @@ const getData = () => {
           // console.log(poi)
           poi = getRealPoint(poi)
           // console.log(poi)
-          poi.x = poi.x / 1920
-          poi.y = poi.y / 1080
+          console.log('radio final:', state.radio, state.radioBackup)
+          poi.x = poi.x / 1920 / state.radioBackup
+          poi.y = poi.y / 1080 / state.radioBackup
           // console.log(poi)
           point['nodes'].push(poi)
           // point['nodes'].push(getRealPoint(poi))