fixed 'sizeToFill' and added test

This commit is contained in:
Vadim
2015-09-29 22:35:22 -04:00
parent 77617bae67
commit 7939f91cd7
6 changed files with 46 additions and 27 deletions
+12 -8
View File
@@ -1,7 +1,7 @@
CanvasTextWrapper
=================
# Syntax
## Syntax
```
CanvasTextWrapper(HTMLCanvasElement, String [, options]);
```
@@ -23,7 +23,7 @@ CanvasTextWrapper(HTMLCanvasElement, String [, options]);
NOTE: if a single word is too long to fit the width with specified font size, it will break on any letter unless ```sizeToFill``` option is enabled.
# Defaults
## Default options
```
{
font: "18px Arial, sans-serif",
@@ -41,9 +41,10 @@ NOTE: if a single word is too long to fit the width with specified font size, it
}
```
# Usage
## Usage
Configure context settings properties such as "fillStyle", "lineWidth" or "strokeStyle" before using CanvasTextWrapper like so:
```
```
var CanvasTextWrapper = require('canvas-text-wrapper').CanvasTextWrapper;
var canvas = document.getElementById("#canvasText");
@@ -55,12 +56,15 @@ context.strokeStyle = "#ff0000";
CanvasTextWrapper(canvas,"Hello"); //default options will apply
```
# Examples
http://namniak.github.io/CanvasTextWrapper/
## Test
In terminal go to CanvasTextWrapper folder and run ```npm t```
# Installation
## Examples
[Demo](http://namniak.github.io/CanvasTextWrapper/)
## Installation
```
bower install canvas-text-wrapper
npm i canvas-text-wrapper
npm i canvas-text-wrapper --save
```