fantasy/painting/factory.js

16 lines
316 B
JavaScript

import Rectangle from "./rectangle.js";
import Circle from "./circle.js";
const options = [
Rectangle,
Circle
];
export default {
createRandomShape: function() {
let Shape = options[Math.floor(Math.random() * options.length)];
return Shape.fromOptions(Shape.randomOptions());
}
};