avocado-old/packages/physics/shape-from-json.js

24 lines
532 B
JavaScript
Raw Normal View History

import {PolygonShape} from './polygon';
import {CircleShape} from './circle';
import {RectangleShape} from './rectangle';
import {ShapeList} from './list';
export function shapeFromJSON(json) {
let shape;
switch (json.type) {
case 'circle':
shape = new CircleShape();
break;
case 'list':
shape = new ShapeList();
break;
case 'polygon':
shape = new PolygonShape();
break;
case 'rectangle':
shape = new RectangleShape();
break;
}
return shape.fromJSON(json);
}