wisemapping-frontend/packages/web2d/storybook/src/stories/Ellipse.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-01-30 05:10:57 +01:00
/* eslint-disable import/prefer-default-export */
// eslint-disable-next-line import/prefer-default-export
2023-02-10 03:51:52 +01:00
import Ellipse from '../../../src/components/Ellipse';
2023-01-30 05:10:57 +01:00
import Workspace from '../../../src/components/Workspace';
export const createEllipse = ({
backgroundColor,
strokeColor,
strokeWidth,
onClick,
strokeStyle,
size,
arc,
}) => {
const divElem = document.createElement('div');
const workspace = new Workspace();
workspace.setSize('400px', '400px');
workspace.setCoordSize(300, 300);
workspace.setCoordOrigin(-150, -150);
2023-02-10 03:51:52 +01:00
const rect = new Ellipse(arc);
2023-01-30 05:10:57 +01:00
rect.setFill(backgroundColor);
const parsedSize = JSON.parse(size);
rect.setSize(parsedSize.width, parsedSize.height);
rect.setPosition(0, 0);
rect.setStroke(strokeWidth, strokeStyle, strokeColor, 1);
rect.addEvent('click', onClick);
// Add referene point ...
2023-02-10 03:51:52 +01:00
const e1 = new Ellipse();
2023-01-30 05:10:57 +01:00
e1.setSize(5, 5);
e1.setPosition(0, 0);
e1.setFill('red');
workspace.append(rect);
workspace.append(e1);
workspace.addItAsChildTo(divElem);
return divElem;
};