comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: polyfill with transparent colors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: polyfill with transparent colors [message #60798 is a reply to message #60795] Fri, 13 June 2008 12:18 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
cgoethel@igpp.ucla.edu writes:

> I have a linear plot that I would like to draw a polygon on top of,
> but still be able to see the underlying plot. Currently, the polygon
> is drawn on top of the existing plot, but the color is not transparent
> so you cannot see the data that is below the polygon. I cannot draw
> the polygon first and then redraw the plot using oplot (the routine to
> draw the plot is not mine, complex, so can't be modified to use oplot
> rather than plot). Any suggestions?

Roll your own alpha channel image. Here is an example
of how you can do it. You will need a couple of Coyote
Library programs to run the code:

http://www.dfanning.com/programs/coyoteprograms.zip

Cheers,

David

;----------------------------------------------------------- -------
PRO Transparent_Polygon

; Create some data.
signal = LoadData(1)
time = Findgen(N_Elements(signal)) * 6.0 / N_Elements(signal)

; Create some windows.
Window, Title='Data Window', XSIZE=400, YSIZE=400, /FREE
dataWin = !D.Window
Window, XSIZE=400, YSIZE=400, /FREE, /PIXMAP
pixmapWin = !D.Window

; Draw plot in data window.
WSet, dataWin
Plot, time, signal, BACKGROUND=FSC_Color('ivory'), $
COLOR=FSC_Color('navy'), $
/NODATA, XTitle='Time', YTitle='Signal Strength'
OPLOT, time, signal, THICK=2, COLOR=FSC_Color('cornflower blue')
OPLOT, time, signal, PSYM=2, COLOR=FSC_Color('olive')

; Take a snapshot.
win1 = TVREAD(TRUE=3)

; Copy data window and draw a polygon in the pixmap window.
WSet, pixmapWin
DEVICE, COPY=[0,0,400, 400, 0, 0, dataWin]
POLYFILL, [0.3, 0.65, 0.5, 0.25, 0.30], $
[0.27, 0.32, 0.75, 0.62, 0.27], /NORMAL, $
COLOR=FSC_COLOR('deep pink')

; Take a snapshot of this window, then delete it.
win2 = TVREAD(TRUE=3)
WDelete, pixmapWin

; Use a half-transparent alpha.
alpha = 0.5
Window, Title='Transparent Window', XSIZE=400, YSIZE=400, /FREE
TV, (win2 * alpha) + (1 - alpha) * win1, TRUE=3

END
;----------------------------------------------------------- -------

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to make the figure change automatically while I selected a new color table?
Next Topic: The problem about the '.RESET_SESSION' command

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 10:47:21 PDT 2025

Total time taken to generate the page: 1.43933 seconds