d3#easePolyOut TypeScript Examples

The following examples show how to use d3#easePolyOut. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Progress.ts    From anichart.js with MIT License 6 votes vote down vote up
getComponent(sec: number) {
    const val = scaleLinear(this.aniTime, [0, 100])
      .clamp(true)
      .interpolate(easeInterpolate(easePolyOut.exponent(5)))(sec);

    const label = format("d")(val);
    const res = this.ani.getComponent(sec);
    const textLabel = new Text({
      text: val === 100 ? `` : `Loading ${label} %`,
      font,
      fontSize: 24,
      textAlign: "center",
      textBaseline: "top",
      position: { x: 0, y: this.shape.height },
      fillStyle: "#fff",
    });
    res?.children.push(textLabel);
    return res;
  }
Example #2
Source File: Progress.ts    From anichart.js with MIT License 4 votes vote down vote up
constructor(options?: ProgressOptions) {
    super();
    if (options) {
      this.position = options.position ?? { x: 0, y: 0 };
      this.aniTime = options.aniTime ?? [0, 3];
      this.shape = options.shape ?? { width: 400, height: 18 };
      this.color = options.color ?? "#FFF";
    }
    const border0 = new Rect({
      shape: {
        width: this.shape.width,
        height: this.shape.height,
      },
      center: { x: this.shape.width / 2, y: this.shape.height / 2 },
      alpha: 1,
      radius: this.radius,
      fillStyle: "#0006",
      strokeStyle: this.color,
      lineWidth: this.lineWidth,
    });
    const border1 = new Rect({
      shape: {
        width: this.shape.width * 1.75,
        height: this.shape.height,
      },
      center: {
        x: (this.shape.width * 1.75) / 2,
        y: this.shape.height / 2,
      },
      alpha: 1,
      radius: this.radius,
      fillStyle: "#0006",
      strokeStyle: this.color,
      lineWidth: this.lineWidth,
    });
    const bar0 = new Rect({
      position: { x: this.padding, y: this.padding },
      center: { x: this.shape.width / 2, y: this.shape.height / 2 },
      shape: { width: 0, height: this.shape.height - this.padding * 2 },
      radius: this.radius,
      fillStyle: this.color,
    });
    const bar1 = new Rect({
      position: { x: this.padding, y: this.padding },
      center: { x: (this.shape.width / 2) * 1.75, y: this.shape.height / 2 },
      shape: {
        width: (this.shape.width - this.padding * 2) * 1.75,
        height: this.shape.height - this.padding * 2,
      },
      radius: this.radius,
      fillStyle: this.color,
    });

    const start = new Component({
      position: this.position,
      scale: { x: 2, y: 2 },
    });
    start.children.push(border0);
    start.children.push(bar0);
    const end = new Component({
      position: this.position,
      scale: { x: 1, y: 1 },
    });
    end.children.push(border1);
    end.children.push(bar1);

    const borderFinished = new Rect({
      shape: {
        width: this.shape.width * 2,
        height: this.shape.height * 2,
      },
      center: {
        x: (this.shape.width * 2) / 2,
        y: (this.shape.height * 2) / 2,
      },
      alpha: 0,
      radius: this.radius,
      fillStyle: "#0006",
      strokeStyle: "#27C",
      lineWidth: this.lineWidth,
    });
    const bar2 = new Rect({
      center: { x: this.shape.width / 2, y: this.shape.height / 2 },
      position: { x: this.padding, y: this.padding },
      shape: {
        width: this.shape.width - this.padding * 2,
        height: this.shape.height - this.padding * 2,
      },
      alpha: 0.0,
      radius: this.radius,
      fillStyle: "#27C",
    });
    const final = new Component({
      position: this.position,
      alpha: 1,
      scale: { x: 1.2, y: 1.2 },
    });
    final.children.push(borderFinished);
    final.children.push(bar2);

    const objCopy = Object.assign({}, final);
    objCopy.alpha = 0;
    this.ani = customAni(this.aniTime[0])
      .keyFrame(start)
      .duration(this.aniTime[1], easePolyOut.exponent(5))
      .keyFrame(end)
      .duration(0.25, easeExpOut)
      .keyFrame(final)
      .duration(0.5)
      .keyFrame(final)
      .duration(0.2)
      .keyFrame(objCopy);
  }