How to use @swim/math - 10 common examples

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 / 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 / chart / main / axis / RightAxisView.ts View on Github external
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
    const dy = this.scale.value!.scale(tick.value);
    const ax = anchor.x;
    const ay = anchor.y + dy;
    const tickAnchor = new PointR2(ax, ay);
    tick.setBounds(bounds);
    tick.setAnchor(tickAnchor);
    tick.setCoord(dy);
  }
}
github swimos / swim / swim-system-js / swim-ux-js / @swim / map / main / MapPolygonView.ts View on Github external
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-js / swim-vis-js / @swim / chart / main / tick / BottomTickView.ts View on Github external
protected layoutTickLabel(tickLabel: RenderView, bounds: BoxR2, anchor: PointR2): void {
    const x = Math.round(anchor.x);
    const y0 = Math.round(anchor.y);
    const y1 = y0 + this.tickMarkLength.value!;
    const y2 = y1 + this.tickLabelPadding.value!;

    const tickLabelAnchor = new PointR2(x, y2);
    tickLabel.setAnchor(tickLabelAnchor);
    if (TypesetView.is(tickLabel)) {
      tickLabel.textAlign("center");
      tickLabel.textBaseline("top");
    }
  }
github swimos / swim / swim-system-js / swim-ux-js / @swim / chart / main / axis / LeftAxisView.ts View on Github external
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
    const dy = this.scale.value!.scale(tick.value);
    const ax = anchor.x;
    const ay = anchor.y + dy;
    const tickAnchor = new PointR2(ax, ay);
    tick.setBounds(bounds);
    tick.setAnchor(tickAnchor);
    tick.setCoord(dy);
  }
}
github swimos / swim / swim-js / swim-vis-js / @swim / chart / main / axis / TopAxisView.ts View on Github external
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
    const dx = this.scale.value!.scale(tick.value);
    const ax = anchor.x + dx;
    const ay = anchor.y;
    const tickAnchor = new PointR2(ax, ay);
    tick.setBounds(bounds);
    tick.setAnchor(tickAnchor);
    tick.setCoord(dx);
  }
}
github swimos / swim / swim-system-js / swim-ux-js / @swim / chart / main / tick / RightTickView.ts View on Github external
protected layoutTickLabel(tickLabel: RenderView, bounds: BoxR2, anchor: PointR2): void {
    const x0 = Math.round(anchor.x);
    const y = Math.round(anchor.y);
    const x1 = x0 + this.tickMarkLength.value!;
    const x2 = x1 + this.tickLabelPadding.value!;

    const tickLabelAnchor = new PointR2(x2, y);
    tickLabel.setAnchor(tickLabelAnchor);
    if (TypesetView.is(tickLabel)) {
      tickLabel.textAlign("left");
      tickLabel.textBaseline("middle");
    }
  }

@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