/*
 * 播放器画面区域对象
 * EZOpenSDK
 *
 * Created by junecheng on 2024/8/22.
 * Copyright (c) 2024年 Ezviz. All rights reserved.
 */
export default class PlayRect {
  left: number
  top: number
  right: number
  bottom: number

  constructor(left: number = 0, top: number = 0, right: number = 0, bottom: number = 0) {
    this.left = left
    this.top = top
    this.right = right
    this.bottom = bottom
  }

  set(left: number, top: number, right: number, bottom: number) {
    this.left = left
    this.top = top
    this.right = right
    this.bottom = bottom
  }

  copyFrom(playRect: PlayRect) {
    this.left = playRect.left
    this.top = playRect.top
    this.right = playRect.right
    this.bottom = playRect.bottom
  }

  offset(dx: number, dy: number) {
    this.left += dx
    this.top += dy
    this.right += dx
    this.bottom += dy
  }

  width(): number {
    return this.right - this.left
  }

  height(): number {
    return this.bottom - this.top
  }

  setEmpty() {
    this.left = this.right = this.top = this.bottom = 0
  }

  isEmpty(): boolean {
    return this.left >= this.right || this.top >= this.bottom
  }

  compare(playRect: PlayRect): boolean {
    return this.left == playRect.left && this.top == playRect.top && this.right == playRect.right &&
      this.bottom == playRect.bottom
  }
}