Skip to content

Commit

Permalink
fix: watermark font size error
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowballXueQiu committed Aug 23, 2024
1 parent baa0888 commit 689e01c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/(root)/backstage/components/Watermark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export default function Watermark({
const ctx = canvas.getContext('2d');

if (ctx) {
ctx.font = font;
const { width } = ctx.measureText(text);
const canvasSize = Math.max(100, width) + gap * devicePixelRatio;
canvas.width = canvasSize;
canvas.height = canvasSize;

ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate((-45 * Math.PI) / 180);
ctx.fillStyle = 'rgba(0, 0, 0, 0.3)';
ctx.fillStyle = 'rgba(0, 0, 0, 0.2)';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = font;
ctx.fillText(text, 0, 0);

return {
Expand Down
4 changes: 2 additions & 2 deletions app/(root)/backstage/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default function BackStageLayout({ children }: { children: React.ReactNod
<div>
<Watermark
text={`${userName} ${userId}`}
fontSize={20}
gap={5}
fontSize={40}
gap={200}
>
{children}
<Tools />
Expand Down

0 comments on commit 689e01c

Please sign in to comment.