The .Opacity property is used to specify the opacity (or transparency) of an object in a Surfer script. You can set the opacity for shapes in layers, the layers themselves, and for other drawn objects. An example script demonstrating this process is provided below
To run this script:
- Copy the script below, or download the attached BAS file: Opacity.bas
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press DELETE.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
Sub Main Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True Dim Plot As Object Set Plot = SurferApp.Documents.Add 'Creates a filled image map, and sets the opacity of the missing data fill to 0% (completely transparent) Dim MapFrame1 As Object Set MapFrame1 = Plot.Shapes.AddImageMap(GridFileName:=SurferApp.Path+"\samples\goldenblank1.grd") Dim ImageLayer As Object Set ImageLayer = MapFrame1.Overlays(1) 'Sets opacity for the missing data in the image layer properties ImageLayer.MissingDataColorRGBA.Opacity=0 'Sets the opacity for the image layer iteself ImageLayer.Opacity = 50 'Creates a polygon and fills it with a semi-opaque fill Dim Coordinates(5) As Double Coordinates(0) = 4: Coordinates(1) = 4 Coordinates(2) = 8: Coordinates(3) = 1 Coordinates(4) = 5.5: Coordinates(5) = 0.5 Set Polygon = Plot.Shapes.AddPolygon(Coordinates) Polygon.Fill.Pattern = "Solid" Polygon.Fill.ForeColorRGBA.Color = srfColorBlue Polygon.Fill.ForeColorRGBA.Opacity = 50 End Sub
For more information, please see the Opacity Property page in the Help. The attached script, Opacity.bas, is also located in the \Samples\Scripts\ folder in the Surfer installation directory.
Updated October 2021
Please sign in to leave a comment.