How to use the @antv/x6.Rectangle function in @antv/x6

To help you get started, we’ve selected a few @antv/x6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / x6 / examples / x6-example-drawio / src / pages / graph / graph.ts View on Github external
if (bounds.width == 0 || bounds.height == 0) {
      return new Rectangle(0, 0, 1, 1)
    } else {
      const s = this.view.scale
      const t = this.view.translate
      const x = Math.ceil(bounds.x / s - t.x)
      const y = Math.ceil(bounds.y / s - t.y)
      const w = Math.floor(bounds.width / s)
      const h = Math.floor(bounds.height / s)

      const x0 = Math.floor(x / size.width)
      const y0 = Math.floor(y / size.height)
      const w0 = Math.ceil((x + w) / size.width) - x0
      const h0 = Math.ceil((y + h) / size.height) - y0

      return new Rectangle(x0, y0, w0, h0)
    }
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / graph.ts View on Github external
getPageLayout() {
    const size = this.getPageSize()
    const bounds = this.getGraphBounds()

    if (bounds.width == 0 || bounds.height == 0) {
      return new Rectangle(0, 0, 1, 1)
    } else {
      const s = this.view.scale
      const t = this.view.translate
      const x = Math.ceil(bounds.x / s - t.x)
      const y = Math.ceil(bounds.y / s - t.y)
      const w = Math.floor(bounds.width / s)
      const h = Math.floor(bounds.height / s)

      const x0 = Math.floor(x / size.width)
      const y0 = Math.floor(y / size.height)
      const w0 = Math.ceil((x + w) / size.width) - x0
      const h0 = Math.ceil((y + h) / size.height) - y0

      return new Rectangle(x0, y0, w0, h0)
    }
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / callout.ts View on Github external
getLabelMargins() {
    return new Rectangle(
      0,
      0,
      0,
      util.getNumber(this.style, 'factor', this.factor) * this.scale,
    )
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / tape.ts View on Github external
if (util.getBoolean(this.style, 'boundedLbl', false)) {
      const w = rect.width
      const h = rect.height

      if (
        this.direction == null ||
        this.direction === 'east' ||
        this.direction === 'west'
      ) {
        const dy = getFactor(this.style, this.factor, h)
        return new Rectangle(rect.x, rect.y + dy, w, h - 2 * dy)
      }

      const dx = getFactor(this.style, this.factor, w)

      return new Rectangle(rect.x + dx, rect.y, w - 2 * dx, h)
    }

    return null
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / tape.ts View on Github external
getLabelMargins(rect: Rectangle) {
    if (util.getBoolean(this.style, 'boundedLbl', false)) {
      const w = rect.width
      const h = rect.height

      if (
        this.direction == null ||
        this.direction === 'east' ||
        this.direction === 'west'
      ) {
        const dy = getFactor(this.style, this.factor, h)
        return new Rectangle(rect.x, rect.y + dy, w, h - 2 * dy)
      }

      const dx = getFactor(this.style, this.factor, w)

      return new Rectangle(rect.x + dx, rect.y, w - 2 * dx, h)
    }

    return null
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / callout.ts View on Github external
export function calloutPerimeter(
  bounds: Rectangle,
  state: State,
  next: Point,
  orthogonal: boolean,
) {
  const factor = getFactor(
    state.style,
    CalloutShape.prototype.factor,
    bounds.height,
  )
  const rect = new Rectangle(0, 0, 0, factor * state.view.scale)
  const directedBounds = util.getDirectedBounds(bounds, rect, state.style)
  return Perimeter.rectangle(directedBounds, state, next, orthogonal)
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / view.ts View on Github external
const ps = this.graph.pageScale
    const fmt = this.graph.pageFormat

    const pw = fmt.width * ps
    const ph = fmt.height * ps

    const x0 = Math.floor(Math.min(0, x) / pw)
    const y0 = Math.floor(Math.min(0, y) / ph)
    const xe = Math.ceil(Math.max(1, x + w) / pw)
    const ye = Math.ceil(Math.max(1, y + h) / ph)

    const rows = xe - x0
    const cols = ye - y0

    return new Rectangle(
      s * (t.x + x0 * pw),
      s * (t.y + y0 * ph),
      s * rows * pw,
      s * cols * ph,
    )
  }
}