diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index ff3e9ca10fd5eccbf01a771db553bbc049054313..4b6857e9693f4ba71f37da2000ac99383260dc7e 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -256,8 +256,8 @@ A new color can be created transparent the following way: </pre> An example of tranparency usage with parallel coordinates can be found in <tt>$ROOTSYS/tutorials/tree/parallelcoordtrans.C</tt>. Right now the -transparency is implemented only for PDF output, and for gif, jpg and png -when root runs in batch mode. +transparency is implemented only for PDF output, SVG output, and for gif, +jpg and png outputs, when root runs in batch mode. */ diff --git a/graf2d/doc/v534/index.html b/graf2d/doc/v534/index.html index 8b162aa62d62661600a4e0b58de835a17bfada0a..3ceb2d32b3df601a604bfcb488529df86ad874f8 100644 --- a/graf2d/doc/v534/index.html +++ b/graf2d/doc/v534/index.html @@ -36,6 +36,13 @@ </li> </ul> +<h4>TSVG</h4> +<ul> + <li> + Implement the transparency in SVG files (cf TPDF). + </li> +</ul> + <h4>TLegend</h4> <ul> <li> diff --git a/graf2d/postscript/src/TSVG.cxx b/graf2d/postscript/src/TSVG.cxx index d8d543e0f48a64f2dff0d553ca488fcdcceaafee..9b8fbe1a375c77ad9e5cc7340a0810afda89cbc0 100644 --- a/graf2d/postscript/src/TSVG.cxx +++ b/graf2d/postscript/src/TSVG.cxx @@ -440,23 +440,14 @@ void TSVG::DrawPolyLine(Int_t nn, TPoints *xy) if (nn > 0) { n = nn; -/// SetLineStyle(fLineStyle); -/// SetLineWidth(fLineWidth); -/// SetColor(Int_t(fLineColor)); } else { n = -nn; -/// SetLineStyle(1); -/// SetLineWidth(1); -/// SetColor(Int_t(fLineColor)); } ixd0 = XtoSVG(xy[0].GetX()); iyd0 = YtoSVG(xy[0].GetY()); -/// WriteInteger(ixd0); -/// WriteInteger(iyd0); if( n <= 1) { if( n == 0) return; -/// PrintFast(2," m"); return; } @@ -502,10 +493,7 @@ void TSVG::DrawPolyLine(Int_t nn, TPoints *xy) if( idy ) MovePS(0,idy); if (nn > 0 ) { -/// if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl"); -/// PrintFast(2," s"); } else { -/// PrintFast(2," f"); } } @@ -526,27 +514,17 @@ void TSVG::DrawPolyLineNDC(Int_t nn, TPoints *xy) if (nn > 0) { n = nn; -/// SetLineStyle(fLineStyle); -/// SetLineWidth(fLineWidth); -/// SetColor(Int_t(fLineColor)); } else { n = -nn; -/// SetLineStyle(1); -/// SetLineWidth(1); -/// SetColor(Int_t(fLineColor)); } ixd0 = UtoSVG(xy[0].GetX()); iyd0 = VtoSVG(xy[0].GetY()); -/// WriteInteger(ixd0); -/// WriteInteger(iyd0); if( n <= 1) { if( n == 0) return; -/// PrintFast(2," m"); return; } -/// PrintFast(2," m"); idx = 0; idy = 0; for (Int_t i=1;i<n;i++) { @@ -589,9 +567,7 @@ void TSVG::DrawPolyLineNDC(Int_t nn, TPoints *xy) if (nn > 0 ) { if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl"); -/// PrintFast(2," s"); } else { -/// PrintFast(2," f"); } } @@ -1069,12 +1045,6 @@ void TSVG::DrawPS(Int_t nn, Double_t *xw, Double_t *yw) // If nn>0 a line is drawn. // If nn<0 a closed polygon is drawn. -///static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075, -/// .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 , -/// .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015}; -///static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60, -/// 180, 90,135, 45,150, 30,120, 60, -/// 180, 90,135, 45,150, 30,120, 60}; Int_t n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi; fais = fasi = 0; @@ -1086,11 +1056,9 @@ void TSVG::DrawPS(Int_t nn, Double_t *xw, Double_t *yw) fasi = fFillStyle%1000; if (fais == 3 || fais == 2) { if (fasi > 100 && fasi <125) { -/// DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw); return; } if (fasi > 0 && fasi < 26) { -/// SetFillPatterns(fasi, Int_t(fFillColor)); } } } @@ -1164,9 +1132,6 @@ void TSVG::DrawPS(Int_t nn, Double_t *xw, Double_t *yw) if (fais == 0) { PrintFast(14,"\"none\" stroke="); SetColor(fFillColor); -/// } else if (fais == 3 || fais == 2) { -/// if (fasi > 0 && fasi < 26) { -/// Put SVG patterns here } else { SetColor(fFillColor); } @@ -1385,6 +1350,10 @@ void TSVG::SetColor(Int_t color) } else { SetColor(1., 1., 1.); } + Float_t a = col->GetAlpha(); + if (a<1.) { + PrintStr(Form(" fill-opacity=\"%3.2f\" stroke-opacity=\"%3.2f\"",a,a)); + } } @@ -1654,6 +1623,7 @@ void TSVG::CellArrayBegin(Int_t, Int_t, Double_t, Double_t, Double_t, Double_t) { // Begin the Cell Array painting + Warning("TSVG::CellArrayBegin", "not yet implemented"); } @@ -1662,6 +1632,7 @@ void TSVG::CellArrayBegin(Int_t, Int_t, Double_t, Double_t, Double_t, void TSVG::CellArrayFill(Int_t, Int_t, Int_t) { // Paint the Cell Array + Warning("TSVG::CellArrayFill", "not yet implemented"); } @@ -1670,6 +1641,7 @@ void TSVG::CellArrayFill(Int_t, Int_t, Int_t) void TSVG::CellArrayEnd() { // End the Cell Array painting + Warning("TSVG::CellArrayEnd", "not yet implemented"); } @@ -1678,5 +1650,6 @@ void TSVG::CellArrayEnd() void TSVG::DrawPS(Int_t, Float_t *, Float_t *) { // Not needed in SVG case + Warning("TSVG::DrawPS", "not yet implemented"); } diff --git a/tutorials/tree/parallelcoordtrans.C b/tutorials/tree/parallelcoordtrans.C index 89d6d182779380bb236e797d16300874a8147b38..89c61a77b2bfc760b1df25164f8d78307cbd0a5d 100644 --- a/tutorials/tree/parallelcoordtrans.C +++ b/tutorials/tree/parallelcoordtrans.C @@ -9,7 +9,7 @@ // Script illustrating the use of transparency (right now in PDF file only) with ||-Coord. // It displays the same data set twice. The first time without transparency and -// the second time with transparency. On the second plot, several clusters +// the second time with transparency. On the second plot, several clusters // appear. //Author: Olivier Couet @@ -37,7 +37,7 @@ void parallelcoordtrans() { TCanvas *c1 = new TCanvas("c1", "c1",0,0,900,1000); c1->Divide(1,2); - + TNtuple *nt = new TNtuple("nt","Demo ntuple","x:y:z:u:v:w:a:b:c"); int n=0; @@ -45,11 +45,11 @@ void parallelcoordtrans() { r->Sphere(s1x, s1y, s1z, 0.1); r->Sphere(s2x, s2y, s2z, 0.2); r->Sphere(s3x, s3y, s3z, 0.05); - + generate_random(i); nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9); n++; - + generate_random(i); nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z, r7, r8, r9); n++; @@ -61,7 +61,7 @@ void parallelcoordtrans() { generate_random(i); nt->Fill(s2x-1, s2y-1, s2z, s1x+.5, s1y+.5, s1z+.5, r7, r8, r9); n++; - + generate_random(i); nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9); n++; @@ -74,11 +74,11 @@ void parallelcoordtrans() { nt->Fill(r1, r2, r3, r4, r5, r6, s3x, r8, s3z ); n++; } - + TParallelCoordVar* pcv; - + c1->cd(1); - + // ||-Coord plot without transparency nt->Draw("x:y:z:u:v:w:a:b:c","","para"); TParallelCoord* para1 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord"); @@ -109,11 +109,12 @@ void parallelcoordtrans() { pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("u"); pcv->SetHistogramHeight(0.); pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("v"); pcv->SetHistogramHeight(0.); pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("w"); pcv->SetHistogramHeight(0.); - - // Produces transparent lines in interactive and batch mode + + // Produce transparent lines in interactive and batch mode c1->Print("parallelcoordtrans.pdf"); + c1->Print("parallelcoordtrans.svg"); - // Produces transparent lines in batch mode only + // Produce transparent lines in batch mode only c1->Print("parallelcoordtrans.gif"); c1->Print("parallelcoordtrans.jpg"); c1->Print("parallelcoordtrans.png");