/**
 * startX:缩放后的X坐标(canvas坐标系下)
 * startY:缩放后的y坐标(canvas坐标系下)
 * canvas:canvas对象
 * ctx:ctx对象
 * id:id
 * zoomRate:缩放率
 * imgX:图片左边距
 * imgY：图片上边距
 * originX：原始x坐标（图片坐标系下）  
 * originY：原始y坐标（图片坐标系下）  
 */
export default class RectForPositionCheck {
    constructor(startX,startY,canvas,ctx,id,zoomRate,imgX,imgY,originX,originY) {
        this.startX = startX
        this.startY = startY
        this.canvas = canvas
        this.ctx = ctx
        this.id = id
        this.zoomRate = zoomRate
        this.imgX = imgX
        this.imgY = imgY
        this.originX = originX
        this.originY = originY
    }
    isMovePositionInRect (x,y) {
        if (x < (this.startX+40*this.zoomRate) && x > (this.startX - 40*this.zoomRate) && y > (this.startY - 40*this.zoomRate) && y < (this.startY + 40*this.zoomRate)) {
            return true
        }
    }
    draw () {
        this.ctx.strokeStyle = 'red'
        this.ctx.lineWidth = 6 * this.zoomRate
        this.ctx.lineJoin = "round";
        this.ctx.save()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX,this.startY)
        this.ctx.lineTo(this.startX + (20*this.zoomRate), this.startY)
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX,this.startY)
        this.ctx.lineTo(this.startX - (20*this.zoomRate), this.startY)
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX,this.startY)
        this.ctx.lineTo(this.startX, this.startY + (20*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX,this.startY)
        this.ctx.lineTo(this.startX, this.startY - (20*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX + (5*this.zoomRate),this.startY - (40*this.zoomRate))
        this.ctx.lineTo(this.startX  + (40*this.zoomRate), this.startY - (40*this.zoomRate))
        this.ctx.lineTo(this.startX  + (40*this.zoomRate), this.startY - (5*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX + (40*this.zoomRate),this.startY + (5*this.zoomRate))
        this.ctx.lineTo(this.startX  + (40*this.zoomRate), this.startY + (40*this.zoomRate))
        this.ctx.lineTo(this.startX  + (5*this.zoomRate), this.startY + (40*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX - (5*this.zoomRate),this.startY + (40*this.zoomRate))
        this.ctx.lineTo(this.startX  - (40*this.zoomRate), this.startY + (40*this.zoomRate))
        this.ctx.lineTo(this.startX  - (40*this.zoomRate) , this.startY + (5*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.beginPath()
        this.ctx.moveTo(this.startX - (40*this.zoomRate),this.startY - (5*this.zoomRate))
        this.ctx.lineTo(this.startX  - (40*this.zoomRate), this.startY - (40*this.zoomRate))
        this.ctx.lineTo(this.startX  - (5*this.zoomRate) , this.startY -(40*this.zoomRate))
        this.ctx.stroke()
        this.ctx.closePath()
        this.ctx.restore()
    }
}