Skip to content

Commit

Permalink
feat(shape): Implements Rectangle shape
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Nov 12, 2015
1 parent 2809c2f commit f4c4376
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/shapes/Rectangle.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import Shape from './../Shape';
import { COLORS } from '../Cursor';
import { Shape } from '../Shape';

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

/**
* Renders the shape
* @param {Cursor} cursor
* @returns {Rectangle}
*/
render(cursor) {
let text = ' ';
let position = this.getPosition();
let width = this.getWidth();
let height = this.getHeight();
let background = this.getBackground();
let foreground = this.getForeground();

cursor
.reset()
.background(COLORS.YELLOW)
.setPosition(this.getPosition().x, this.getPosition().y)
.write(text)
.move(-text.length, 1)
.write(text)
.move(-text.length, 1)
.write(text);
cursor.fill({
x1: position.x,
y1: position.y,
x2: width + position.x,
y2: height + position.y,
background,
foreground
});

return this;
}
}

0 comments on commit f4c4376

Please sign in to comment.