Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, inject, computed } from 'vue'
|
import { ref, inject, computed } from 'vue'
|
||||||
import { exportCanvasToImage } from '../tools/exportMethod'
|
import { exportCanvasToImage } from '../tools/exportMethod'
|
||||||
import { OperationType } from '../tools/layerHelper'
|
import { OperationType, BlendMode } from '../tools/layerHelper'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
zoom: { default: 1, type: Number },
|
zoom: { default: 1, type: Number },
|
||||||
step: { default: 0.1, type: Number }
|
step: { default: 0.1, type: Number }
|
||||||
@@ -87,7 +87,9 @@
|
|||||||
}
|
}
|
||||||
const onImageClick = async () => {
|
const onImageClick = async () => {
|
||||||
const layer = await importLocalImage(false)
|
const layer = await importLocalImage(false)
|
||||||
objectManager.setFillRepeat(layer?.info?.id)
|
const id = layer?.info?.id
|
||||||
|
objectManager.setBlendMode(id, BlendMode.MULTIPLY)
|
||||||
|
objectManager.setFillRepeat(id)
|
||||||
}
|
}
|
||||||
const onWorkbench = async () => {
|
const onWorkbench = async () => {
|
||||||
exportCanvasToImage(canvasManager.canvas).then((url) => {
|
exportCanvasToImage(canvasManager.canvas).then((url) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
|
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
|
||||||
<div class="canvas-box">
|
<div class="canvas-box">
|
||||||
<depth-canvas :config="config" @workbench="onWorkbench" @close="onClose" />
|
<depth-canvas :config="config" @workbench="onWorkbench" />
|
||||||
</div>
|
</div>
|
||||||
</fullscreen-dialog>
|
</fullscreen-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -60,17 +60,12 @@ export class CanvasManager {
|
|||||||
this.layerManager = this.stateManager.layerManager
|
this.layerManager = this.stateManager.layerManager
|
||||||
this.canvasWidth = options.canvasWidth || 750
|
this.canvasWidth = options.canvasWidth || 750
|
||||||
this.canvasHeight = options.canvasHeight || 600
|
this.canvasHeight = options.canvasHeight || 600
|
||||||
this.canvas = createCanvas(options.canvasRef.value, {
|
var image = null;
|
||||||
preserveObjectStacking: true,
|
|
||||||
enableRetinaScaling: true,
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
})
|
|
||||||
if (options.url) {
|
if (options.url) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve) => {
|
||||||
fabric.Image.fromURL(options.url, async (img) => {
|
fabric.Image.fromURL(options.url, async (img) => {
|
||||||
this.canvasWidth = img.width
|
this.canvasWidth = img.width
|
||||||
this.canvasHeight = img.height
|
this.canvasHeight = img.height
|
||||||
this.setCanvasViewSize(options)
|
|
||||||
img.set({
|
img.set({
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
@@ -81,14 +76,22 @@ export class CanvasManager {
|
|||||||
name: "图片图层",
|
name: "图片图层",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.canvas.add(img)
|
image = img
|
||||||
await this.layerManager.updateLayerThumbnailsById(img.info.id)
|
|
||||||
resolve(img)
|
resolve(img)
|
||||||
}, { crossOrigin: 'anonymous' })
|
}, { crossOrigin: 'anonymous' })
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
this.setCanvasViewSize(options)
|
|
||||||
}
|
}
|
||||||
|
this.canvas = createCanvas(options.canvasRef.value, {
|
||||||
|
preserveObjectStacking: true,
|
||||||
|
enableRetinaScaling: true,
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
})
|
||||||
|
if (image) {
|
||||||
|
this.canvas.add(image)
|
||||||
|
await this.layerManager.updateLayerThumbnailsById(image.info.id)
|
||||||
|
}
|
||||||
|
this.setCanvasViewSize(options)
|
||||||
|
|
||||||
this.canvas.clipPath = new fabric.Rect({
|
this.canvas.clipPath = new fabric.Rect({
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
|
|||||||
@@ -78,6 +78,14 @@ export class ObjectManager {
|
|||||||
this.layerManager = options.layerManager
|
this.layerManager = options.layerManager
|
||||||
}
|
}
|
||||||
onMounted() { }
|
onMounted() { }
|
||||||
|
/** 设置混合模式 */
|
||||||
|
setBlendMode(id: string, blendMode: string) {
|
||||||
|
const object = this.canvasManager.getObjectById(id)
|
||||||
|
if (!object) return console.warn('设置混合模式失败,对象不存在ID:', id)
|
||||||
|
object.set("globalCompositeOperation", blendMode)
|
||||||
|
this.canvasManager.renderAll()
|
||||||
|
}
|
||||||
|
|
||||||
/** 设置平铺状态 */
|
/** 设置平铺状态 */
|
||||||
setFillRepeat(id: string) {
|
setFillRepeat(id: string) {
|
||||||
const object = this.canvasManager.getObjectById(id)
|
const object = this.canvasManager.getObjectById(id)
|
||||||
@@ -118,6 +126,7 @@ export class ObjectManager {
|
|||||||
scaleY: object.scaleY,
|
scaleY: object.scaleY,
|
||||||
flipX: object.flipX,
|
flipX: object.flipX,
|
||||||
flipY: object.flipY,
|
flipY: object.flipY,
|
||||||
|
globalCompositeOperation: object.globalCompositeOperation,
|
||||||
originX: "left",
|
originX: "left",
|
||||||
originY: "top",
|
originY: "top",
|
||||||
info,
|
info,
|
||||||
|
|||||||
Reference in New Issue
Block a user