Skip to content

Latest commit

 

History

History
107 lines (79 loc) · 3.27 KB

File metadata and controls

107 lines (79 loc) · 3.27 KB

Image ⇐ Shape

Implements support for Image drawing in terminal.

Kind: global class
Extends: Shape
Since: 1.0.0

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.

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
});

image.getImage() ⇒ String

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');

image.isPreserveAspectRatio() ⇒ Boolean

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

image.toObject() ⇒ Object

Serializes shape to the object representation.

Kind: instance method of Image

Image.isBase64(string) ⇒ Boolean

Check if string is base64 encoded string.

Kind: static method of Image

Param Type
string String