GithubHelp home page GithubHelp logo

analit's Introduction

Analit: Analog Literals for Rust

For all of Rust's great improvements on the status quo of systems languages, one feature has been sorely missing. No, it's not higher-kinded-types, or integer generics, or having a name that includes the letter 'C'. It's analog literals. Ever since Eelis debuted "Analog Literals" in 2005 as a C++ utility, the ability to draw geometry out using ASCII art has set a new bar for what constitutes a minimal-viable-language.

Examples

Analog literals follow a simple syntactic pattern. The pointy corners of things are marked by '+' characters, one unit in the x-axis is represented by '--', and one unit in the Y and Z axes are represented by '|' and '/', respectively. The reason two characters are used to represent just one unit in the x-axis is to compensate for the rectangular shape that characters are rendered with. Analog expressions return a tuple reflecting the dimensions of the drawing. But enough talk--let's see some examples:

One-Dimensional

A line of length two along the X axis:

assert_eq!(2, analit!(
        +----+
    ));

A line of length two along the Y axis:

assert_eq!(2, analit!(
    +
    |
    |
    +
));

A line of length two along the Z axis:

assert_eq!(2,analit!(
       +
      /
     /
    +
));

Two-Dimensional

Two dimensional literals have proven themselves especially valuable to GUI programmers.

A (2,1) rectangle defined across X and Y:

assert_eq!((2,1),analit!(
    +----+
    |    |
    +----+
));

...across X and Z:

assert_eq!((2,1),analit!(
      +----+
     /    /
    +----+
));

...across Y and Z:

assert_eq!((2,1),analit!(
       +
      /|
     / +
    + /
    |/
    +
));

Three-Dimensional

It's time to dig those red-and-blue glasses out from between the couch cushions; we're going into the next dimension!

assert_eq!((1,1,3),analit!(
        +--+
       /  /|
      /  / +
     /  / /
    +--+ /
    |  |/
    +--+
));

It's like it's coming right out of the screen!

Using Analog Literals in Your Next Project*

Simply add the following to your Cargo.toml

[dependencies.analit]
git = "https://github.com/jswrenn/analit"

Or, from the registry:

[dependencies]
analit = "*"

*Please don't.

analit's People

Contributors

jswrenn avatar squiddy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.