Kirdes Posted February 10, 2022 Share Posted February 10, 2022 Hi. Any idea why my animation breaks when the two panels are animated ? See the Pen WNXjvyP?editors=0010 by kirdesmf (@kirdesmf) on CodePen Link to comment Share on other sites More sharing options...
OSUblake Posted February 10, 2022 Share Posted February 10, 2022 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(); } 3 Link to comment Share on other sites More sharing options...
Kirdes Posted February 10, 2022 Author Share Posted February 10, 2022 Just found out. Thx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now