How to use the @antv/x6.util.clamp 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 / internal-storage.ts View on Github external
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()
  }
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / process.ts View on Github external
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
  }
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / util.ts View on Github external
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
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / util.ts View on Github external
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
}
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / format-cell.tsx View on Github external
<div>
          <div>
            
              Opacity
            
            {this.state.opacity != null &amp;&amp; (
               `${value!}%`}
                parser={value =&gt; value!.replace(/%$/g, '')}
                style={{ flex: 1 }}
              /&gt;
            )}
          </div>
        </div>
        <div>
          <div>
            </div></div>
github antvis / x6 / examples / x6-example-drawio / src / pages / graph / shape / internal-storage.ts View on Github external
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()
  }
}