@@ -56,7 +56,8 @@ func main() {
collection := fontCollection()
- sz := image.Point{X: 1200, Y: 630}
+ const scale = 1
+ sz := image.Point{X: 1200 * scale, Y: 630 * scale}
w, err := headless.NewWindow(sz.X, sz.Y)
if err != nil {
@@ -66,8 +67,11 @@ func main() {
gtx := layout.Context{
Ops: new(op.Ops),
Queue: new(router.Router),
+ Metric: unit.Metric{
+ PxPerDp: scale,
+ PxPerSp: scale,
+ },
}
- w.Frame(gtx.Ops)
layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
gtx.Constraints.Max.X = int(float64(gtx.Constraints.Max.X) * .6)
gtx.Constraints.Min.X = gtx.Constraints.Max.X
@@ -162,10 +166,11 @@ func main() {
layout.Rigid(layout.Spacer{Height: 50}.Layout),
)
})
+ w.Frame(gtx.Ops)
img := image.NewRGBA(image.Rectangle{Max: sz})
err = w.Screenshot(img)
if err != nil {
- fmt.Println("Error: Could not transform GUI to image")
+ fmt.Println("Error: Could not transfer GUI to image")
}
var buf bytes.Buffer
if err := png.Encode(&buf, img); err != nil {