Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Negative coordinates in \p tag #79

Open
RinonNinqueon opened this issue May 4, 2016 · 2 comments
Open

Negative coordinates in \p tag #79

RinonNinqueon opened this issue May 4, 2016 · 2 comments

Comments

@RinonNinqueon
Copy link

There's a problem, when you try to use negative coordinates in \p tag.
You can use it in SVG, but you need to set viewBox attribute.
I changed DrawingStyles.prototype.toSVG function.
First find minimum value:

bboxWidthMin = Math.min(bboxWidthMin, instruction.x);
bboxHeightMin = Math.min(bboxHeightMin, instruction.y + this._baselineOffset);

And then something like this:

var bboxWidth1 = bboxWidth;
var bboxHeight1 = bboxHeight;

if (bboxWidthMin < 0)
    bboxWidth1 -= bboxWidthMin;
if (bboxHeightMin < 0)
    bboxHeight1 -= bboxHeightMin;

var width_str = (bboxWidth1 * scaleX).toFixed(3) + "px";
var height_str = (bboxHeight1 * scaleY).toFixed(3) + "px";
svg.width.baseVal.valueAsString = width_str;
svg.height.baseVal.valueAsString = height_str;

var viewBox_str = (bboxWidthMin * scaleX) + " " + (bboxHeightMin * scaleX) + " " + (bboxWidth1 * scaleX) + " " + (bboxHeight1 * scaleX);
svg.setAttribute("viewBox", viewBox_str);

It works, but looks still strange:
yuurei_bad
Need to be like this:
yuurei_good
And of course code of graphics:

Dialogue: 0,0:0:0.0,0:01:42.56,Default,,0,0,0,,{\fad(100,10)\an5\p1\fscx200\fscy200\shad0\pos(402.667,205.333)}m 3 19 b 2 18 -2 18 -4 17 b -12 14 -18 4 -18 -4 b -18 -14 -12 -19 -8 -21 b 0 -25 13 -21 18 -6 b 20 -1 22 6 20 13 b 19 15 17 13 15 15 b 14 16 14 19 13 19 b 11 19 10 17 8 18 b 8 18 7 19 6 20 b 5 21 4 20 4 20
Dialogue: 0,0:0:0.0,0:01:42.56,Default,,0,0,0,,{\fad(100,10)\an5\p1\fscx200\fscy200\shad0\pos(372.667,168.333)}m 5 -19 b 4 -21 2 -25 4 -25 b 5 -25 7 -23 7 -20 b 7 -22 10 -24 11 -22 b 12 -20 10 -18 8 -18 b 10 -17 10 -14 8 -14 b 7 -14 6 -15 6 -17 b 4 -15 2 -15 2 -17 b 2 -18 3 -20 5 -19
Dialogue: 0,0:0:0.0,0:01:42.56,Default,,0,0,0,,{\fad(100,10)\an5\p1\fscx200\fscy200\shad0\pos(366.667,161.333)}m 5 -19 b 5 -21 9 -20 8 -18 b 7 -16 5 -18 5 -19
Dialogue: 0,0:0:0.0,0:01:42.56,Default,,0,0,0,,{\fad(100,10)\an5\p1\fscx200\fscy200\c&H000000&\bord0\shad0\shad0\pos(392.667,177.333)}m -13 0 b -12 4 -2 6 -3 -4 l -4 -3 b -3 4 -11 3 -12 0 m 1 -5 b 4 1 14 -3 10 -10 l 9 -9 b 12 -4 5 -1 2 -5 m 0 2 b 1 4 5 3 3 0 b 4 3 0 3 0 2
Dialogue: 0,0:0:0.0,0:01:42.56,Default,,0,0,0,,{\fad(100,10)\an5\p1\fscx200\fscy200\bord0\shad0\c&H748AF4&\shad0\pos(388.667,172.333)}m -6 6 b -4 5 -6 3 -8 4 b -10 5 -8 7 -6 6 m 8 -2 b 6 0 9 0 10 -1 b 11 -2 10 -4 8 -2
@Arnavion
Copy link
Owner

Arnavion commented May 4, 2016

Did you test with master or 0.11.0 ? master has this commit.

@RinonNinqueon
Copy link
Author

I got version from npm install --save libjass.
Now I compiled latest git version and have this:
yuureibad_2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants