func compose(data Message, bg ledmatrix.Color) *ledmatrix.Writer {
	matrix := ledmatrix.NewMatrix(tower.Rows, tower.Columns)
	writer := ledmatrix.NewWriter(matrix)
	writer.Spacer(matrix.Columns, 0) // Blank bootstrap

	for _, line := range data {
		var r, g, b int
		var f bitmapfont.Font

		if line.Font < 8 {
			f = bitmapfont.F68
		} else {
			f = bitmapfont.F88
		}

		fmt.Sscanf(line.Color, "#%02x%02x%02x", &r, &g, &b)
		writer.WriteText(line.Text, f, ledmatrix.RGB(r, g, b), bg)
	}
	return writer
}
Example #2
0
// renderdeTextMessage convert a text to a LED bitmap matrix.
// This method is used by the displayBuilder gorouting.
func textToBitmap(text []Line, bg uint32) *ledmatrix.Matrix {
	matrix := ledmatrix.NewMatrix(rows, 0)
	writer := ledmatrix.NewWriter(matrix)
	writer.Spacer(matrix.Columns, 0) // Blank bootstrap

	for _, line := range text {
		var r, g, b int
		var f font.Font

		if line.Font < 8 {
			f = font.Font6x8
		} else {
			f = font.Font8x8
		}

		fmt.Sscanf(line.Color, "#%02x%02x%02x", &r, &g, &b)
		writer.WriteText(line.Text, f, ledmatrix.RGB(r, g, b), bg)
	}
	return matrix
}
Example #3
0
// blank generates a "space" from the given color
func blank(len int, bg uint32) *ledmatrix.Matrix {
	matrix := ledmatrix.NewMatrix(rows, columns)
	writer := ledmatrix.NewWriter(matrix)
	writer.Spacer(columns, bg) // Blank spacer
	return matrix
}