Skip to content

Commit 73577a8

Browse files
committed
Fix - support transparancy (alpha) in TColor (#45)
1 parent d60e6f3 commit 73577a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/JSRootPainter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@
248248

249249
JSROOT.Painter.MakeColorRGB = function(col) {
250250
if ((col==null) || (col._typename != 'TColor')) return null;
251-
var rgb = "rgb(" + (col.fRed*255).toFixed(0) + "," + (col.fGreen*255).toFixed(0) + "," + (col.fBlue*255).toFixed(0) + ")";
251+
var rgb = Math.round(col.fRed*255) + "," + Math.round(col.fGreen*255) + "," + Math.round(col.fBlue*255);
252+
if ((col.fAlpha === undefined) || (col.fAlpha == 1.))
253+
rgb = "rgb(" + rgb + ")";
254+
else
255+
rgb = "rgba(" + rgb + "," + col.fAlpha.toFixed(3) + ")";
256+
252257
switch (rgb) {
253258
case 'rgb(255,255,255)' : rgb = 'white'; break;
254259
case 'rgb(0,0,0)' : rgb = 'black'; break;

0 commit comments

Comments
 (0)