2021-12-05 17:33:09 +01:00
|
|
|
import $ from 'jquery';
|
2022-07-13 03:58:11 +02:00
|
|
|
import { Workspace, Text } from '../../src';
|
2021-12-05 00:39:20 +01:00
|
|
|
|
|
|
|
global.$ = $;
|
|
|
|
|
2022-01-03 22:01:16 +01:00
|
|
|
function multiline(text, fontName, elemId) {
|
2021-12-05 00:39:20 +01:00
|
|
|
const workspace = new Workspace();
|
|
|
|
workspace.setSize('200px', '240px');
|
|
|
|
workspace.setCoordSize('200', '240');
|
|
|
|
workspace.setCoordOrigin(0, 0);
|
|
|
|
|
|
|
|
[6, 8, 10, 15].forEach((size, i) => {
|
|
|
|
const wText = new Text();
|
|
|
|
workspace.append(wText);
|
|
|
|
|
|
|
|
wText.setText(text);
|
2022-01-03 22:01:16 +01:00
|
|
|
wText.setFont(fontName, size, 'bold');
|
2021-12-05 00:39:20 +01:00
|
|
|
wText.setPosition(30, 50 * i);
|
|
|
|
wText.setColor('blue');
|
|
|
|
});
|
|
|
|
|
|
|
|
workspace.addItAsChildTo($(`#${elemId}`));
|
|
|
|
}
|
|
|
|
|
|
|
|
function alignments(text, family, elemId) {
|
2021-12-30 21:32:32 +01:00
|
|
|
const workspace = new Workspace();
|
|
|
|
workspace.setSize('260px', '240px');
|
|
|
|
workspace.setCoordSize('260', '240');
|
|
|
|
workspace.setCoordOrigin(0, 0);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
|
|
|
['center', 'left', 'right'].forEach((align, i) => {
|
|
|
|
const wText = new Text();
|
2021-12-30 21:32:32 +01:00
|
|
|
workspace.append(wText);
|
2021-12-05 00:39:20 +01:00
|
|
|
|
|
|
|
wText.setText(text);
|
|
|
|
wText.setFont(family, 8, 'bold');
|
|
|
|
wText.setPosition(30, 80 * i);
|
|
|
|
wText.setColor('green');
|
|
|
|
wText.setTextAlignment(align);
|
|
|
|
});
|
|
|
|
|
2021-12-30 21:32:32 +01:00
|
|
|
workspace.addItAsChildTo($(`#${elemId}`));
|
2021-12-05 00:39:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Multine tests ...
|
2022-01-03 22:01:16 +01:00
|
|
|
['Arial', 'Tahoma', 'Verdana', 'Times', 'Brush Script MT'].forEach((fontName, i) => {
|
|
|
|
multiline('This multine text.\nLine 1 :)\nLine2', fontName, `multi${i}`);
|
2021-12-05 00:39:20 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Multine tests and alingments .. ...
|
2022-01-03 22:01:16 +01:00
|
|
|
['Arial', 'Tahoma', 'Verdana', 'Times', 'Brush Script MT'].forEach((fontName, i) => {
|
2022-07-13 03:58:11 +02:00
|
|
|
alignments(
|
|
|
|
'This multine text.\nThis is the long line just because :)\nShort line',
|
|
|
|
fontName,
|
|
|
|
`amulti${i}`,
|
|
|
|
);
|
2021-12-05 00:39:20 +01:00
|
|
|
});
|