Implements support for Image drawing in terminal.
Kind: global class
Extends: Shape
Since: 1.0.0
- Image ⇐
Shape- new Image(cursor, [options])
- instance
- .getImage() ⇒
String - .setImage(image) ⇒
Image - .isPreserveAspectRatio() ⇒
Boolean - .setPreserveAspectRatio([isPreserveAspectRatio]) ⇒
Image - .render() ⇒
Image - .toObject() ⇒
Object
- .getImage() ⇒
- static
- .isBase64(string) ⇒
Boolean
- .isBase64(string) ⇒
Creates new Image instance. Worth noting, that Image can be rendered only in iTerm 3. Applies immediately, without caching in virtual terminal in Cursor.
| Param | Type | Description |
|---|---|---|
| cursor | Cursor |
Cursor instance |
| [options] | Object |
Options object |
| [options.image] | String |
Base64 encoded file or path to image |
| [options.preserveAspectRatio] | Boolean |
If true, preserve aspect ratio |
Example
Image.create(cursor, {
x: 'center',
y: 'middle',
image: 'my-image.png',
preserveAspectRatio: true
});Get base64 encoded image.
Kind: instance method of Image
image.setImage(image) ⇒ Image
Set image to the shape.
Kind: instance method of Image
| Param | Type | Description |
|---|---|---|
| image | String |
Can be path to the image or base64 encoded image |
Example
image.setShape('base64');
image.setShape('./my-image.png');Check if image is preserve aspect ratio.
Kind: instance method of Image
image.setPreserveAspectRatio([isPreserveAspectRatio]) ⇒ Image
Set preserve aspect ratio.
Kind: instance method of Image
| Param | Type | Default | Description |
|---|---|---|---|
| [isPreserveAspectRatio] | Boolean |
true |
If false, not preserves aspect ratio in the image |
image.render() ⇒ Image
Renders the shape.
Kind: instance method of Image
Serializes shape to the object representation.
Kind: instance method of Image
Check if string is base64 encoded string.
Kind: static method of Image
| Param | Type |
|---|---|
| string | String |