• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    TypeScript
  • License
    Mozilla Public Li...
  • Created almost 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

TextGraphic is a framework for creating Textual Graphics. It provides layers, styling, rich color, text justification, layouts, tables, view-ports, transparency, etc.

TextGraphic

TextGraphic (previously "TextGraphic") is a framework for creating Textual Graphics. It provides layers, styling, rich color, text justification, layouts, tables, view-ports, transparency, etc. All behind a beautiful object-oriented view model that is easy and humane to use. Underneath it also provides a rich rendering engine that is fully independent of any platform and can synthesize rendered code for ANSI Terminals, Web, and plain text format. Written in pure ECMAScript without incorporating any platform provided API, (no node/DOM API is used) and therefore works on any JavaScript platform.


Header Screenshots of the TextGraphic Playground and Demos


A remark is that while TextGraphic can be used to style command line interfaces, it is not a command line interface library. It can work on many platforms and is intended to do the core visual tasks. I will have more libraries coming on top of the TextGraphic. A TermKit that provides some advance Terminal features and libraries for textual graphics and textual interfaces.



The View Model of the TextGraphic

TextGraphic in its core, provides a 2D representation of text which is defined in a set of classes called Views — that are implementations of the ViewProtocol standard. These Views makes it possible to define a 2D textual object:

A demo of TextGraphic in the Playground that shows the basic shaping and styling.

TextGraphic makes it possible to compose layers and views by combining the layers together.

An screenshot showing the label being added to the canvas



Rendering Capabilities of TextGraphic

Rich Composition

In TextGraphic you can combine scenes together and each View preserves the boundary for itself. So the children of the view are always retained within the boundaries of the view. This makes it possible to do all sorts of powerful things. — P.S. Look how the borders of the boxes are combined together in their intersections :)


The Pane Animation Demo of the TextGraphic that shows how different canvases can be added together independent of their space


Over-lapping Layers and Transparency

TextGraphic is different from some of its alternatives because it uses a Virtual Screen underneath. TextGraphic uses no cursor movements. Instead, it uses a virtual screen to compute the resulting view and then synthesizes the required styling information (ANSI Terminal escape sequences in this example) and returns one single string that you can push to the stdout or .innerHTML

To do so. TextGraphic uses a simple ray-tracer for z-index locating and then composes layers together. Having z-index and ray-tracing makes it possible to have objects that over-lap and also because of ray-tracing, objects can have transparency in them.


Screenshot of a TextGraphic demo showing 3 boxes layered on each other. On with a transparent background and one with a solid colored background


Graphing Engine

In TextGraphic you can use the GraphView to render mathematical formulas into a textual format. This is done efficiently without taking advantage of a GPU (although I very much hope to have WebGPU as a GPGPU available on browser and the node so that I can implement a super preformat version of it.)


Screenshot of a graph being rendered into the screen


Scalable Vector Graphics

By providing an efficient GraphView, TextGraphic makes it possible to have scalable vector graphics that are useful in making different UI components or graphical arts. You can make these shapes react to zoom, window size and view port size changes.



Unicode Box Fine Tunning

TextGraphic's Canvas view can fine tune the intersections of unicode boxes. This table is made of putting 30 independent boxes together, but TextGraphic can change the characters at where these boxes are joined together and it also understands the weights of these connections. So the result is a very beautiful and fine tunned result that previously was impossible or extremely hard to implement. (I know of no other system that implements anything like this. Monodraw does have this ability but it only works for the light lines and weight detection is still unique to TextGraphic I guess)


An spreadsheet view demo that shows the UNICODE box fine tunning.


Cropping & Slicing

TextGraphic offers a fast and virtually footprint-free system for cropping views. This makes for a great tool for making layouts, scroll views, etc...



Static Render Synthesis

TextGraphic is a rendering engine that synthesizes the final render at once. It does not require any realtime cursor movement or environmental changes. This enables some really powerful features.

  • The system becomes platform independent as you see in the next feature title.
  • You get to run the renderer as a server side feature while having clients showing its renders.
  • It can be used to synthesize and generate all sorts of static content for the machine and the web.
  • The synthesized view can be further enhanced and modified by third party code.
  • Since you have the whole view computed ahead of time, you get a very high speed when rendering :)


Platform Independent Rendering

The design of TextGraphic is around a central idea of having different renderers for different environments, which are open to anyone to also extend and add to. TextGraphic has a Virtual Screen and Ray-Tracker system that makes it possible to compute optimized native renders for different platforms. Currently TextGraphic offers renderers for ANSI Terminal, SVG, and HTML.


Screenshots of a graphic rendered for ANSI Terminal, SVG and Web



Installation and Usage

For now, I'm designing the system so it is both unstable and the API is subject to drastic change. You can look at the playground examples to get an idea of how to use the system. And the package can be installed using and used as:


% npm install --save textgraphic
import * as TextGraphic from "textgraphic"

You can also play inside the playground. TextGraphic has its own environment for playing around with the codes and testing your ideas, It has auto-complete features and debugging views.
Learn more about the playground and its capabilities →


Screenshot showing the TextGraphic Playground








© Copyright 2020—present, Pouya Kary. All rights reserved.

More Repositories

1

Orchestra

One language to be RegExp's Successor. Visually readable and rich, technically safe and extended, naturally scalable, advanced, and optimized
JavaScript
139
star
2

ProColors

A collection of coding themes for syntax highlighting and the editors that are designed to be available in dark and light modes with a very high precision of harmony and token definition coverage.
Makefile
105
star
3

Nota

A calculator with a beautiful interface for the Terminal, Including unicode-based charting and rich mathematical notation rendering
Haskell
55
star
4

Graph

[EXPERIMENTAL] A Powerful, Beautiful, Programmable and Rich Graph Editor for Students, Data Scientists, Mathematicians and anyone who want's to just have fun with graphs!
TypeScript
35
star
5

themeX

The ultimate UNIVERSAL syntax color theme generator that let's you build your color scheme in just one file and compile for a wide range of different editors.
TypeScript
32
star
6

Starlight

Automatic macOS Dark/Light shift based on surrounding ambient light.
27
star
7

nearley-vscode

Nearley Language Support for Visual Studio Code
25
star
8

KaryScript

KaryScript is an experimental language to test the possibilities of a more readable textual language. It compiles to ES6 and can be considered a much better ECMAScript
TypeScript
21
star
9

comment-legacy-gui

Online Generator for Kary Foundation Comment System (KFCS) http://comment.kary.us
CSS
20
star
10

vscode-racket

Racket support for Visual Studio Code with better inteliSense
TypeScript
19
star
11

comment

A KFCS plugin for Visual Studio Code, So that you can shape anything into KFCS section comment with just ⌘y and ⌘l
TypeScript
16
star
12

Righteous

CSS Code Formatter Engine that implements the Kary Coding Standards
CSS
12
star
13

coding-standards

Source code for the https://kcs.library.kary.us
9
star
14

note

My pretty simple teminal note. Uses the Kary Framework for UI and has the coolest most awesome look. Is super simple and works with Dropbox and your cloud system...
C#
7
star
15

picky

A macOS color picker.
7
star
16

cozy

Yet another web UI framework :D
6
star
17

Intactus-legacy

A String manipulation engine based on the Kary Framework that renders Mathematical Notations and Charts using ASCII / Character Art.
C#
5
star
18

idf-vscode

Language Support for HeatStudio, OpenStudio and EneregyPlus files
TypeScript
5
star
19

DesignTalk

DesignTalk; An experimentation on various human-computer interface ideas. https://designtalk.kary.us
JavaScript
5
star
20

DayAndNight

A super tiny app that sits on your dock and lets you change the system appearance with only a single click
Rich Text Format
4
star
21

pirate

My personal version of Brave desktop browser
JavaScript
4
star
22

moves

🧀 Moves your cursor under the columns in the above line
TypeScript
4
star
23

nearley-playground-mac

Offline mac app for Nearley Playground
Objective-C
3
star
24

ungamify

Removes gamifications in some known websites so that you don't get addicted to them!
JavaScript
3
star
25

basic-gouraud-shader

A basic Gouraud Shader for fun
C++
3
star
26

Concerto

RegExp to Orchestra Language Compiler
TypeScript
3
star
27

vscode-comment-justifier

A Visual Studio Code extension that lets you justify comments to be less than 40 characters and so easy to read.
TypeScript
3
star
28

comment-3

An OS X software to generate comments in my way
Swift
2
star
29

Pageman

HTML, Markdown and Legend mixer that Loves Jekyll and Kary Comments.
TypeScript
2
star
30

telephone

A fork of Black Screen, just better!
TypeScript
2
star
31

ios-youtube-shortcuts

3 shortcuts for downloading video, skipping ads and making videos picture-in-picture (iPad) for YouTube.
2
star
32

dup

a tiny and fast command line utility to find the duplicate files within a directory
Go
2
star
33

gerda

The optimized Arendelle's intelligent auto suggestion server
TypeScript
2
star
34

tambourine

A very simple music theory library
TypeScript
2
star
35

rod

Compile switch case to ternary operator
Crystal
2
star
36

arendelle-book

The official Arendelle Book that you can find http://web.arendelle.org/book/ - Licensing can be found here: http://web.arendelle.org/legal/book/index.html
2
star
37

numeraX

Compiler for generating mathematical TeX expressions from a simple user friendly math notation. Playground at http://numerax.toys.kary.us
TypeScript
2
star
38

monojustifier

A justification algorithm specifically designed for monospace environments like terminal emulators and text editors.
TypeScript
2
star
39

ia-templates

iA Writer templates
CSS
2
star
40

go-corelib

Kary Framework is a Cross Platform Textual User Interface Implementation Framework made of components for String Manipulation, Terminal Viewport Management and Terminal UI Widgets.
Go
2
star
41

bulda-casio-prism

Arendelle's very first implementation...
1
star
42

pageman-vscode

Pageman language syntax highlighting support for Visual Studio Code
1
star
43

arcco

A dirty and quick documentation generator
Lua
1
star
44

qbert.arendelle

Arendelle Q-Bert
1
star
45

wasi-print-f64-to-stdout

Very Very Basic STDOUT for WASI so that I can make stuff in WAT
WebAssembly
1
star
46

stack.arendelle

A very simple stack system for Arendelle
1
star
47

birdy.arendelle

Arendelle Language's Logo
1
star
48

arendelle-nano

Arendelle Highlighting for GNU Nano Editor
1
star
49

bulda.arendelle

Bulda is a legacy language behind Arendelle, Now written with Arendelle
1
star
50

sketchup-grid-importer

Import your Arendelle Grid files to 3D SketchUp models so you can print them in 3D!
Ruby
1
star
51

gol

Every dev deserves a game of life implementation right?
Rust
1
star
52

righteous-vscode

Visual Studio Code TypeScript and JavaScript Code Formatter based on Kary Foundation's Righteous Formatting Engine for Kary Foundation's Coding Style.
TypeScript
1
star
53

swifty

Arendelle 2XIV Switf based Interpreter that powers the Arendelle for iOS as well Mac REPL for Arendelle.
Objective-C
1
star
54

wolfram-turing-machine

Wolfram's 2-state 3-symbol Turing machine
Go
1
star
55

themeX-yeoman

themeX project generator for Yeoman
JavaScript
1
star
56

selfstopper

JavaScript
1
star
57

pouyakary

1
star
58

procolors-vscode

JavaScript
1
star
59

pouyakary.github.io

The 5th edition of Kary.us. My personal homepage.
CSS
1
star
60

virtuous

The Kary-style JSON formatter
TypeScript
1
star
61

atom-kf-light

Kary Foundation's Light Theme for Atom
CSS
1
star
62

gitget

A little tiny tool to clone a whole GitLab server :)
TypeScript
1
star
63

idf-formatter

A formatter engine for EnergyPlus IDF File Format
TypeScript
1
star