Colour codes for G4VisAttributes

Hello ,

Can anybody share or suggest from where we can get the list of colour codes used for visualaising the components ? I am finding difficulty in setting different colour for targets .
For example G4VisAttributes G4Colour ( 0., 0., 1. ); this ( 0., 0., 1. ) is for blue colour.

Thank You

_Geant4 Version:_PACKAGE_VERSION “10.4.2”
_Operating System:_CentOS LINUX
Compiler/Version: CPack ,Terminal
CMake Version: CPack

That should read

  G4VisAttributes blue(G4Colour( 0., 0., 1. ));

This is a matter of understanding C++. It looks like you need to take a course in C++ programming. It’s nonsense to say G4VisAttributes G4Colour. So:

  • A quick look at almost any example will show how it’s done. Have a look at examples/basic/B5/src/
  • Colours can be set by commands. See B1/vis.mac.
  • The ultimately, the header files G4VisAttributes.hh' and G4Colour.hh’ define what’s available.

You can also, for example

  G4Colour pink;
  G4Colour::GetColour("pink", pink);

There’s a cryptic command just after the list of registered graphics systems:

Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.

which perhaps should also say these colours are also available in C++. When you issue /vis/list, you get:

Some /vis commands (optionally) take a string to specify colour.
Available colours:
  aquamarine, black, blue, blueviolet, brown, cadetblue, coral, cornflowerblue, cyan,
darkgreen, darkolivegreen, darkorchid, darkslateblue, darkslategrey, darkturquoise,
dimgrey, firebrick, forestgreen, gold, goldenrod, gray, green, greenyellow, grey, indianred,
khaki, lightblue, lightgrey, lightsteelblue, limegreen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue, navy, navyblue, orange, orangered,
orchid, palegreen, pink, plum, red, salmon, seagreen, sienna, skyblue, slateblue,
springgreen, steelblue, tan, thistle, turquoise, violet, violetred, wheat, white, yellow,
1 Like

(Not sure all those features are available in Giant 10.4. That’s quite an old version.)

THANK YOU for making sense of the wrong code .

Still I had already used it in one of my programs as -

G4VisAttributes* sphereAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.2));

and it worked .

Thank You for sharing the list of available colours .

Compare the two lines:

G4VisAttributes G4Colour ( 0., 0., 1. );


G4VisAttributes* sphereAttributes = new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.2));

Pay attention to the parentheses in the second case. At the innermost level, you are instantiating a (temporary) G4Colour object, with the given constructor arguments. Then, that object gets passed into the constructor for G4VisAttributes. The address of the newly instantiated G4VisAttributes object is stored in your sphereAttributes variable.

As John Allison noted, this is basic C++ language syntax. Once you understand the syntax, a lot of other things will become much less mysterious or arbitrary.