Skip to content

Commit 01445c2

Browse files
committed
Try to optimize translate for latex
1 parent 19cd5b0 commit 01445c2

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

scripts/JSRoot.latex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,7 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
11551155
} else {
11561156
x_up = 3*r; x_low = r;
11571157
path.attr("d",`M0,${Math.round(0.25*h-r)}a${r},${r},0,0,0,${2*r},0v${2*r-h}a${r},${r},0,1,1,${2*r},0`);
1158+
// path.attr('transform','skewX(-3)'); could use skewX for italic-like style
11581159
}
11591160

11601161
if (subs.low) {

scripts/JSRoot.painter.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ JSROOT.define(['d3'], (d3) => {
773773
* @memberof JSROOT
774774
* @param {object} args - different arguments to set fill attributes, see {@link JSROOT.TAttFillHandler.setArgs} for more info
775775
* @param {number} [args.kind = 2] - 1 means object drawing where combination fillcolor==0 and fillstyle==1001 means no filling, 2 means all other objects where such combination is white-color filling
776-
* @private
777776
*/
778777

779778
function TAttFillHandler(args) {
@@ -2749,10 +2748,19 @@ JSROOT.define(['d3'], (d3) => {
27492748

27502749
if (!arg.rotate) { arg.x += arg.dx; arg.y += arg.dy; arg.dx = arg.dy = 0; }
27512750

2752-
let trans = (arg.x || arg.y) ? "translate(" + Math.round(arg.x) + "," + Math.round(arg.y) + ")" : "";
2753-
if (arg.rotate) trans += " rotate(" + Math.round(arg.rotate) + ")";
2754-
if (scale !== 1) trans += ` scale(${scale.toFixed(3)})`;
2755-
if (arg.dx || arg.dy) trans += " translate(" + Math.round(arg.dx) + "," + Math.round(arg.dy) + ")";
2751+
let trans = "";
2752+
if (arg.y)
2753+
trans = "translate(" + Math.round(arg.x) + "," + Math.round(arg.y) + ")";
2754+
else if (arg.x)
2755+
trans = "translate(" + Math.round(arg.x) + ")";
2756+
if (arg.rotate)
2757+
trans += " rotate(" + Math.round(arg.rotate) + ")";
2758+
if (scale !== 1)
2759+
trans += " scale(" + scale.toFixed(3) + ")";
2760+
if (arg.dy)
2761+
trans += " translate(" + Math.round(arg.dx) + "," + Math.round(arg.dy) + ")";
2762+
else if (arg.dx)
2763+
trans += " translate(" + Math.round(arg.dx) + ")";
27562764
if (trans) txt_g.attr("transform", trans);
27572765
});
27582766

0 commit comments

Comments
 (0)