Exemplo n.º 1
0
func Write8(i image.Image, bounds image.Rectangle) {
	var c0, c1 tc.C256
	for y := bounds.Min.Y; y < bounds.Max.Y; y += 2 {
		for x := bounds.Min.X; x < bounds.Max.X; x++ {
			c0 = iget(i, bounds, x, y)
			c1 = 232
			if (y + 1) < bounds.Max.Y {
				c1 = iget(i, bounds, x, y+1)
			}

			fmt.Print(tc.Background8(c1, tc.Foreground24(c0, BLOCK)))
		}
		fmt.Print("\n")
	}
}
Exemplo n.º 2
0
func Write24(i image.Image, bounds image.Rectangle) {
	var c0, c1 color.Color
	for y := bounds.Min.Y; y < bounds.Max.Y; y += 2 {
		for x := bounds.Min.X; x < bounds.Max.X; x++ {
			c0 = i.At(x, y)
			c1 = color.Black
			if (y + 1) < bounds.Max.Y {
				c1 = i.At(x, y+1)
			}

			fmt.Print(tc.Background24(c1, tc.Foreground24(c0, BLOCK)))
		}
		fmt.Print("\n")
	}
}
Exemplo n.º 3
0
func (w *Writer) Write(in []byte) (n int, err error) {
	t1 := time.Now()
	d := t1.Sub(w.now)
	w.now = t1

	if len(in) > 0 && in[len(in)-1] == '\n' {
		in = in[0 : len(in)-1]
	}

	perc := heatmap.Percentage(100.0 * float64(d) / float64(w.ReferenceDuration))
	dd := []byte(tc.Foreground24(perc, fmtDur(d)))

	line := make([]byte, len(in)+len(dd)+2)
	copy(line, dd)
	line[len(dd)] = '\t'
	copy(line[len(dd)+1:], in)
	line[len(in)+len(dd)+1] = '\n'

	return w.base.Write(line)
}