Exemple #1
0
func createBitmap() *walk.Bitmap {
	bounds := walk.Rectangle{Width: 200, Height: 200}

	bmp, _ := walk.NewBitmap(bounds.Size())

	succeeded := false
	defer func() {
		if !succeeded {
			bmp.Dispose()
		}
	}()

	canvas, _ := walk.NewCanvasFromImage(bmp)
	defer canvas.Dispose()

	brushBmp, _ := walk.NewBitmapFromFile("../img/plus.png")
	defer brushBmp.Dispose()

	brush, _ := walk.NewBitmapBrush(brushBmp)
	defer brush.Dispose()

	canvas.FillRectangle(brush, bounds)

	font, _ := walk.NewFont("Times New Roman", 40, walk.FontBold|walk.FontItalic)
	defer font.Dispose()

	canvas.DrawText("Walk Drawing Example", font, walk.RGB(0, 0, 0), bounds, walk.TextWordbreak)

	succeeded = true
	return bmp
}
Exemple #2
0
func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	doc := walk.NewDocument("Walk Printing Example")
	defer doc.Dispose()

	doc.InsertPageBreak()

	text := "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."
	font, _ := walk.NewFont("Times New Roman", 12, 0)
	color := walk.RGB(0, 0, 0)
	preferredSize := walk.Size{1000, 0}
	format := walk.TextWordbreak

	for i := 0; i < 20; i++ {
		doc.AddText(fmt.Sprintf("%d) %s", i, text), font, color, preferredSize, format)
	}

	doc.Print()
}