Jump to content
Search Community

Issue animation sine wave

Kirdes test
Moderator Tag

Recommended Posts

You just need to use save and restore as setTransform resets the transforms.

 

draw(ctx) {
    const { width, height } = ctx.canvas;

    ctx.save();
    ctx.setTransform(1, 0, 0, 1, this.transform.x, 0);

    ctx.beginPath();
    ctx.moveTo(this.moveTo.x, this.moveTo.y);
    ctx.lineTo(this.start.x, this.start.y);
    for (const { x, y } of this.points) {
      ctx.lineTo(x, y);
    }
    ctx.lineTo(this.end.x, this.end.y);
    ctx.fillStyle = "black";
    ctx.fill();
    ctx.restore();
  }

 

 

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...