little refactoring

This commit is contained in:
Anton Lavrenov
2023-04-05 20:37:22 -06:00
parent 390bd3e10b
commit 742c08599a
10 changed files with 1063 additions and 385 deletions

View File

@@ -77,10 +77,10 @@ describe('TextPath', function () {
layer.draw();
var trace = layer.getContext().getTrace();
var trace = layer.getContext().getTrace(true);
assert.equal(
trace,
'clearRect(0,0,578,200);clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(10,10);lineTo(60,10);lineWidth=1;strokeStyle=red;stroke();restore();save();transform(1,0,0,1,0,0);font=normal normal 24px Arial;textBaseline=middle;textAlign=left;save();save();translate(10,10);rotate(0);fillStyle=orange;fillText(T,0,0);restore();save();translate(24.66,10);rotate(0);fillStyle=orange;fillText(h,0,0);restore();save();translate(38.008,10);rotate(0);fillStyle=orange;fillText(e,0,0);restore();save();translate(51.355,10);rotate(0);fillStyle=orange;fillText( ,0,0);restore();restore();restore();'
'clearRect();clearRect();save();transform();beginPath();moveTo();lineTo();lineWidth;strokeStyle;stroke();restore();save();transform();font;textBaseline;textAlign;save();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();restore();restore();'
);
});
@@ -761,7 +761,7 @@ describe('TextPath', function () {
assert.equal(rect.height, 0, 'check height');
});
it.only('dashes on line', function () {
it('dashes on line', function () {
var stage = addStage();
stage.draggable(true);
@@ -773,9 +773,8 @@ describe('TextPath', function () {
fontSize: 16,
scaleX: 0.8,
scaleY: 0.8,
text: '----------------',
text: '_______________',
data: 'M 0,10 L 300 10',
textDecoration: 'underline',
y: 5,
});
layer.add(textpath);
@@ -791,18 +790,10 @@ describe('TextPath', function () {
var rect = textpath.getClientRect();
// just different results in different envs
if (isBrowser) {
assert.equal(Math.round(rect.height), 331, 'check height');
} else {
assert.equal(Math.round(rect.height), 333, 'check height');
}
textpath.text('');
rect = textpath.getClientRect();
assert.equal(rect.height, 0, 'check height');
assert.equal(Math.round(rect.height), 13, 'check height');
});
it.only('check bad calculations', function () {
it('check bad calculations', function () {
var stage = addStage();
stage.draggable(true);
@@ -814,11 +805,19 @@ describe('TextPath', function () {
fontSize: 16,
scaleX: 0.8,
scaleY: 0.8,
textDecoration: 'underline',
text: '__________________________________________________________________________________________________________________________________________________________________________________________________________________',
text: '___________________________________________________________________________________________________________________________________________________________________________________________________________________',
data: 'M 109.98618090452261 138.6656132223618 C 135.94577638190955 48.80547503140701 149.91187876884422 79.79800957914573 151.40954773869348 117.23973382537689 S 123.00811620603017 419.616741991206 122.84170854271358 460.0538041771357 S 134.33883542713568 469.8304329459799 149.98115577889448 464.33898005653265 S 245.4620163316583 411.5856081972362 257.1105527638191 412.91686950376885 S 239.31850251256282 474.434854428392 249.96859296482413 475.76611573492465 S 338.21036306532665 425.67526648869347 348.5276381909548 424.3440051821608 S 337.3640408291457 461.1772344535176 338.5288944723618 464.33898005653265 S 346.8778454773869 466.79295744346734 358.52638190954775 451.4834524183417',
});
layer.add(textpath);
layer.draw();
var trace = layer.getContext().getTrace(true);
assert.equal(
trace,
'restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();save();translate();rotate();fillStyle;fillText();restore();restore();restore();'
);
var path = new Konva.Path({
stroke: 'red',
scaleX: 0.8,
@@ -881,10 +880,11 @@ describe('TextPath', function () {
layer.draw();
var rect = textpath.getClientRect();
assert.equal(Math.round(rect.width), 299);
if (isBrowser) {
assert.equal(Math.round(rect.width), 299);
assert.equal(Math.round(rect.height), 171);
} else {
assert.equal(Math.round(rect.width), 298);
assert.equal(Math.round(rect.height), 170);
}
});