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

export default class MoveIcon {
    constructor() {}

    moveFullIcon(dx,dy, iconId) {
        let icon = floorplanService.getIcon(iconId)

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

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

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

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

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

    moveIconVertex(newPosition,iconId,index) {
        let icon = floorplanService.getIcon(iconId)
        icon.updatePoints(newPosition,index)
    }
}

const moveIcon = new MoveIcon()
export { moveIcon }
