Skip to content

Commit

Permalink
feat(slide): Impplements simple Slide wrapper that allows to render t…
Browse files Browse the repository at this point in the history
…he slide
  • Loading branch information
ghaiklor committed Nov 21, 2015
1 parent b66f792 commit 881b956
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/Slide.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import { Shape } from './shapes/Shape';
import { Rectangle } from './shapes/Rectangle';
import { Text } from './shapes/Text';

/**
* Creates a new slide with shapes.
*
* @since 1.0.0
* @version 1.0.0
*/
export class Slide {
/**
* Creates new Slide instance
* @constructor
*/
constructor() {
this._shapes = [];
}
_shapes = [];

/**
* Adds shape to slide
* @param {Shape} shape
* @returns {Slide}
* Creates new Slide instance.
*
* @param {Array<Shape>} shapes Array of serialized shapes
* @constructor
*/
addShape(shape) {
if (!(shape instanceof Shape)) throw new Error('You must provide Shape instance');

this._shapes.push(shape);
return this;
constructor(shapes) {
this._shapes = shapes.map(shape => {
if (shape.name === 'Rectangle') return Rectangle.fromObject(shape.options);
if (shape.name === 'Text') return Text.fromObject(shape.options);
});
}

/**
* Renders the slide
* @param {Cursor} cursor
* Renders the slide.
*
* @param {Cursor} cursor Cursor instance which is using for rendering the slide
* @returns {Slide}
*/
render(cursor) {
Expand Down

0 comments on commit 881b956

Please sign in to comment.