2.0.2 • Published 7 years ago

text-draw v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

travis ci build

TextDraw.js

Importing/Installing

Require text-draw after you have installed it.

var TextDraw = require('text-draw');

You can also download text-draw.js (found in build folder on github page) and place it where you can access it.

var TextDraw = require('[PATH]/text-draw.js');

Or, if you would like to use the minified TextDraw.

var TextDraw = require('[PATH]/text-draw.min.js');
Note: something like browserify is required to use text-draw on web pages.

Initializing

Once you have imported TextDraw..

First, create a TextDraw object and initialize it.

var myCanvas = TextDraw.init();

Create a canvas of size(x, y) for your text.

myCanvas.createCanvas(21,9);
Note: Drawing must be contained within the canvas or you will recieve an error.

Drawing

There are many options for drawing, but this demo will stick to creating a basic square with some text inside it.

Create a square on the canvas.

myCanvas.square.draw("#",21,9,1,1);
//square.draw(character, width, height, x, y, extras)

Then place some text inside.

myCanvas.text.draw("Hello World",5,5);
//text.draw(text, x, y)

Displaying

You can display the canvas that you have drawn with logConsole.

myCanvas.logConsole();
//or
myCanvas.logConsole({display_color: false});
//for consoles that do not support color.

You can also display the canvas on a web page by using drawCanvas.

var container = document.getElementById("demo");
container.innerHTML = myCanvas.drawCanvas();

Make sure to wrap any element that you plan to insert a canvas into with pre tags.

<pre><div id="demo"></div></pre>

Result

You should see something similar to:

##################### 
##################### 
##################### 
##################### 
#####Hello World##### 
##################### 
##################### 
##################### 
#####################

Further reading

https://github.com/edwin0258/TextDraw.js/tree/master/docs

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago