25 lines
499 B
JavaScript
25 lines
499 B
JavaScript
import {PolygonShape} from './polygon';
|
|
export {PolygonShape};
|
|
|
|
import {RectangleShape} from './rectangle';
|
|
export {RectangleShape};
|
|
|
|
import {ShapeList} from './list';
|
|
export {ShapeList};
|
|
|
|
export function shapeFromJSON(json) {
|
|
let shape;
|
|
switch (json.type) {
|
|
case 'list':
|
|
shape = new ShapeList();
|
|
break;
|
|
case 'polygon':
|
|
shape = new PolygonShape();
|
|
break;
|
|
case 'rectangle':
|
|
shape = new RectangleShape();
|
|
break;
|
|
}
|
|
return shape.fromJSON(json);
|
|
}
|