'========================================================================== 'CONTOURFILL.BAS ' 'This script demonstrates the following: ' ' How to create a contour map ' How to fill the contour intervals with CLR file ' How to fill a single contour interval with a specific color ' How to apply a custom gradational colormap to a contour map '========================================================================== Sub Main Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True Path = SurferApp.Path + "\samples\" Dim Plot As Object Set Plot = SurferApp.Documents.Add Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd") Set ContourLayer = MapFrame.Overlays(1) ContourLayer.FillContours = True 'Fills the contours with colors from a preset CLR file ContourLayer.FillForegroundColorMap.LoadPreset("Rainbow") ContourLayer.ApplyFillToLevels(1, 1, 0) 'Change a specific contour interval to Magenta Set Levels = ContourLayer.Levels Levels(8).Fill.ForeColorRGBA.Color = srfColorMagenta 'Move first map to lower left MapFrame.Selected = True Plot.Selection.Left = 1.0 Plot.Selection.Top = 4.0 'Deselect All Plot.Selection.DeselectAll 'Create a second contour map and fill contours Set MapFrame2 = Plot.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd") Set ContourLayer2 = MapFrame2.Overlays(1) ContourLayer2.FillContours = True 'Set the colors to be gradational from blue to white Set Levels2 = ContourLayer2.Levels m = Levels2.Count ColorInc2 = 255.0 / (m-1) For j=1 To m ColorInc2 = 255.0 * (j-1) / (m-1) Levels2(j).Fill.ForeColorRGBA.Color = RGB(ColorInc2,ColorInc2,255) Next j 'Move second map to upper right MapFrame2.Selected = True Plot.Selection.Left = 4.5 Plot.Selection.Top = 10.0 'Turn on screen updating to view maps Plot.Windows(1).Zoom(srfGridZoomFitToWindow) End Sub