; docformat = 'rst' ;+ ; This is an example program to demonstrate how to create plot with multiple transparent images ; with Coyote Graphics routines. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "multi_transparent_images.pro" and run it like this:: ; IDL> .RUN multi_transparent_images ; ; :Author: ; FANNING SOFTWARE CONSULTING:: ; David W. Fanning ; 1645 Sheely Drive ; Fort Collins, CO 80526 USA ; Phone: 970-221-0438 ; E-mail: david@idlcoyote.com ; Coyote's Guide to IDL Programming: http://www.idlcoyote.com ; ; :History: ; Change History:: ; Written, 6 February 2013 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2013, Fanning Software Consulting, Inc. ;- PRO Multi_Transparent_Images ; Set up the display window. cgDisplay, 600, 500 pos = cgLayout([2,2], XGap=5, YGap=2.5, OXMargin=[6,6], OYMargin=[3, 7], Aspect=3./4) ; Multiple images will be drawn in the Z buffer if we are creating a PostScript file. IF !D.Name EQ 'PS' THEN BEGIN thisDevice = !D.Name Set_Plot, 'Z' Device, Set_Resolution=[600,500], Decomposed=1, Set_Pixel_Depth=24 cgErase ENDIF ; First image. cgImage, cgDemoData(7), position = pos[*,0], CTIndex=0 cgImage, cgDemoData(5), alphaFGPosition=pos[*,0], CTIndex=33, Transparent=80, Missing_Value=0 ; Second image. cgImage, cgDemoData(7), position = pos[*,1], CTIndex=5, /Brewer, /Noerase cgImage, cgDemoData(5), alphaFGPosition=pos[*,1], CTIndex=5, Transparent=60, Missing_Value=0 ; Third image. cgImage, cgDemoData(7), position = pos[*,2], CTIndex=8, /Brewer, /Noerase cgImage, cgDemoData(5), alphaFGPosition=pos[*,2], CTIndex=8, Transparent=40, Missing_Value=0 ; Fourth image. cgImage, cgDemoData(7), position = pos[*,3], CTIndex=3, /Brewer, /Noerase cgImage, cgDemoData(5), alphaFGPosition=pos[*,3], CTIndex=2, Transparent=20, Missing_Value=0 ; Take a snapshot for display in PostScript IF !D.Name EQ 'Z' THEN BEGIN snapshot = cgSnapshot() Set_Plot, thisDevice cgImage, snapshot ENDIF ; Add a title. font = (!D.Name EQ 'PS') ? 1 : 0 ytop = (pos[*,1])[2] ypos = (ytop + 0.075) < 0.95 cgText, 0.5, ypos, /Normal, 'Multi-Transparent Images', Font=font, $ Charsize=cgDefCharsize()*1.25, Alignment=0.5 ; Add plot annotations. cgPlot, [1], Position=pos[*,0], /NoData, /NoErase, Label='80% Transparent', $ XTickformat='(A1)', YTickFormat='(A1)' cgPlot, [1], Position=pos[*,1], /NoData, /NoErase, Label='60% Transparent', $ XTickformat='(A1)', YTickFormat='(A1)' cgPlot, [1], Position=pos[*,2], /NoData, /NoErase, Label='40% Transparent', $ XTickformat='(A1)', YTickFormat='(A1)' cgPlot, [1], Position=pos[*,3], /NoData, /NoErase, Label='20% Transparent', $ XTickformat='(A1)', YTickFormat='(A1)' END ;----------------------------------------------------------------------------- ; To display in a graphics window. Multi_Transparent_Images ; To display in a resizeable graphics window. cgWindow, 'Multi_Transparent_Images', WBackground='white', $ WXSize=600, WYSize=500 ; To create a PostScript file. cgPS_Open, 'multi_transparent_images.ps' Multi_Transparent_Images cgPS_Close ; To create a PNG file. cgPS2Raster, 'multi_transparent_images.ps', /PNG END