WIP
This commit is contained in:
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"codeberg",
|
||||||
|
"fpdf",
|
||||||
|
"qrcode",
|
||||||
|
"yeqown"
|
||||||
|
]
|
||||||
|
}
|
||||||
26
main.go
26
main.go
@@ -12,7 +12,7 @@ import (
|
|||||||
var cols = 4
|
var cols = 4
|
||||||
var rows = 4
|
var rows = 4
|
||||||
var qrSize = 50.0
|
var qrSize = 50.0
|
||||||
var fontSize = 16.0 // pts
|
var fontSize = 32.0 // pts
|
||||||
var fontSizeMM = fontSize / 72 * 25.4
|
var fontSizeMM = fontSize / 72 * 25.4
|
||||||
var text = "meow!"
|
var text = "meow!"
|
||||||
|
|
||||||
@@ -86,12 +86,6 @@ func main() {
|
|||||||
colWidth := pageWidth / float64(cols)
|
colWidth := pageWidth / float64(cols)
|
||||||
rowHeight := pageHeight / float64(rows)
|
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 {
|
if textTopPadding+fontSizeMM+qrTopPadding+qrSize > rowHeight {
|
||||||
slog.Warn("qr is too big for row")
|
slog.Warn("qr is too big for row")
|
||||||
}
|
}
|
||||||
@@ -109,13 +103,6 @@ func main() {
|
|||||||
topLeftX := colWidth * float64(colIdx)
|
topLeftX := colWidth * float64(colIdx)
|
||||||
topLeftY := rowHeight * float64(rowIdx)
|
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
|
// label at the top
|
||||||
pdf.Text(
|
pdf.Text(
|
||||||
topLeftX+colWidth/2-textWidth/2,
|
topLeftX+colWidth/2-textWidth/2,
|
||||||
@@ -125,18 +112,11 @@ func main() {
|
|||||||
|
|
||||||
// qr at the bottom
|
// qr at the bottom
|
||||||
pdf.ImageOptions("qr",
|
pdf.ImageOptions("qr",
|
||||||
topLeftX+colWidth/2-qrSize/2, //+float64(dim)/2, // centre
|
topLeftX+colWidth/2-qrSize/2,
|
||||||
topLeftY+textTopPadding+fontSizeMM+qrTopPadding, // centre, below text line
|
topLeftY+textTopPadding+fontSizeMM+qrTopPadding,
|
||||||
qrSize, qrSize,
|
qrSize, qrSize,
|
||||||
false,
|
false,
|
||||||
fpdf.ImageOptions{AllowNegativePosition: true}, 0, "")
|
fpdf.ImageOptions{AllowNegativePosition: true}, 0, "")
|
||||||
// pdf.Image("qr",
|
|
||||||
// topLeftX+5, // centre
|
|
||||||
// topLeftY+float64(fontSize)*1.3, // centre
|
|
||||||
// float64(qrSize),
|
|
||||||
// float64(qrSize),
|
|
||||||
// false, "tp", 0, "")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user