wisemapping-frontend/packages/web2d/test/playground/curvedLine.js

94 lines
2.5 KiB
JavaScript
Raw Normal View History

import $ from 'jquery';
2022-12-22 09:13:23 +01:00
import { Workspace, CurvedLine, Point, Elipse } from '../../src';
2022-12-23 04:12:55 +01:00
const drawLine = (size) => {
2022-12-22 09:13:23 +01:00
const workspace = new Workspace();
workspace.setSize('300px', '300px');
workspace.setCoordSize(300, 300);
workspace.setCoordOrigin(-150, -150);
// Line 1 ...
const line1 = new CurvedLine();
line1.setFrom(0, 0);
line1.setTo(100, 100);
line1.setSrcControlPoint(new Point(100 / 2, 0));
line1.setDestControlPoint(new Point(-100 / 2, 0));
2022-12-23 04:12:55 +01:00
line1.setStroke(1, 'solid', 'blue', 1);
line1.setWidth(size);
2022-12-22 09:13:23 +01:00
workspace.append(line1);
const line2 = new CurvedLine();
line2.setFrom(0, 0);
line2.setTo(-100, -100);
line2.setSrcControlPoint(new Point(-100 / 2, 0));
line2.setDestControlPoint(new Point(100 / 2, 0));
2022-12-23 04:12:55 +01:00
line2.setStroke(1, 'solid', 'blue', 1);
line2.setWidth(size);
2022-12-22 09:13:23 +01:00
workspace.append(line2);
const line3 = new CurvedLine();
line3.setFrom(0, 0);
line3.setTo(100, -100);
line3.setSrcControlPoint(new Point(100 / 2, 0));
line3.setDestControlPoint(new Point(-100 / 2, 0));
2022-12-23 04:12:55 +01:00
line3.setStroke(1, 'solid', 'blue', 1);
line3.setWidth(size);
2022-12-22 09:13:23 +01:00
workspace.append(line3);
const line4 = new CurvedLine();
line4.setFrom(0, 0);
line4.setTo(-100, 100);
line4.setSrcControlPoint(new Point(-100 / 2, 0));
line4.setDestControlPoint(new Point(100 / 2, 0));
2022-12-23 04:12:55 +01:00
line4.setStroke(1, 'solid', 'blue', 1);
line4.setWidth(size);
2022-12-22 09:13:23 +01:00
workspace.append(line4);
// Add referene point ...
const e1 = new Elipse();
2022-12-23 04:12:55 +01:00
e1.setSize(5, 5);
2022-12-22 09:13:23 +01:00
e1.setPosition(0, 0);
2022-12-23 04:12:55 +01:00
e1.setFill('red');
2022-12-22 09:13:23 +01:00
workspace.append(e1);
const e2 = new Elipse();
e2.setPosition(-100, -100);
e2.setSize(10, 10);
workspace.append(e2);
const e3 = new Elipse();
e3.setPosition(100, 100);
e3.setSize(10, 10);
workspace.append(e3);
const e4 = new Elipse();
e4.setPosition(-100, 100);
e4.setSize(10, 10);
workspace.append(e4);
const e5 = new Elipse();
e5.setPosition(100, -100);
e5.setSize(10, 10);
workspace.append(e5);
return workspace;
};
2022-12-23 04:12:55 +01:00
const w1 = drawLine(1);
2022-12-22 09:13:23 +01:00
w1.addItAsChildTo($('#curvedSimpleExample').first());
2022-12-23 04:12:55 +01:00
const w2 = drawLine(28);
2022-12-22 09:13:23 +01:00
w2.addItAsChildTo($('#curvedNiceExample').first());
2022-12-23 04:12:55 +01:00
const w3 = drawLine(1);
w3.addItAsChildTo($('#curvedSize1NiceExample').first());
const w4 = drawLine(7);
w4.addItAsChildTo($('#curvedSize7NiceExample').first());
const w5 = drawLine(14);
w5.addItAsChildTo($('#curvedSize14NiceExample').first());
const w6 = drawLine(30);
w6.addItAsChildTo($('#curvedSize30NiceExample').first());