Skip to content

Commit

Permalink
feat(shape): Add API declaration to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Mar 30, 2016
1 parent 272e7f8 commit 1efa42e
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
107 changes: 107 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<a name="Image"></a>

## Image ⇐ <code>Shape</code>
Implements support for Image drawing in terminal.

**Kind**: global class
**Extends:** <code>Shape</code>
**Since**: 1.0.0

* [Image](#Image) ⇐ <code>Shape</code>
* [new Image(cursor, [options])](#new_Image_new)
* _instance_
* [.getImage()](#Image+getImage) ⇒ <code>String</code>
* [.setImage(image)](#Image+setImage) ⇒ <code>[Image](#Image)</code>
* [.isPreserveAspectRatio()](#Image+isPreserveAspectRatio) ⇒ <code>Boolean</code>
* [.setPreserveAspectRatio([isPreserveAspectRatio])](#Image+setPreserveAspectRatio) ⇒ <code>[Image](#Image)</code>
* [.render()](#Image+render) ⇒ <code>[Image](#Image)</code>
* [.toObject()](#Image+toObject) ⇒ <code>Object</code>
* _static_
* [.isBase64(string)](#Image.isBase64) ⇒ <code>Boolean</code>

<a name="new_Image_new"></a>

### new Image(cursor, [options])
Creates new Image instance.
Worth noting, that Image can be rendered only in iTerm 3.
Applies immediately, without caching in virtual terminal in [Cursor](Cursor).


| Param | Type | Description |
| --- | --- | --- |
| cursor | <code>Cursor</code> | Cursor instance |
| [options] | <code>Object</code> | Options object |
| [options.image] | <code>String</code> | Base64 encoded file or path to image |
| [options.preserveAspectRatio] | <code>Boolean</code> | If true, preserve aspect ratio |

**Example**
```js
Image.create(cursor, {
x: 'center',
y: 'middle',
image: 'my-image.png',
preserveAspectRatio: true
});
```
<a name="Image+getImage"></a>

### image.getImage() ⇒ <code>String</code>
Get base64 encoded image.

**Kind**: instance method of <code>[Image](#Image)</code>
<a name="Image+setImage"></a>

### image.setImage(image) ⇒ <code>[Image](#Image)</code>
Set image to the shape.

**Kind**: instance method of <code>[Image](#Image)</code>

| Param | Type | Description |
| --- | --- | --- |
| image | <code>String</code> | Can be path to the image or base64 encoded image |

**Example**
```js
image.setShape('base64');
image.setShape('./my-image.png');
```
<a name="Image+isPreserveAspectRatio"></a>

### image.isPreserveAspectRatio() ⇒ <code>Boolean</code>
Check if image is preserve aspect ratio.

**Kind**: instance method of <code>[Image](#Image)</code>
<a name="Image+setPreserveAspectRatio"></a>

### image.setPreserveAspectRatio([isPreserveAspectRatio]) ⇒ <code>[Image](#Image)</code>
Set preserve aspect ratio.

**Kind**: instance method of <code>[Image](#Image)</code>

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [isPreserveAspectRatio] | <code>Boolean</code> | <code>true</code> | If false, not preserves aspect ratio in the image |

<a name="Image+render"></a>

### image.render() ⇒ <code>[Image](#Image)</code>
Renders the shape.

**Kind**: instance method of <code>[Image](#Image)</code>
<a name="Image+toObject"></a>

### image.toObject() ⇒ <code>Object</code>
Serializes shape to the object representation.

**Kind**: instance method of <code>[Image](#Image)</code>
<a name="Image.isBase64"></a>

### Image.isBase64(string) ⇒ <code>Boolean</code>
Check if string is base64 encoded string.

**Kind**: static method of <code>[Image](#Image)</code>

| Param | Type |
| --- | --- |
| string | <code>String</code> |

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"clean": "rm -rf ./lib",
"compile": "npm run clean; babel src --out-dir lib",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"docs": "npm run compile; jsdoc2md \"lib/**/*.js\" > API.md",
"prepublish": "npm run compile",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"test": "babel-node ./node_modules/.bin/isparta cover _mocha"
Expand All @@ -32,6 +33,7 @@
"coveralls": "2.11.9",
"cz-conventional-changelog": "1.1.5",
"isparta": "4.0.0",
"jsdoc-to-markdown": "1.3.3",
"kittik-cursor": "4.1.0",
"mocha": "2.4.5",
"semantic-release": "4.3.5",
Expand Down

0 comments on commit 1efa42e

Please sign in to comment.