Skip to content

Commit

Permalink
feat(shape): Implements simple text shape
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Nov 13, 2015
1 parent 9cdb821 commit 9dc1a52
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/shapes/Text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Shape } from '../Shape';

export class Text extends Shape {
/**
* Creates new Text instance
* @constructor
*/
constructor(...args) {
super(...args);
}

/**
* Renders a shape
* @param {Cursor} cursor
* @returns {Text}
*/
render(cursor) {
let {x, y} = this.getPosition();
let text = this.getText();
let background = this.getBackground();
let foreground = this.getForeground();

if (background) cursor.background(background);
if (foreground) cursor.foreground(foreground);

cursor.setPosition(x, y);
cursor.write(text);

return this;
}
}

0 comments on commit 9dc1a52

Please sign in to comment.