diff --git a/packages/x6/src/addon/shape/callout.ts b/packages/x6/src/addon/shape/callout.ts deleted file mode 100644 index 5307101166c..00000000000 --- a/packages/x6/src/addon/shape/callout.ts +++ /dev/null @@ -1,72 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { State } from '../../core/state' -import { Shape, Actor } from '../../shape' -import { SvgCanvas2D } from '../../canvas' -import { Perimeter } from '../../perimeter' -import { Point, Rectangle } from '../../struct' -import { rectanglePerimeter } from '../../perimeter/rectangle' - -export class CalloutShape extends Actor { - base = 20 - factor = 30 - position1 = 0.5 - position2 = 0.5 - - isRoundable() { - return true - } - - getLabelMargins() { - return new Rectangle( - 0, - 0, - 0, - util.getNumber(this.style, 'factor', this.factor) * this.scale, - ) - } - - 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], - ) - } -} - -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 rectanglePerimeter(directedBounds, state, next, orthogonal) -} - -Shape.register('callout', CalloutShape) -Perimeter.register('calloutPerimeter', calloutPerimeter) diff --git a/packages/x6/src/addon/shape/card.ts b/packages/x6/src/addon/shape/card.ts deleted file mode 100644 index 14527c2b066..00000000000 --- a/packages/x6/src/addon/shape/card.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as util from '../../util' -import { Point } from '../../struct' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' - -export class CardShape extends Actor { - factor: number = 30 - - isRoundable() { - return true - } - - redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const arcSize = this.getLineArcSize() - const factor = util.getNumber(this.style, 'factor', this.factor) - const s = Math.max(0, Math.min(w, Math.min(h, factor))) - - this.drawPoints( - c, - [ - 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) diff --git a/packages/x6/src/addon/shape/cube.ts b/packages/x6/src/addon/shape/cube.ts deleted file mode 100644 index ab2ae67fe97..00000000000 --- a/packages/x6/src/addon/shape/cube.ts +++ /dev/null @@ -1,93 +0,0 @@ -import * as util from '../../util' -import { Rectangle } from '../../struct' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Cylinder } from '../../shape' - -export class CubeShape extends Cylinder { - factor: number = 20 - darkOpacity: number = 0 - darkOpacity2: number = 0 - - isHtmlAllowed() { - return false - } - - getLabelMargins(rect: Rectangle) { - if (util.getBoolean(this.style, 'boundedLbl', false)) { - const s = util.getNumber(this.style, 'factor', this.factor) * this.scale - return new Rectangle(s, s, 0, 0) - } - - return null - } - - drawNodeShape(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const factor = util.getNumber(this.style, 'factor', this.factor) - const darkOpacity = util.getNumber( - this.style, - 'darkOpacity', - this.darkOpacity - ) - const darkOpacity2 = util.getNumber( - this.style, - 'darkOpacity2', - this.darkOpacity2 - ) - const s = Math.max(0, Math.min(w, Math.min(h, factor))) - const op = Math.max(-1, Math.min(1, darkOpacity)) - const op2 = Math.max(-1, Math.min(1, darkOpacity2)) - c.translate(x, y) - - c.begin() - c.moveTo(0, 0) - c.lineTo(w - s, 0) - c.lineTo(w, s) - c.lineTo(w, h) - c.lineTo(s, h) - c.lineTo(0, h - s) - c.lineTo(0, 0) - c.close() - c.end() - - c.fillAndStroke() - - if (!this.outline) { - c.setShadow(false) - - if (op !== 0) { - c.setFillOpacity(Math.abs(op)) - c.setFillColor(op < 0 ? '#ffffff' : '#000000') - c.begin() - c.moveTo(0, 0) - c.lineTo(w - s, 0) - c.lineTo(w, s) - c.lineTo(s, s) - c.close() - c.fill() - } - - if (op2 !== 0) { - c.setFillOpacity(Math.abs(op2)) - c.setFillColor(op2 < 0 ? '#ffffff' : '#000000') - c.begin() - c.moveTo(0, 0) - c.lineTo(s, s) - c.lineTo(s, h) - c.lineTo(0, h - s) - c.close() - 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) diff --git a/packages/x6/src/addon/shape/data-storage.ts b/packages/x6/src/addon/shape/data-storage.ts deleted file mode 100644 index d8e2ccb21d1..00000000000 --- a/packages/x6/src/addon/shape/data-storage.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { getFactor } from './util' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' - -export class DataStorageShape extends Actor { - factor: number = 0.1 - - redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const s = getFactor(this.style, this.factor, w) - c.moveTo(s, 0) - c.lineTo(w, 0) - c.quadTo(w - s * 2, h / 2, w, h) - c.lineTo(s, h) - c.quadTo(s - s * 2, h / 2, s, 0) - c.close() - c.end() - } -} - -Shape.register('dataStorage', DataStorageShape) diff --git a/packages/x6/src/addon/shape/document.ts b/packages/x6/src/addon/shape/document.ts deleted file mode 100644 index 718c6473c4e..00000000000 --- a/packages/x6/src/addon/shape/document.ts +++ /dev/null @@ -1,33 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { Rectangle } from '../../struct' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' - -export class DocumentShape extends Actor { - factor: number = 0.3 - - getLabelMargins(rect: Rectangle) { - if (util.getBoolean(this.style, 'boundedLbl', false)) { - const dy = getFactor(this.style, this.factor, rect.height) - return new Rectangle(0, 0, 0, dy) - } - - return null - } - - redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const dy = getFactor(this.style, this.factor, h) - const fy = 1.4 - - c.moveTo(0, 0) - c.lineTo(w, 0) - c.lineTo(w, h - dy / 2) - c.quadTo((w * 3) / 4, h - dy * fy, w / 2, h - dy / 2) - c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2) - c.lineTo(0, dy / 2) - c.close() - } -} - -Shape.register('document', DocumentShape) diff --git a/packages/x6/src/addon/shape/flex-arrow.ts b/packages/x6/src/addon/shape/flex-arrow.ts deleted file mode 100644 index 3815946bb73..00000000000 --- a/packages/x6/src/addon/shape/flex-arrow.ts +++ /dev/null @@ -1,35 +0,0 @@ -import * as util from '../../util' -import { Shape, ArrowConnector } from '../../shape' - -export class FlexArrowShape extends ArrowConnector { - defaultWidth = 10 - defaultArrowWidth = 20 - - constructor() { - super() - this.spacing = 0 - } - - getStartArrowWidth() { - return ( - this.getEdgeWidth() + - util.getNumber(this.style, 'startWidth', this.defaultArrowWidth) - ) - } - - 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) diff --git a/packages/x6/src/addon/shape/index.ts b/packages/x6/src/addon/shape/index.ts deleted file mode 100644 index c325cf484a8..00000000000 --- a/packages/x6/src/addon/shape/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from './process' -export * from './parallelogram' -export * from './document' -export * from './internal-storage' -export * from './cube' -export * from './step' -export * from './trapezoid' -export * from './tape' -export * from './note' -export * from './card' -export * from './callout' -export * from './uml-actor' -export * from './logic' -export * from './data-storage' -export * from './flex-arrow' -export * from './link' diff --git a/packages/x6/src/addon/shape/internal-storage.ts b/packages/x6/src/addon/shape/internal-storage.ts deleted file mode 100644 index 89948194dcf..00000000000 --- a/packages/x6/src/addon/shape/internal-storage.ts +++ /dev/null @@ -1,37 +0,0 @@ -import * as util from '../../util' -import { SvgCanvas2D } from '../../canvas' -import { Shape, RectangleShape } from '../../shape' - -export class InternalStorageShape extends RectangleShape { - dx: number = 20 - dy: number = 20 - - isHtmlAllowed() { - return false - } - - drawForeground(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - super.drawForeground(c, x, y, w, h) - - let inset = 0 - if (this.rounded) { - const f = (this.style.arcSize || 0.15 * 100) / 100 - inset = Math.max(inset, Math.min(w * f, h * f)) - } - - const dx = util.clamp(util.getNumber(this.style, 'dx', this.dx), inset, w) - const dy = util.clamp(util.getNumber(this.style, 'dy', this.dy), inset, h) - - c.begin() - c.moveTo(x, y + dy) - c.lineTo(x + w, y + dy) - c.stroke() - - c.begin() - c.moveTo(x + dx, y) - c.lineTo(x + dx, y + h) - c.stroke() - } -} - -Shape.register('internalStorage', InternalStorageShape) diff --git a/packages/x6/src/addon/shape/link.ts b/packages/x6/src/addon/shape/link.ts deleted file mode 100644 index 84af4341b1e..00000000000 --- a/packages/x6/src/addon/shape/link.ts +++ /dev/null @@ -1,28 +0,0 @@ -import * as util from '../../util' -import { Shape, ArrowConnector } from '../../shape' - -export class LinkShape extends ArrowConnector { - defaultWidth = 4 - - constructor() { - super() - this.spacing = 0 - } - - isOpenEnded() { - return true - } - - isArrowRounded() { - return this.rounded - } - - getEdgeWidth() { - return ( - util.getNumber(this.style, 'width', this.defaultWidth) + - Math.max(0, this.strokeWidth - 1) - ) - } -} - -Shape.register('link', LinkShape) diff --git a/packages/x6/src/addon/shape/logic.ts b/packages/x6/src/addon/shape/logic.ts deleted file mode 100644 index 6fafec7f9af..00000000000 --- a/packages/x6/src/addon/shape/logic.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' - -export class OrShape extends 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.close() - c.end() - } -} - -export class XorShape extends 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) diff --git a/packages/x6/src/addon/shape/note.ts b/packages/x6/src/addon/shape/note.ts deleted file mode 100644 index 42a612c8c59..00000000000 --- a/packages/x6/src/addon/shape/note.ts +++ /dev/null @@ -1,55 +0,0 @@ -import * as util from '../../util' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Cylinder } from '../../shape' - -export class NoteShape extends Cylinder { - factor: number = 30 - darkOpacity: number = 0 - - drawNodeShape(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const factor = util.getNumber(this.style, 'factor', this.factor) - const darkOpacity = util.getNumber( - this.style, - 'darkOpacity', - this.darkOpacity - ) - const s = Math.max(0, Math.min(w, Math.min(h, factor))) - const op = Math.max(-1, Math.min(1, darkOpacity)) - c.translate(x, y) - - c.begin() - c.moveTo(0, 0) - c.lineTo(w - s, 0) - c.lineTo(w, s) - c.lineTo(w, h) - c.lineTo(0, h) - c.lineTo(0, 0) - c.close() - c.end() - c.fillAndStroke() - - if (!this.outline) { - c.setShadow(false) - - if (op !== 0) { - c.setFillOpacity(Math.abs(op)) - c.setFillColor(op < 0 ? '#FFFFFF' : '#000000') - c.begin() - c.moveTo(w - s, 0) - c.lineTo(w - s, s) - c.lineTo(w, s) - c.close() - c.fill() - } - - c.begin() - c.moveTo(w - s, 0) - c.lineTo(w - s, s) - c.lineTo(w, s) - c.end() - c.stroke() - } - } -} - -Shape.register('note', NoteShape) diff --git a/packages/x6/src/addon/shape/parallelogram.ts b/packages/x6/src/addon/shape/parallelogram.ts deleted file mode 100644 index eaafa1e90f5..00000000000 --- a/packages/x6/src/addon/shape/parallelogram.ts +++ /dev/null @@ -1,87 +0,0 @@ -import * as util from '../../util' -import { State } from '../../core/state' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' -import { Perimeter } from '../../perimeter' -import { Point, Rectangle } from '../../struct' -import { getFactor } from './util' - -export class ParallelogramShape extends Actor { - factor = 0.2 - - isRoundable() { - return true - } - - 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, - ) - } -} - -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) { - 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) { - 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) diff --git a/packages/x6/src/addon/shape/process.ts b/packages/x6/src/addon/shape/process.ts deleted file mode 100644 index be053b4ebeb..00000000000 --- a/packages/x6/src/addon/shape/process.ts +++ /dev/null @@ -1,64 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { SvgCanvas2D } from '../../canvas' -import { Rectangle } from '../../struct' -import { Direction } from '../../types' -import { Shape, RectangleShape } from '../../shape' - -export class ProcessShape extends RectangleShape { - factor: number = 0.1 - direction: Direction - - isHtmlAllowed() { - return false - } - - getInset(width: number, height: number, round?: boolean) { - let inset = getFactor(this.style, this.factor, width) - - if (this.rounded) { - const f = (this.style.arcSize || 0.15 * 100) / 100 - inset = util.clamp(f * width, f * height, inset) - } - - if (round) { - inset = Math.round(inset) - } - - return inset - } - - getLabelBounds(rect: Rectangle) { - const style = this.state.style - const horizontal = style.horizontal != null ? style.horizontal : true - if ( - horizontal === - (this.direction == null || - this.direction === 'east' || - this.direction === 'west') - ) { - const bounds = rect.clone() - const inset = this.getInset(rect.width, rect.height) - bounds.x += Math.round(inset) - bounds.width -= Math.round(2 * inset) - return bounds - } - - return rect - } - - 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) diff --git a/packages/x6/src/addon/shape/step.ts b/packages/x6/src/addon/shape/step.ts deleted file mode 100644 index e5db8412c5a..00000000000 --- a/packages/x6/src/addon/shape/step.ts +++ /dev/null @@ -1,120 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { Style } from '../../types' -import { State } from '../../core/state' -import { SvgCanvas2D } from '../../canvas' -import { Perimeter } from '../../perimeter' -import { Point, Rectangle } from '../../struct' -import { Shape, Actor } from '../../shape' - -export class StepShape extends Actor { - factor: number = 0.2 - - isRoundable() { - return true - } - - 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() - } -} - -export function stepPerimeter( - bounds: Rectangle, - state: State, - next: Point, - orthogonal: boolean, -) { - const defaultFactor = StepShape.prototype.factor - const style: Style = state ? state.style : {} - - 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), - ] - } 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), - ] - } - - 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) diff --git a/packages/x6/src/addon/shape/tape.ts b/packages/x6/src/addon/shape/tape.ts deleted file mode 100644 index 2fb441bc218..00000000000 --- a/packages/x6/src/addon/shape/tape.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { Rectangle } from '../../struct' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' - -export class TapeShape extends Actor { - factor: number = 0.4 - - 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 - } - - redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const dy = getFactor(this.style, this.factor, h) - const fy = 1.4 - - c.moveTo(0, dy / 2) - c.quadTo(w / 4, dy * fy, w / 2, dy / 2) - c.quadTo((w * 3) / 4, dy * (1 - fy), w, dy / 2) - c.lineTo(w, h - dy / 2) - c.quadTo((w * 3) / 4, h - dy * fy, w / 2, h - dy / 2) - c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2) - c.lineTo(0, dy / 2) - c.close() - c.end() - } -} - -Shape.register('tape', TapeShape) diff --git a/packages/x6/src/addon/shape/trapezoid.ts b/packages/x6/src/addon/shape/trapezoid.ts deleted file mode 100644 index 30428177321..00000000000 --- a/packages/x6/src/addon/shape/trapezoid.ts +++ /dev/null @@ -1,105 +0,0 @@ -import * as util from '../../util' -import { getFactor } from './util' -import { Style } from '../../types' -import { State } from '../../core/state' -import { Perimeter } from '../../perimeter' -import { SvgCanvas2D } from '../../canvas' -import { Shape, Actor } from '../../shape' -import { Point, Rectangle } from '../../struct' - -export class TrapezoidShape extends Actor { - factor: number = 0.2 - - isRoundable() { - return true - } - - redrawPath(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - const dx = getFactor(this.style, this.factor, w, 0.5) - const arcSize = this.getLineArcSize() - - this.drawPoints( - c, - [ - new Point(0, h), - new Point(dx, 0), - new Point(w - dx, 0), - new Point(w, h), - ], - this.rounded, - arcSize, - true, - ) - } -} - -export function trapezoidPerimeter( - bounds: Rectangle, - state: State, - next: Point, - orthogonal: boolean, -) { - const defaultFactor = TrapezoidShape.prototype.factor - const style: Style = state ? state.style : {} - - const x = bounds.x - const y = bounds.y - const w = bounds.width - const h = bounds.height - - const direction = (state != null && state.style.direction) || 'east' - let points: Point[] - - if (direction === 'east') { - const dx = getFactor(style, defaultFactor, w) - points = [ - new Point(x + dx, y), - new Point(x + w - dx, y), - new Point(x + w, y + h), - new Point(x, y + h), - new Point(x + dx, y), - ] - } 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) { - 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('trapezoid', TrapezoidShape) -Perimeter.register('trapezoidPerimeter', trapezoidPerimeter) diff --git a/packages/x6/src/addon/shape/uml-actor.ts b/packages/x6/src/addon/shape/uml-actor.ts deleted file mode 100644 index 63225d230cc..00000000000 --- a/packages/x6/src/addon/shape/uml-actor.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Shape } from '../../shape' -import { SvgCanvas2D } from '../../canvas' - -export class UmlActorShape extends Shape { - drawBackground(c: SvgCanvas2D, x: number, y: number, w: number, h: number) { - c.translate(x, y) - - // Head - c.ellipse(w / 4, 0, w / 2, h / 4) - c.fillAndStroke() - - c.begin() - c.moveTo(w / 2, h / 4) - c.lineTo(w / 2, (2 * h) / 3) - - // Arms - c.moveTo(w / 2, h / 3) - 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) diff --git a/packages/x6/src/addon/shape/util.ts b/packages/x6/src/addon/shape/util.ts deleted file mode 100644 index af0b851beab..00000000000 --- a/packages/x6/src/addon/shape/util.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as util from '../../util' -import { Style } from '../../types' - -export function getFactor( - style: Style, - defaultFactor: number, - size: number, - max: number = 1, - key: string = 'factor' -) { - const factor = util.getNumber(style, key, defaultFactor) - return clampFactor(factor, size, max) -} - -export function clampFactor(factor: number, size: number, max: number = 1) { - return factor > 1 - ? util.clamp(factor, 0, size * max) - : util.clamp(factor, 0, max) * size -}