This commit is contained in:
2026-04-28 11:01:03 +09:30
parent ef2afaa984
commit 104b764746
2 changed files with 11 additions and 23 deletions

8
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"cSpell.words": [
"codeberg",
"fpdf",
"qrcode",
"yeqown"
]
}

26
main.go
View File

@@ -12,7 +12,7 @@ import (
var cols = 4
var rows = 4
var qrSize = 50.0
var fontSize = 16.0 // pts
var fontSize = 32.0 // pts
var fontSizeMM = fontSize / 72 * 25.4
var text = "meow!"
@@ -86,12 +86,6 @@ func main() {
colWidth := pageWidth / float64(cols)
rowHeight := pageHeight / float64(rows)
// qrRowRatio := qrSize / rowHeight
// qrColRatio := qrSize / colWidth
// fmt.Printf("qr/row height ratio: %.2f\n", qrRowRatio)
// fmt.Printf("qr/col width ratio: %.2f\n", qrColRatio)
if textTopPadding+fontSizeMM+qrTopPadding+qrSize > rowHeight {
slog.Warn("qr is too big for row")
}
@@ -109,13 +103,6 @@ func main() {
topLeftX := colWidth * float64(colIdx)
topLeftY := rowHeight * float64(rowIdx)
// if rowHeight*0.8 < float64(qrSize) {
// panic("row too small for qr")
// }
// if colWidth*0.6 < float64(qrSize) {
// panic("col too small for qr")
// }
// label at the top
pdf.Text(
topLeftX+colWidth/2-textWidth/2,
@@ -125,18 +112,11 @@ func main() {
// qr at the bottom
pdf.ImageOptions("qr",
topLeftX+colWidth/2-qrSize/2, //+float64(dim)/2, // centre
topLeftY+textTopPadding+fontSizeMM+qrTopPadding, // centre, below text line
topLeftX+colWidth/2-qrSize/2,
topLeftY+textTopPadding+fontSizeMM+qrTopPadding,
qrSize, qrSize,
false,
fpdf.ImageOptions{AllowNegativePosition: true}, 0, "")
// pdf.Image("qr",
// topLeftX+5, // centre
// topLeftY+float64(fontSize)*1.3, // centre
// float64(qrSize),
// float64(qrSize),
// false, "tp", 0, "")
}
}