File: image_fullblock.go

package info (click to toggle)
golang-sourcehut-rockorager-vaxis 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: makefile: 9
file content (88 lines) | stat: -rw-r--r-- 2,306 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package vaxis

//
// import (
// 	"image"
// )
//
// var blitterCells = map[int]rune{
// 	0b1111: '█', // FULL BLOCK
// 	0b0000: ' ', // SPACE
// 	0b1100: '▀', // UPPER HALF BLOCK
// 	0b0011: '▄', // LOWER HALF BLOCK
// 	0b0101: '▐', // RIGHT HALF BLOCK
// 	0b1010: '▌', // LEFT HALF BLOCK
// 	0b0010: '▖', // QUADRANT LOWER LEFT
// 	0b0001: '▗', // QUADRANT LOWER RIGHT
// 	0b1000: '▘', // QUADRANT UPPER LEFT
// 	0b1011: '▙', // QUADRANT UPPER LEFT AND LOWER LEFT AND LOWER RIGHT
// 	0b1001: '▚', // QUADRANT UPPER LEFT AND LOWER RIGHT
// 	0b1110: '▛', // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER LEFT
// 	0b1101: '▜', // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER RIGHT
// 	0b0100: '▝', // QUADRANT UPPER RIGHT
// 	0b0110: '▞', // QUADRANT UPPER RIGHT AND LOWER LEFT
// 	0b0111: '▟', // QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT
// }
//
// func blit(img image.Image) []Cell {
// 	w := img.Bounds().Max.X
// 	h := img.Bounds().Max.Y
// 	if h%2 != 0 {
// 		h += 1
// 	}
// 	// The image will be made into an array of cells, each cell will capture
// 	// 1x2 pixels
// 	cells := make([]Cell, (w * h / 2))
// 	for i, cell := range cells {
// 		y := i / w
// 		x := i - (y * w)
// 		y *= 2
//
// 		top := img.At(x, y)
// 		bottom := img.At(x, y+1)
// 		var (
// 			r uint8
// 			g uint8
// 			b uint8
// 		)
// 		switch top {
// 		case bottom:
// 			cell.Character = Character{
// 				Grapheme: " ",
// 				Width:    1,
// 			}
// 			pr, pg, pb, a := top.RGBA()
// 			if a > 0 {
// 				r = uint8((pr * 255) / a)
// 				g = uint8((pg * 255) / a)
// 				b = uint8((pb * 255) / a)
// 				cell.Background = RGBColor(r, g, b)
// 			}
// 		default:
// 			cell.Character = Character{
// 				Grapheme: "▀",
// 			}
// 			pr, pg, pb, a := top.RGBA()
// 			switch a {
// 			case 0:
// 				r = uint8(pr)
// 				g = uint8(pg)
// 				b = uint8(pb)
// 			default:
// 				r = uint8((pr * 255) / a)
// 				g = uint8((pg * 255) / a)
// 				b = uint8((pb * 255) / a)
// 			}
// 			cell.Foreground = RGBColor(r, g, b)
// 			pr, pg, pb, a = bottom.RGBA()
// 			if a > 0 {
// 				r = uint8((pr * 255) / a)
// 				g = uint8((pg * 255) / a)
// 				b = uint8((pb * 255) / a)
// 				cell.Background = RGBColor(r, g, b)
// 			}
// 		}
// 		cells[i] = cell
// 	}
// 	return cells
// }