vivid/README.md

123 lines
3.2 KiB
Markdown
Raw Normal View History

2016-12-21 13:34:16 +13:00
# Vivid
Vivid is a simple 2D rendering library.
I plan to use it to render polygons for display on a
[monochrome 128x64 OLED display from Adafruit](https://www.adafruit.com/products/938).
2017-01-02 20:47:49 +13:00
## Features
* Supports drawing and manipulating a number of basic 2D primimives.
* Supports arbitrary transformations shape transformations.
* Renders shapes onto a buffer.
* 100% pure Elixir with no dependencies.
## Demo
I implemented a simple ASCII renderer for debugging and testing purposes, so at
any time you can pipe a `Frame` to `IO.puts` and the contents of the buffer will
be rendered and printed onto the screen.
### Basic drawing
Frames behave as a simple collection of shapes and colours, which you can simply
push on to.
```elixir
use Vivid
Frame.init(10,10, RGBA.white)
|> Frame.push(Circle.init(Point.init(5,5), 4), RGBA.black)
|> IO.puts
```
```
@@@@ @@@
@@ @@@ @
@@ @@@@@ @
@ @@@@@@@
@ @@@@@@@
@ @@@@@@@
@@ @@@@@ @
@@ @@@ @
@@@@ @@@
@@@@@@@@@@
```
### Transformations
Vivid supports a number of standards transforms which can be applied to a shape
before it is added to a frame. It also makes provision for you to write your own.
```elixir
use Vivid
frame = Frame.init(20, 20, RGBA.white)
shape = Box.init(Point.init(0,0), Point.init(5,5))
|> Transform.rotate(45)
|> Transform.fill(frame)
|> Transform.center(frame)
|> Transform.apply
Frame.push(frame, shape, RGBA.black)
|> IO.puts
```
```
2017-01-12 13:30:11 +13:00
@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @ @@@@@@@@
@@@@@@@@ @@@ @@@@@@@
@@@@@@@ @@@@@ @@@@@@
@@@@@ @@@@@@@ @@@@@
@@@@ @@@@@@@@@@ @@@@
@@@ @@@@@@@@@@@@ @@@
@@ @@@@@@@@@@@@@@ @@
@ @@@@@@@@@@@@@@@@ @
@@@@@@@@@@@@@@@@@@
@ @@@@@@@@@@@@@@@@ @
@@ @@@@@@@@@@@@@@ @@
@@@ @@@@@@@@@@@@ @@@
@@@@ @@@@@@@@@@ @@@@
@@@@@ @@@@@@@@@ @@@@
@@@@@@ @@@@@@@ @@@@@
@@@@@@@ @@@@@ @@@@@@
@@@@@@@@ @@@ @@@@@@@
@@@@@@@@@ @ @@@@@@@@
@@@@@@@@@@ @@@@@@@@@
2017-01-02 20:47:49 +13:00
```
2016-12-22 15:30:32 +13:00
2017-01-02 21:00:23 +13:00
## License
Source code is licensed under the terms of the MIT license, the text of which
is included in the `LICENSE` file in this distribution.
This distribution includes the Hershey vector font from
[The Hershey Fonts](http://sol.gfxile.net/hershey/index.html).
Font use restrictions:
```
This distribution of the Hershey Fonts may be used by anyone for
any purpose, commercial or otherwise, providing that:
1. The following acknowledgements must be distributed with
the font data:
- The Hershey Fonts were originally created by Dr.
A. V. Hershey while working at the U. S.
National Bureau of Standards.
- The format of the Font data in this distribution
was originally created by
James Hurt
Cognition, Inc.
900 Technology Park Drive
Billerica, MA 01821
(mit-eddie!ci-dandelion!hurt)
2. The font data in this distribution may be converted into
any other format *EXCEPT* the format distributed by
the U.S. NTIS (which organization holds the rights
to the distribution and use of the font data in that
particular format). Not that anybody would really
*want* to use their format... each point is described
in eight bytes as "xxx yyy:", where xxx and yyy are
the coordinate values as ASCII numbers.
```
2016-12-22 15:30:32 +13:00
## Status
This library is still experimental, but what few features it has work well.