Skip to content

Commit

Permalink
Fix alpha channel not working (Box2D + Text2D)
Browse files Browse the repository at this point in the history
  • Loading branch information
nahkd123 committed Sep 29, 2024
1 parent d975ba3 commit f3edd2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nahara-motion/src/system/scene/box2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Box2D implements ISceneObjectWithPositionalData, ISceneObjectWithSi
const height = this.height.get(context.time);
const rotation = this.rotation.get(context.time);
const color = this.color.get(context.time);
context.canvas.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a ?? 255})`;
context.canvas.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${(color.a ?? 255) / 255})`;

context.canvas.translate(x + width / 2, y + height / 2);
context.canvas.rotate(rotation * Math.PI / 180);
Expand Down
2 changes: 1 addition & 1 deletion nahara-motion/src/system/scene/text2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Text2D implements ISceneObjectWithPositionalData {
const size = this.size.get(context.time);
const color = this.color.get(context.time);
context.canvas.font = `${size}px ${this.font}`;
context.canvas.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a ?? 255})`;
context.canvas.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${(color.a ?? 255) / 255})`;
context.canvas.save();
context.canvas.translate(x, y);
context.canvas.scale(scaleX, scaleY);
Expand Down

0 comments on commit f3edd2a

Please sign in to comment.