- 积分
- 641
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-5-15
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2017-4-13 12:53:20
|
显示全部楼层
- Sub Main
- '源代码来自Surfer13自带样本库,老鹰进行了中文标注。边译边学,毗漏难免,欢迎交流指正。
- '设置Surfer程序为创建对象。声明文档为对象。设置Surfer程序可见。
- Dim SurferApp As Object
- Set SurferApp = CreateObject("Surfer.Application")
- SurferApp.Visible = True
- '声明场景为对象。新建场景文件。
- Dim Plot As Object
- Set Plot = SurferApp.Documents.Add
- '声明文本为对象。
- Dim Text As Object
- '创建文本1"This is my text",坐标(0.5,3)。字号18,加粗,字体"Italic"。
- Set Text1 = Plot.Shapes.AddText(x:=0.5, y:=3, Text:="This is my text")
- Text1.Font.Size = 18
- Text1.Font.Bold = True
- Text1.Font.Italic = True
- '创建文本2"This is my text"回车符与换行符连接在一起"This is my text on the second line",坐标(2,0.5)。
- '文本水平居中,垂直居中。字号16。(Green)绿色。
- Set Text2 = Plot.Shapes.AddText(x:=2, y:=0.5, Text:="This is my text"& vbCrLf & "This is my text on the second line")
- Text2.Font.HAlign = srfTACenter
- Text2.Font.VAlign = srfTAVCenter
- Text2.Font.Size=16
- Text2.Font.ForeColorRGBA.Color=srfColorGreen
- '声明符号为对象。创建符号,坐标(2,2),第12号符,大小0.4,填充(Magenta)品红,线框(Magenta)品红。
- Dim Symbol As Object
- Set Symbol = Plot.Shapes.AddSymbol(x:=2, y:=2)
- Symbol.Marker.Index = 12
- Symbol.Marker.Size = 0.4
- Symbol.Marker.FillColorRGBA.Color=srfColorMagenta
- Symbol.Marker.LineColorRGBA.Color = srfColorMagenta
- '创建矩形,四边坐标(0.5,7.5,1.5,10.5)。线框(Purple)紫色,线宽0.015。
- '纯色填充,背景(LightYellow)浅黄,前景(Green)绿。
- Set Rectangle=Plot.Shapes.AddRectangle(Left:=0.5, Bottom:=7.5, Right:=1.5, Top:=10.5)
- Rectangle.Line.ForeColorRGBA.Color=srfColorPurple
- Rectangle.Line.Width = 0.015
- Rectangle.Fill.Pattern="Solid"
- Rectangle.Fill.BackColorRGBA.Color = srfColorLightYellow
- Rectangle.Fill.ForeColorRGBA.Color = srfColorGreen
- '创建圆角矩形。四边坐标(7,9,8,10.5),圆角X半径0.3,Y半径0.3。
- '线框(Magenta)品红,线宽0.03。填充图案(Swamp)沼泽,(Green)绿色。
- Set RoundedRectangle = Plot.Shapes.AddRectangle(Left:=7, Bottom:=9, Right:=8, Top:=10.5, xRadius:=0.3, yRadius:=0.3)
- RoundedRectangle.Line.ForeColorRGBA.Color = srfColorMagenta
- RoundedRectangle.Line.Width = 0.03
- RoundedRectangle.Fill.Pattern = "Swamp"
- RoundedRectangle.Fill.ForeColorRGBA.Color = srfColorForestGreen
- '创建椭圆,四至坐标(6.5,5.5,8,8),填充(Solid)纯色,(Blue)蓝色。
- Set Ellipse = Plot.Shapes.AddEllipse(Left:=6.5, Bottom:=5.5, Right:=8, Top:=8)
- Ellipse.Fill.Pattern = "Solid"
- Ellipse.Fill.ForeColorRGBA.Color = srfColorBlue
- '创建单段线,起点(2,8.5),终点(3.5,10.5)。紫色,线宽0.04,连续线段。
- Set Polyline = Plot.Shapes.AddLine(xBeg:=2, yBeg:=8.5, xEnd:=3.5, yEnd:=10.5)
- Polyline.Line.ForeColorRGBA.Color = srfColorPurple
- Polyline.Line.Width = 0.04
- Polyline.Line.Style = "Solid"
- '声明多段线拐点坐标组为双精度数值。坐标(4,10.5)(6.5,10)(5,9)(6,8.5)。
- Dim PolyLineArray(7) As Double
- PolyLineArray(0) = 4: PolyLineArray(1) = 10.5
- PolyLineArray(2) = 6.5: PolyLineArray(3) = 10
- PolyLineArray(4) = 5: PolyLineArray(5) = 9
- PolyLineArray(6) = 6: PolyLineArray(7) = 8.5
- '创建贝叶斯曲线,红色,0.03,连续线段。
- Set Spline = Plot.Shapes.AddPolyLine2(PolyLineArray, srfPTBezier)
- Spline.Line.ForeColorRGBA.Color = srfColorRed
- Spline.Line.Width = 0.03
- Spline.Line.Style = "Solid"
- '声明曲线顶点坐标为双精度数值。
- Dim Vertices() As Double
- Vertices() = Spline.Vertices
- '创建多段线,蓝色。声明多段线顶点坐标为双精度数值。
- Set PolyLine = Plot.Shapes.AddPolyLine2(PolyLineArray, srfPTPolyline)
- PolyLine.Line.ForeColorRGBA.Color = srfColorBlue
- Dim Vertices2() As Double
- Vertices2() = PolyLine.Vertices
- '声明坐标数组为双精度数值。(4,4)(8,1)(5.5,0.5)。
- 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
- '根据上述坐标创立多边形。现框(Blue)蓝色,线宽0.05。纯色填充,透明,(Orange)橘黄。
- Set Polygon = Plot.Shapes.AddPolygon(Coordinates)
- Polygon.Line.ForeColorRGBA.Color = srfColorBlue
- Polygon.Line.Width = 0.05
- Polygon.Fill.Pattern = "Solid"
- Polygon.Fill.Transparent = True
- Polygon.Fill.ForeColorRGBA.Color = srfColorOrange
- '声明多边形顶点坐标为双精度数值。12个拐点坐标如下。
- Dim PgonCoordinates(23) As Double
- PgonCoordinates(0) = 3.44: PgonCoordinates(1) = 4.06
- PgonCoordinates(2) = 1.10: PgonCoordinates(3) = 6.39
- PgonCoordinates(4) = 3.44: PgonCoordinates(5) = 8.73
- PgonCoordinates(6) = 5.75: PgonCoordinates(7) = 6.39
- PgonCoordinates(8) = 3.36: PgonCoordinates(9) = 8.07
- PgonCoordinates(10) = 5.01: PgonCoordinates(11) = 6.42
- PgonCoordinates(12) = 3.36: PgonCoordinates(13) = 4.75
- PgonCoordinates(14) = 1.71: PgonCoordinates(15) = 6.42
- PgonCoordinates(16) = 1.71: PgonCoordinates(17) = 8.07
- PgonCoordinates(18) = 5.01: PgonCoordinates(19) = 8.07
- PgonCoordinates(20) = 5.01: PgonCoordinates(21) = 4.75
- PgonCoordinates(22) = 1.71: PgonCoordinates(23) = 4.75
- '多边形0由前面四点坐标构成,多边形1由中间四点坐标构成,多边形2由最后四点坐标构成。
- Dim NumPolygons(2) As Long
- NumPolygons(0) = 4
- NumPolygons(1) = 4
- NumPolygons(2) = 4
- '设置组合多边形(顶点坐标=PgonCoordinates,多边形计数=NumPolygons)。
- '(Brown)棕线,线宽0.05,纯色填充。
- Set ComplexPolygon = Plot.Shapes.AddComplexPolygon(Vertices:=PgonCoordinates, PolyCounts:=NumPolygons)
- ComplexPolygon.Line.ForeColorRGBA.Color = srfColorBrown
- ComplexPolygon.Line.Width = 0.05
- ComplexPolygon.Fill.Pattern="Solid"
- '创建组合对象。显示"Composite Object"。
- '文本2,坐标(6.25,3.75),内容"Composite Object"。
- '创建矩形,四边坐标(6,3.25,8,4.25)。
- '两者选中,组合。
- Debug.Print "Composite Object"
- Set Text2 = Plot.Shapes.AddText(x:=6.25, y:=3.75, Text:="Composite Object")
- Set Rectangle2=Plot.Shapes.AddRectangle(Left:=6, Bottom:=3.25, Right:=8, Top:=4.25)
- Text2.Select
- Rectangle2.Select
- Set Composite = Plot.Selection.Combine
- '打散组合。
- Composite.BreakApart
- End Sub
复制代码
|
|