How to use the @antv/x6.Shape.register 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 / uml-actor.ts View on Github external
c.lineTo(0, h / 3)
    c.moveTo(w / 2, h / 3)
    c.lineTo(w, h / 3)

    // Legs
    c.moveTo(w / 2, (2 * h) / 3)
    c.lineTo(0, h)
    c.moveTo(w / 2, (2 * h) / 3)
    c.lineTo(w, h)
    c.end()

    c.stroke()
  }
}

Shape.register('umlActor', UmlActorShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / step.ts View on Github external
}

  const p1 = new Point(cx, cy)

  if (orthogonal) {
    if (next.x < x || next.x > x + w) {
      p1.y = next.y
    } else {
      p1.x = next.x
    }
  }

  return util.getPerimeterPoint(points, p1, next) as Point
}

Shape.register('step', StepShape)
Perimeter.register('stepPerimeter', stepPerimeter)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / logic.ts View on Github external
}
}

export class XorShape extends Shape.Actor {
  redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    c.moveTo(0, 0)
    c.quadTo(w, 0, w, h / 2)
    c.quadTo(w, h, 0, h)
    c.quadTo(w / 2, h / 2, 0, 0)
    c.close()
    c.end()
  }
}

Shape.register('or', OrShape)
Shape.register('xor', XorShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / cube.ts View on Github external
c.fill()
      }

      c.begin()
      c.moveTo(s, h)
      c.lineTo(s, s)
      c.lineTo(0, 0)
      c.moveTo(s, s)
      c.lineTo(w, s)
      c.end()
      c.stroke()
    }
  }
}

Shape.register('cube', CubeShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / flex-arrow.ts View on Github external
getEndArrowWidth() {
    return (
      this.getEdgeWidth() +
      util.getNumber(this.style, 'endWidth', this.defaultArrowWidth)
    )
  }

  getEdgeWidth() {
    return (
      util.getNumber(this.style, 'width', this.defaultWidth) +
      Math.max(0, this.strokeWidth - 1)
    )
  }
}

Shape.register('flexArrow', FlexArrowShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / callout.ts View on Github external
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)
}

Shape.register('callout', CalloutShape)
Perimeter.register('calloutPerimeter', calloutPerimeter)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / card.ts View on Github external
new Point(s, 0),
        new Point(w, 0),
        new Point(w, h),
        new Point(0, h),
        new Point(0, s),
      ],
      this.rounded,
      arcSize,
      true,
    )

    c.end()
  }
}

Shape.register('card', CardShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / parallelogram.ts View on Github external
]
  }

  const center = bounds.getCenter()
  if (orthogonal) {
    if (next.x < x || next.x > x + w) {
      center.y = next.y
    } else {
      center.x = next.x
    }
  }

  return util.getPerimeterPoint(points, center, next) as Point
}

Shape.register('parallelogram', ParallelogramShape)
Perimeter.register('parallelogramPerimeter', parallelogramPerimeter)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / process.ts View on Github external
drawForeground(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    const inset = this.getInset(w, h, true)

    c.begin()
    c.moveTo(x + inset, y)
    c.lineTo(x + inset, y + h)
    c.moveTo(x + w - inset, y)
    c.lineTo(x + w - inset, y + h)
    c.stroke()

    super.drawForeground(c, x, y, w, h)
  }
}

Shape.register('process', ProcessShape)
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / logic.ts View on Github external
c.end()
  }
}

export class XorShape extends Shape.Actor {
  redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) {
    c.moveTo(0, 0)
    c.quadTo(w, 0, w, h / 2)
    c.quadTo(w, h, 0, h)
    c.quadTo(w / 2, h / 2, 0, 0)
    c.close()
    c.end()
  }
}

Shape.register('or', OrShape)
Shape.register('xor', XorShape)