Position of watermark text now calculated in polar coordinates

Watermark text will now appear to rotate around the page centre, rather than at the bottom corner of the text element.
This commit is contained in:
Richard Grimes authored and GitHub committed 2026-01-30 11:50:17 +01:00
1 parent 75df8a48cb
commit 5e66d42f59
1 file changed
+2 -2
+2 -2
View File
@@ -178,8 +178,8 @@ async function addWatermark() {
const textWidth = watermarkAsset.widthOfTextAtSize(text, fontSize);
page.drawText(text, {
x: (width - textWidth) / 2,
y: height / 2,
x: (width / 2) - ((textWidth / 2) * Math.cos(angle * Math.PI / 180)),
y: (height / 2) - ((textWidth / 2) * Math.sin(angle * Math.PI / 180)),
font: watermarkAsset,
size: fontSize,
color: rgb(textColor.r, textColor.g, textColor.b),