Menu

#205 Feature request: getter for current colour

open
nobody
None
5
2023-08-04
2023-08-04
AstroFloyd
No

I would like a function/subroutine that tells my program which colour (map and index) is currently being used. This information is available in the source code as plsc->curcmap and plsc->icol0, but is unavailable to my Fortran user program. This function would be the opposite of plcol0()/plcol1(). I could imagine a Fortran subroutine plgcurcol(cmap, icol), where cmap and icol are the return values containing the current colour map and index.

The use of such a procedure is when writing a function/subroutine of my own that does some plotting using PLplot. My current example is a routine that draws a graph using both solid features (alpha=1) bars and semitransparent features. The alpha value needs to be changed inside the routine, and changed back to the original before returning, as not to mess up the PLplot settings after the routine returns. Part of that Fortran routine would look like

  ! Do some plotting in default transparency...

  call plgcurcol(cmap,icol)
  if(cmap.eq.0) then
    call plgcol0a(icol, red0,green0,blue0, alpha0)   ! Store original colour
    call plscol0a(icol, red0,green0,blue0, myalpha)  ! Set desired colour
  else 
    call plgcol1a(icol, red0,green0,blue0, alpha0)   ! Store original colour
    call plscol1a(icol, red0,green0,blue0, myalpha)  ! Set desired colour
  end if

  ! Do some plotting in my desired, temporary transparency...

  if(cmap.eq.0) then
    call plscol0a(icol, red0,green0,blue0, alpha0)  ! Restore original colour
  else 
    call plscol1a(icol, red0,green0,blue0, alpha0)  ! Restore original colour
  end if

To achieve a similar goal in different circumstances, I could imagine a routine plgcurrgba(r,g,b, a) to obtain the RGB colours and alpha channel instead of the colour map and index. However, I suppose one would still need a colour map and index to assign the modified colour to, and hence plgcurcol() to get the original map/index settings and later restore them.

PS, this is low priority, but I'm not sure whether that's 1 or 9...

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.