2021-12-05 17:33:09 +01:00
|
|
|
import $ from 'jquery';
|
2022-12-21 05:53:13 +01:00
|
|
|
import { Workspace, PolyLine, Elipse } from '../../src';
|
2021-12-05 00:39:20 +01:00
|
|
|
|
|
|
|
global.$ = $;
|
2022-12-21 05:53:13 +01:00
|
|
|
const drawLine = (type) => {
|
|
|
|
const workspace = new Workspace();
|
|
|
|
workspace.setSize('300px', '300px');
|
|
|
|
workspace.setCoordSize(300, 300);
|
|
|
|
workspace.setCoordOrigin(-150, -150);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
// Add referene point ...
|
|
|
|
const e1 = new Elipse();
|
|
|
|
e1.setSize(10, 10);
|
|
|
|
e1.setPosition(0, 0);
|
|
|
|
workspace.append(e1);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const e2 = new Elipse();
|
|
|
|
e2.setPosition(-100, -100);
|
|
|
|
e2.setSize(10, 10);
|
|
|
|
workspace.append(e2);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const e3 = new Elipse();
|
|
|
|
e3.setPosition(100, 100);
|
|
|
|
e3.setSize(10, 10);
|
|
|
|
workspace.append(e3);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const e4 = new Elipse();
|
|
|
|
e4.setPosition(-100, 100);
|
|
|
|
e4.setSize(10, 10);
|
|
|
|
workspace.append(e4);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const e5 = new Elipse();
|
|
|
|
e5.setPosition(100, -100);
|
|
|
|
e5.setSize(10, 10);
|
|
|
|
workspace.append(e5);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
// Line 1 ...
|
|
|
|
const line1 = new PolyLine();
|
|
|
|
line1.setFrom(0, 0);
|
|
|
|
line1.setTo(100, 100);
|
|
|
|
line1.setStyle(type);
|
|
|
|
line1.setStroke('1');
|
|
|
|
workspace.append(line1);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const line2 = new PolyLine();
|
|
|
|
line2.setFrom(0, 0);
|
|
|
|
line2.setTo(-100, -100);
|
|
|
|
line2.setStyle(type);
|
|
|
|
line2.setStroke('1');
|
|
|
|
workspace.append(line2);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const line3 = new PolyLine();
|
|
|
|
line3.setFrom(0, 0);
|
|
|
|
line3.setTo(100, -100);
|
|
|
|
line3.setStyle(type);
|
|
|
|
line3.setStroke('1');
|
|
|
|
workspace.append(line3);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const line4 = new PolyLine();
|
|
|
|
line4.setFrom(0, 0);
|
|
|
|
line4.setTo(-100, 100);
|
|
|
|
line4.setStyle(type);
|
|
|
|
line2.setStroke('1');
|
|
|
|
workspace.append(line4);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
return workspace;
|
|
|
|
};
|
|
|
|
const w1 = drawLine('Straight');
|
|
|
|
w1.addItAsChildTo($('#straightSample'));
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const w2 = drawLine('MiddleStraight');
|
|
|
|
w2.addItAsChildTo($('#middleStraightSample'));
|
2021-12-05 00:39:20 +01:00
|
|
|
|
2022-12-21 05:53:13 +01:00
|
|
|
const w3 = drawLine('MiddleCurved');
|
|
|
|
w3.addItAsChildTo($('#middleCurvedSample'));
|
|
|
|
|
|
|
|
const w4 = drawLine('Curved');
|
|
|
|
w4.addItAsChildTo($('#curvedSample'));
|