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

46 lines
1.0 KiB
JavaScript
Raw Normal View History

import $ from 'jquery';
2022-07-13 03:58:11 +02:00
import { Workspace, Rect } from '../../src';
2021-12-05 00:39:20 +01:00
global.$ = $;
const rectExampleTest = () => {
const workspace = new Workspace();
workspace.setSize('100px', '100px');
workspace.setCoordSize(100, 100);
workspace.setCoordOrigin(0, 0);
const rect = new Rect();
rect.setPosition(20, 20);
workspace.append(rect);
workspace.addItAsChildTo($('#rectExample'));
};
rectExampleTest();
const roundrectExampleTest = () => {
function builder(container, x, width, height) {
for (let i = 1; i <= 10; i++) {
const rect = new Rect(i / 10);
2022-07-13 03:58:11 +02:00
rect.setPosition(x, (i - 1) * (50 + 5));
2021-12-05 00:39:20 +01:00
rect.setSize(width, height);
container.append(rect);
}
}
// 50 x 50
const workspace = new Workspace();
workspace.setSize('500px', '550px');
workspace.setCoordOrigin(0, -4);
workspace.setCoordSize(500, 550);
workspace.addItAsChildTo($('#roundRect'));
builder(workspace, 10, 50, 50);
// 100 x 50
builder(workspace, 70, 100, 50);
// 200 x 50
builder(workspace, 180, 200, 50);
};
roundrectExampleTest();