How to use the @swim/math.BoxR2 function in @swim/math

To help you get started, we’ve selected a few @swim/math 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 swimos / swim / swim-system-js / swim-ux-js / @swim / map / main / MapLayerView.ts View on Github external
protected layoutChildView(childView: View): void {
    if (RenderView.is(childView)) {
      let bounds = this._bounds;
      let anchor = this._anchor;
      const x = bounds.x;
      const y = bounds.y;
      if (bounds.x !== 0 || bounds.y !== 0) {
        // transform bounds into layer coordinates
        const width = bounds.width;
        const height = bounds.height;
        bounds = new BoxR2(0, 0, width, height);
      }
      if (x !== 0 || y !== 0) {
        // transform anchor into layer coordinates
        anchor = new PointR2(anchor.x - x, anchor.y - y);
      }
      childView.setBounds(bounds);
      childView.setAnchor(anchor);
    }
  }
github swimos / swim / swim-system-js / swim-ui-js / @swim / view / main / LayerView.ts View on Github external
protected layoutChildView(childView: View): void {
    if (RenderView.is(childView)) {
      let bounds = this._bounds;
      let anchor = this._anchor;
      const x = bounds.x;
      const y = bounds.y;
      if (bounds.x !== 0 || bounds.y !== 0) {
        // transform bounds into layer coordinates
        const width = bounds.width;
        const height = bounds.height;
        bounds = new BoxR2(0, 0, width, height);
      }
      if (x !== 0 || y !== 0) {
        // transform anchor into layer coordinates
        anchor = new PointR2(anchor.x - x, anchor.y - y);
      }
      childView.setBounds(bounds);
      childView.setAnchor(anchor);
    }
  }
github swimos / swim / swim-system-js / swim-ux-js / @swim / map / main / MapPolygonView.ts View on Github external
for (let i = 0; i < n; i += 1) {
        const coord = coords[i].value!;
        const point = projection.project(coord);
        points[i] = point;
        cx += point.x;
        cy += point.y;
        invalid = invalid || !isFinite(point.x) || !isFinite(point.y);
        xMin = Math.min(xMin, point.x);
        yMin = Math.min(yMin, point.y);
        xMax = Math.max(point.x, xMax);
        yMax = Math.max(point.y, yMax);
      }
      cx /= n;
      cy /= n;
      if (!invalid) {
        hitBounds = new BoxR2(xMin, yMin, xMax, yMax);
      }
    }
    this._hitBounds = hitBounds;
    this.setAnchor(new PointR2(cx, cy));
  }
github swimos / swim / swim-system-js / swim-ux-js / @swim / map / main / MapLayerView.ts View on Github external
protected willSetBounds(bounds: BoxR2): BoxR2 | void {
    const newBounds = super.willSetBounds(bounds);
    if (newBounds instanceof BoxR2) {
      bounds = newBounds;
    }
    const xMin = Math.round(bounds.xMin);
    const yMin = Math.round(bounds.yMin);
    const xMax = Math.round(bounds.xMax);
    const yMax = Math.round(bounds.yMax);
    return new BoxR2(xMin, yMin, xMax, yMax);
  }
github swimos / swim / swim-system-js / swim-ui-js / @swim / view / main / LayerView.ts View on Github external
protected willSetBounds(bounds: BoxR2): BoxR2 | void {
    const newBounds = super.willSetBounds(bounds);
    if (newBounds instanceof BoxR2) {
      bounds = newBounds;
    }
    const xMin = Math.round(bounds.xMin);
    const yMin = Math.round(bounds.yMin);
    const xMax = Math.round(bounds.xMax);
    const yMax = Math.round(bounds.yMax);
    return new BoxR2(xMin, yMin, xMax, yMax);
  }

@swim/math

Mathematical and geometric structures and operators

Apache-2.0
Latest version published 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages