forked from yeqown/go-qrcode
/
helper.go
36 lines (35 loc) · 915 Bytes
/
helper.go
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
package terminal
//
//import (
// "image/color"
// "os"
// "syscall"
// "unsafe"
//)
//
//const defaultRatio float64 = 7.0 / 3.0 // The terminal's default cursor width/height ratio
//
//func terminalSize() (int, int, float64) {
// var size [4]uint16
// if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL,
// uintptr(os.Stdout.Fd()), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&size)),
// 0, 0, 0); err != 0 {
// panic(err)
// }
// rows, cols, width, height := size[0], size[1], size[2], size[3]
//
// whratio := defaultRatio
// if width > 0 && height > 0 {
// whratio = float64(height/rows) / float64(width/cols)
// }
//
// return int(cols), int(rows), whratio
//}
//
//func terminalColor(rgb color.RGBA) uint16 {
// r := (((rgb.R * 5) + 127) / 255) * 36
// g := (((rgb.G * 5) + 127) / 255) * 6
// b := ((rgb.B * 5) + 127) / 255
//
// return uint16(r+g+b) + 16 + 1 // termbox default color offset
//}