import { floorplanService } from '../Service/FloorplanService'
import { mathUtil } from '../MathUtil.js'
import { coordinate } from '../Coordinate'
import Constant from '../Constant'

export default class MoveCircle {
    constructor() {}

    moveFullCircle(dx,dy, circleId) {
        let circle = floorplanService.getCircle(circleId)

        circle.points[0] = {
            x:circle.points[0].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:circle.points[0].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        circle.points[1] = {
            x:circle.points[1].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:circle.points[1].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        circle.points[2] = {
            x:circle.points[2].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:circle.points[2].y - dy/coordinate.res,
        }

        circle.points[3] = {
            x:circle.points[3].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:circle.points[3].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        circle.center = {
            x:circle.center.x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:circle.center.y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }
    }

    moveCircleVertex(newPosition,circleId,index) {
        let circle = floorplanService.getCircle(circleId)
        circle.updatePoints(newPosition,index)
    }
}

const moveCircle = new MoveCircle()
export { moveCircle }
