home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F40836_DrawCurveBezier.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-16  |  1.8 KB  |  50 lines

  1. Attribute VB_Name = "DrawCurveBezier"
  2. '******************************************************************'
  3. '*                                                                *'
  4. '*                      TurboCAD for Windows                      *'
  5. '*                   Copyright (c) 1993 - 2001                    *'
  6. '*             International Microcomputer Software, Inc.         *'
  7. '*                            (IMSI)                              *'
  8. '*                      All rights reserved.                      *'
  9. '*                                                                *'
  10. '******************************************************************'
  11.  
  12. ' Creates curve - Bezier and polygon from coordinates collection
  13. Public Sub BezierCurve()
  14. Dim App As Application
  15. Dim ActDr As Drawing
  16. Dim Grs As Graphics
  17. Dim GrBezier As Graphic
  18. Dim GrPolygon As Graphic
  19. Dim Ver As Vertex
  20.  
  21.     Set App = IMSIGX.Application
  22.     Set ActDr = App.ActiveDrawing
  23.     Set Grs = ActDr.Graphics
  24. Dim x#, y#
  25. Dim x0#, y0#, z0#
  26.     x0 = 1#
  27.     y0 = 5# + 2.5 * Sin(x0)
  28.     z0 = 0#
  29. ' add two graphics GrBezier and GrPolygon to the graphics collection
  30. ' coordinates x0,y0,z0 - defines initial point of the graphic
  31.     Set GrBezier = Grs.AddCurveBezier(x0, y0, z0)
  32.     Set GrPolygon = Grs.AddLineIrregularPolygon(x0, y0, 0)
  33. ' add other points as Vertices to the graphic
  34.     For x = 1 To 9 Step 1
  35.         y = 5 + 2.5 * Sin(x)
  36.         Set Ver = GrBezier.Vertices.Add(x, y, z0)
  37.         Set Ver = GrPolygon.Vertices.Add(x, y, z0)
  38.     Next x
  39. ' Changes some properties of the graphic
  40.     GrBezier.Properties("PenWidth") = 0.03
  41.     GrBezier.Properties("PenColor") = RGB(255, 0, 0)
  42.     GrBezier.Properties("PenStyle") = "Dashed"
  43.     GrBezier.Draw
  44.     
  45.     GrPolygon.Properties("PenWidth") = 0.03
  46.     GrPolygon.Properties("PenColor") = RGB(0, 255, 0)
  47.     GrPolygon.Draw
  48.  
  49. End Sub
  50.