1
This commit is contained in:
@@ -33,21 +33,21 @@ export class CanvasManager {
|
|||||||
setCanvasViewSize(options) {
|
setCanvasViewSize(options) {
|
||||||
this.canvasViewWidth = options.canvasViewWidth || 1920
|
this.canvasViewWidth = options.canvasViewWidth || 1920
|
||||||
this.canvasViewHeight = options.canvasViewHeight || 1080
|
this.canvasViewHeight = options.canvasViewHeight || 1080
|
||||||
|
this.canvas.setWidth(this.canvasViewWidth)
|
||||||
|
this.canvas.setHeight(this.canvasViewHeight)
|
||||||
}
|
}
|
||||||
initCanvas(options: CanvasInitOptions) {
|
initCanvas(options: CanvasInitOptions) {
|
||||||
this.layerManager = this.stateManager.layerManager
|
this.layerManager = this.stateManager.layerManager
|
||||||
this.setCanvasViewSize(options)
|
|
||||||
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, {
|
this.canvas = createCanvas(options.canvasRef.value, {
|
||||||
width: this.canvasViewWidth,
|
|
||||||
height: this.canvasViewHeight,
|
|
||||||
preserveObjectStacking: true,
|
preserveObjectStacking: true,
|
||||||
enableRetinaScaling: true,
|
enableRetinaScaling: true,
|
||||||
stopContextMenu: true,
|
stopContextMenu: true,
|
||||||
fireRightClick: true,
|
fireRightClick: true,
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
})
|
})
|
||||||
|
this.setCanvasViewSize(options)
|
||||||
this.canvas.clipPath = new fabric.Rect({
|
this.canvas.clipPath = new fabric.Rect({
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ export class RectToolManager {
|
|||||||
if(height === 0) height = 50
|
if(height === 0) height = 50
|
||||||
this.demoObject.set({ width, height })
|
this.demoObject.set({ width, height })
|
||||||
const object = this.demoObject.toJSON("evented")
|
const object = this.demoObject.toJSON("evented")
|
||||||
|
if(object.width < 0) {
|
||||||
|
object.left += object.width
|
||||||
|
object.width = -object.width
|
||||||
|
}
|
||||||
|
if(object.height < 0) {
|
||||||
|
object.top += object.height
|
||||||
|
object.height = -object.height
|
||||||
|
}
|
||||||
this.layerManager.createRectLayer(object, true)
|
this.layerManager.createRectLayer(object, true)
|
||||||
this.canvasManager.canvas.remove(this.demoObject)
|
this.canvasManager.canvas.remove(this.demoObject)
|
||||||
this.canvasManager.canvas.renderAll()
|
this.canvasManager.canvas.renderAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user