프로젝트
GitHub에서 보기

msoap/tcg
소개
Terminal cell graphics library
디자인 및 미디어What you can do
- Available 5 graphics modes, from 2x3 pixels grid for terminal symbol to 1x1, 1x2 and 2x2, or you can create own custom mode with your graphics
- Set/get one pixel
- Drawings: lines (vertical, horizontal, or with any angle), boxes, circles, arcs
- Fill area with a different options, for example fill with patterns
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalTCG - terminal cell graphics
Go Graphics library for use in a text terminal. Only 1bit graphics can be used with two colors. Used unicode block symbols for drawing. 2x3 mode is supported by the Iosevka font or some terminals (like default on Ubuntu).
Features
- Available 5 graphics modes, from 2x3 pixels grid for terminal symbol to 1x1, 1x2 and 2x2, or you can create own custom mode with your graphics
- Set/get one pixel
- Drawings: lines (vertical, horizontal, or with any angle), boxes, circles, arcs
- Fill area with a different options, for example fill with patterns
- Buffer manipulating: cut, clone, convert to/from stdlib Image or text
- Buffer transform: BitBlt with options, clear, flip, invert, scroll (vertical, horizontal)
- Sub-package for turtle graphics, also available drawing by text script
- Sprite support with Put, Withdraw, Move, etc methods
Install
go get github.com/msoap/tcg
Usage
package main
import (
"log"
"time"
"github.com/gdamore/tcell/v3"
"github.com/msoap/tcg"
)
func main() {
tg, err := tcg.New(tcg.Mode2x3) // each terminal symbol contains a 2x3 pixels grid, also you can use 1x1, 1x2, and 2x2 modes
if err != nil {
log.Fatalf("create tcg: %s", err)
}
i := 0
for {
pixColor := tg.Buf.At(10, 10) // get color of pixel
tg.Buf.Set(11, 11, pixColor) // draw one pixel with color from 10,10
tg.Buf.Line(0, 0, i, i, tcg.Black) // draw a diagonal line
tg.Show() // synchronize buffer with screen
if tg.TCellScreen.HasPendingEvent() {
if ev, ok := tg.TCellScreen.PollEvent().(*tcell.EventKey); ok && ev.Rune() == 'q' {
break // exit by 'q' key
}
}
i++
time.Sleep(time.Second)
}
tg.Finish() // finish application and restore screen
}
See more examples in examples folder.
Screenshot
Game of Life example in iTerm2 terminal:

See more screenshots.
TODO
- fonts support
- sprites
- animation in sprite
See also
- Go terminal library - github.com/gdamore/tcell
- Turtle graphics
- Try it in the Go Playground
Unicode symbols:
- Block Elements - wikipedia
- Block Elements - unicode.org
- Symbols for Legacy Computing - wikipedia
- Symbols for Legacy Computing - unicode.org
Supported fonts (for "2x3" mode):
관련 프로젝트 살펴보기
불러오는 중…