-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2cd998b
Showing
10 changed files
with
601 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Console Pxls viewer | ||
|
||
View a Pxls canvas on the command-line! | ||
|
||
## Known bugs | ||
|
||
- Windows has fewer, wronger colors | ||
- this is due to the library that's used ([termbox-go](https://github.com/nsf/termbox-go/)) not supporting xterm 256 colors at the time of this writing. | ||
- Mingw on Windows not rendering anything | ||
- no idea why this happens | ||
- Moving horizontally goes twice as fast than moving vertically | ||
|
||
## Controls | ||
|
||
* Drag your mouse to scroll through the canvas. | ||
* Use the arrow keys to move faster. | ||
* Ctrl+C exists. | ||
|
||
## Arguments | ||
|
||
`--host`: the hostname of the pxls server. Default is "pxls.space" | ||
|
||
`--secure`: whether the connection should be secure (use https: and wss: protocols) or insecure (use http: and ws: protocols). Default is true. | ||
|
||
--- | ||
|
||
## Screenshots | ||
|
||
Powershell in Windows: | ||
![Windows, Powershell](images/windows-powershell.gif) | ||
|
||
Ubuntu with Xterm color palette (full of visual glitches, but pretty colors) | ||
![Ubuntu, Terminal (Xterm color palette)](images/ubuntu-xterm.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// +build !windows linux,darwin | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/lucasb-eyer/go-colorful" | ||
"github.com/nsf/termbox-go" | ||
) | ||
|
||
const termboxXtermOffset = 0x11 | ||
|
||
// modification of https://github.com/ichinaski/pxl/blob/master/color.go. | ||
|
||
// reduceRGB reduces color values to the range [0, 15]. | ||
func reduceRGB(color colorful.Color) (uint16, uint16, uint16) { | ||
r, g, b, _ := color.RGBA() | ||
|
||
return uint16(r >> 8), uint16(g >> 8), uint16(b >> 8) | ||
} | ||
|
||
// termColor converts a 24-bit RGB color into a term256 compatible approximation. | ||
func colorToTermboxAttr(color colorful.Color) termbox.Attribute { | ||
r, g, b := reduceRGB(color) | ||
|
||
var ( | ||
termR = (((r * 5) + 127) / 255) * 36 | ||
termG = (((g * 5) + 127) / 255) * 6 | ||
termB = (((b * 5) + 127) / 255) | ||
) | ||
|
||
return termbox.Attribute(termR + termG + termB + termboxXtermOffset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build windows | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/lucasb-eyer/go-colorful" | ||
"github.com/nsf/termbox-go" | ||
) | ||
|
||
// TODO(netux): wait for Termbox to add support for Output256 on Windows. | ||
var termboxPalette = map[colorful.Color]termbox.Attribute{ | ||
colorful.Color{R: 0, G: 0, B: 0}: termbox.ColorBlack, | ||
colorful.Color{R: 1, G: 0, B: 0}: termbox.ColorRed, | ||
colorful.Color{R: 0, G: 1, B: 0}: termbox.ColorGreen, | ||
colorful.Color{R: 0, G: 1, B: 0}: termbox.ColorBlue, | ||
colorful.Color{R: 1, G: 1, B: 0}: termbox.ColorYellow, | ||
colorful.Color{R: 1, G: 0, B: 1}: termbox.ColorMagenta, | ||
colorful.Color{R: 0, G: 1, B: 1}: termbox.ColorCyan, | ||
colorful.Color{R: 1, G: 1, B: 1}: termbox.ColorWhite, | ||
} | ||
|
||
func colorToTermboxAttr(color colorful.Color) termbox.Attribute { | ||
var closest colorful.Color | ||
var by float64 = 2 | ||
for c := range termboxPalette { | ||
d := color.DistanceLab(c) | ||
|
||
if d < by { | ||
closest = c | ||
by = d | ||
} | ||
} | ||
|
||
return termboxPalette[closest] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module go-dev.netux.site/shell/pxls-viewer | ||
|
||
require ( | ||
github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 | ||
github.com/mattn/go-runewidth v0.0.4 // indirect | ||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d | ||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 h1:5MnxBC15uMxFv5FY/J/8vzyaBiArCOkMdFT9Jsw78iY= | ||
github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4= | ||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= | ||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= | ||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= | ||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= | ||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 h1:ulvT7fqt0yHWzpJwI57MezWnYDVpCAYBVuYst/L+fAY= | ||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.