How to use the @antv/x6.Point 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 / shape / parallelogram.ts View on Github external
export function parallelogramPerimeter(
  bounds: Rectangle,
  state: State,
  next: Point = new Point(),
  orthogonal: boolean = false,
) {
  const style = state ? state.style : {}
  const defaultFactor = ParallelogramShape.prototype.factor

  const x = bounds.x
  const y = bounds.y
  const w = bounds.width
  const h = bounds.height

  const direction = (state != null && state.style.direction) || 'east'
  const vertical = direction === 'north' || direction === 'south'

  let points: Point[]

  if (vertical) {
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / step.ts View on Github external
redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    const f = getFactor(this.style, this.factor, w)
    const arcSize = this.getLineArcSize()

    this.drawPoints(
      c,
      [
        new Point(0, 0),
        new Point(w - f, 0),
        new Point(w, h / 2),
        new Point(w - f, h),
        new Point(0, h),
        new Point(f, h / 2),
      ],
      this.rounded,
      arcSize,
      true,
    )

    c.end()
  }
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / trapezoid.ts View on Github external
} else if (direction === 'west') {
    const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x, y),
      new Point(x + w, y),
      new Point(x + w - dx, y + h),
      new Point(x + dx, y + h),
      new Point(x, y),
    ]
  } else if (direction === 'north') {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y + dy),
      new Point(x + w, y),
      new Point(x + w, y + h),
      new Point(x, y + h - dy),
      new Point(x, y + dy),
    ]
  } else {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y),
      new Point(x + w, y + dy),
      new Point(x + w, y + h - dy),
      new Point(x, y + h),
      new Point(x, y),
    ]
  }

  const center = bounds.getCenter()

  if (orthogonal) {
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / step.ts View on Github external
const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x + dx, y),
      new Point(x + w, y),
      new Point(x + w - dx, cy),
      new Point(x + w, y + h),
      new Point(x + dx, y + h),
      new Point(x, cy),
      new Point(x + dx, y),
    ]
  } else if (direction === 'north') {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y + dy),
      new Point(cx, y),
      new Point(x + w, y + dy),
      new Point(x + w, y + h),
      new Point(cx, y + h - dy),
      new Point(x, y + h),
      new Point(x, y + dy),
    ]
  } else {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y),
      new Point(cx, y + dy),
      new Point(x + w, y),
      new Point(x + w, y + h - dy),
      new Point(cx, y + h),
      new Point(x, y + h - dy),
      new Point(x, y),
    ]
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / step.ts View on Github external
new Point(x + w - dx, y),
      new Point(x + w, cy),
      new Point(x + w - dx, y + h),
      new Point(x, y + h),
      new Point(x + dx, cy),
      new Point(x, y),
    ]
  } else if (direction === 'west') {
    const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x + dx, y),
      new Point(x + w, y),
      new Point(x + w - dx, cy),
      new Point(x + w, y + h),
      new Point(x + dx, y + h),
      new Point(x, cy),
      new Point(x + dx, y),
    ]
  } else if (direction === 'north') {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y + dy),
      new Point(cx, y),
      new Point(x + w, y + dy),
      new Point(x + w, y + h),
      new Point(cx, y + h - dy),
      new Point(x, y + h),
      new Point(x, y + dy),
    ]
  } else {
    const dy = getFactor(style, defaultFactor, h)
    points = [
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / step.ts View on Github external
const x = bounds.x
  const y = bounds.y
  const w = bounds.width
  const h = bounds.height

  const cx = bounds.getCenterX()
  const cy = bounds.getCenterY()

  const direction = (state != null && state.style.direction) || 'east'
  let points: Point[]

  if (direction === 'east') {
    const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x, y),
      new Point(x + w - dx, y),
      new Point(x + w, cy),
      new Point(x + w - dx, y + h),
      new Point(x, y + h),
      new Point(x + dx, cy),
      new Point(x, y),
    ]
  } else if (direction === 'west') {
    const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x + dx, y),
      new Point(x + w, y),
      new Point(x + w - dx, cy),
      new Point(x + w, y + h),
      new Point(x + dx, y + h),
      new Point(x, cy),
      new Point(x + dx, y),
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / callout.ts View on Github external
redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    const arcSize = this.getLineArcSize()
    const s = getFactor(this.style, this.factor, h)
    const dx1 = getFactor(this.style, this.position1, w, 1, 'position')
    const dx2 = getFactor(this.style, this.position2, w, 1, 'position2')
    const base = getFactor(this.style, this.base, w, 1, 'base')

    this.drawPoints(
      c,
      [
        new Point(0, 0),
        new Point(w, 0),
        new Point(w, h - s),
        new Point(Math.min(w, dx1 + base), h - s),
        new Point(dx2, h),
        new Point(Math.max(0, dx1), h - s),
        new Point(0, h - s),
      ],
      this.rounded,
      arcSize,
      true,
      [4],
    )
  }
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / parallelogram.ts View on Github external
redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    const dx = getFactor(this.style, this.factor, w)
    const arcSize = (this.state.style.arcSize || 20) / 2

    this.drawPoints(
      c,
      [
        new Point(0, h),
        new Point(dx, 0),
        new Point(w, 0),
        new Point(w - dx, h),
      ],
      this.rounded,
      arcSize,
      true,
    )
  }
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / parallelogram.ts View on Github external
const x = bounds.x
  const y = bounds.y
  const w = bounds.width
  const h = bounds.height

  const direction = (state != null && state.style.direction) || 'east'
  const vertical = direction === 'north' || direction === 'south'

  let points: Point[]

  if (vertical) {
    const dy = getFactor(style, defaultFactor, h)
    points = [
      new Point(x, y),
      new Point(x + w, y + dy),
      new Point(x + w, y + h),
      new Point(x, y + h - dy),
      new Point(x, y),
    ]
  } else {
    const dx = getFactor(style, defaultFactor, w)
    points = [
      new Point(x + dx, y),
      new Point(x + w, y),
      new Point(x + w - dx, y + h),
      new Point(x, y + h),
      new Point(x + dx, y),
    ]
  }

  const center = bounds.getCenter()
  if (orthogonal) {
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / sidebar-util.ts View on Github external
thumbWidth: number,
    thumbHeight: number,
    thumbBorder: number,
  ) => {
    const width = item.width
    const height = item.height
    const graph = getTempGraph()

    graph.view.scaleAndTranslate(1, 0, 0)
    if (item.isEdge) {
      graph.addEdge({
        label: item.data,
        style: { ...item.style, stroke: '#000' },
        points: item.points ? [...item.points] : [],
        sourcePoint: new Point(0, height),
        targetPoint: new Point(width, 0),
      })
    } else {
      graph.addNode({
        width,
        height,
        label: item.data,
        style: item.style,
      })
    }

    const elem = renderThumb(
      graph,
      container,
      thumbWidth,
      thumbHeight,
      thumbBorder,