home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch15 / axspiral / axspiral.dob (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  14.8 KB  |  498 lines

  1. VERSION 5.00
  2. Begin VB.UserDocument AXSpiral 
  3.    ClientHeight    =   6645
  4.    ClientLeft      =   2100
  5.    ClientTop       =   945
  6.    ClientWidth     =   7440
  7.    HScrollSmallChange=   15
  8.    PaletteMode     =   1  'UseZOrder
  9.    ScaleHeight     =   6645
  10.    ScaleWidth      =   7440
  11.    VScrollSmallChange=   15
  12.    Begin VB.Frame Frame1 
  13.       Caption         =   "Pen Width"
  14.       BeginProperty Font 
  15.          Name            =   "Times New Roman"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   1140
  24.       Left            =   5625
  25.       TabIndex        =   28
  26.       Top             =   5295
  27.       Width           =   1635
  28.       Begin VB.OptionButton WOption 
  29.          Height          =   195
  30.          Index           =   1
  31.          Left            =   150
  32.          Style           =   1  'Graphical
  33.          TabIndex        =   31
  34.          Top             =   300
  35.          Value           =   -1  'True
  36.          Width           =   210
  37.       End
  38.       Begin VB.OptionButton WOption 
  39.          Height          =   195
  40.          Index           =   2
  41.          Left            =   150
  42.          Style           =   1  'Graphical
  43.          TabIndex        =   30
  44.          Top             =   570
  45.          Width           =   210
  46.       End
  47.       Begin VB.OptionButton WOption 
  48.          Height          =   195
  49.          Index           =   3
  50.          Left            =   150
  51.          Style           =   1  'Graphical
  52.          TabIndex        =   29
  53.          Top             =   840
  54.          Width           =   225
  55.       End
  56.       Begin VB.Line Line1 
  57.          X1              =   540
  58.          X2              =   1455
  59.          Y1              =   390
  60.          Y2              =   390
  61.       End
  62.       Begin VB.Line Line2 
  63.          BorderWidth     =   2
  64.          X1              =   1455
  65.          X2              =   540
  66.          Y1              =   660
  67.          Y2              =   675
  68.       End
  69.       Begin VB.Line Line3 
  70.          BorderWidth     =   3
  71.          X1              =   1425
  72.          X2              =   540
  73.          Y1              =   930
  74.          Y2              =   930
  75.       End
  76.    End
  77.    Begin VB.PictureBox CPicture 
  78.       BackColor       =   &H000000FF&
  79.       Height          =   225
  80.       Index           =   0
  81.       Left            =   6000
  82.       ScaleHeight     =   165
  83.       ScaleWidth      =   1080
  84.       TabIndex        =   27
  85.       Top             =   1590
  86.       Width           =   1140
  87.    End
  88.    Begin VB.OptionButton Option 
  89.       Height          =   255
  90.       Index           =   0
  91.       Left            =   5745
  92.       Style           =   1  'Graphical
  93.       TabIndex        =   26
  94.       Top             =   1575
  95.       Width           =   225
  96.    End
  97.    Begin VB.PictureBox CPicture 
  98.       BackColor       =   &H000000C0&
  99.       Height          =   225
  100.       Index           =   1
  101.       Left            =   6000
  102.       ScaleHeight     =   165
  103.       ScaleWidth      =   1080
  104.       TabIndex        =   25
  105.       Top             =   1995
  106.       Width           =   1140
  107.    End
  108.    Begin VB.OptionButton Option 
  109.       Height          =   255
  110.       Index           =   1
  111.       Left            =   5745
  112.       Style           =   1  'Graphical
  113.       TabIndex        =   24
  114.       Top             =   1935
  115.       Width           =   225
  116.    End
  117.    Begin VB.PictureBox CPicture 
  118.       BackColor       =   &H0000FFFF&
  119.       Height          =   225
  120.       Index           =   2
  121.       Left            =   6000
  122.       ScaleHeight     =   165
  123.       ScaleWidth      =   1080
  124.       TabIndex        =   23
  125.       Top             =   2385
  126.       Width           =   1140
  127.    End
  128.    Begin VB.OptionButton Option 
  129.       Height          =   255
  130.       Index           =   2
  131.       Left            =   5745
  132.       Style           =   1  'Graphical
  133.       TabIndex        =   22
  134.       Top             =   2370
  135.       Width           =   225
  136.    End
  137.    Begin VB.PictureBox CPicture 
  138.       BackColor       =   &H0000FF00&
  139.       Height          =   225
  140.       Index           =   3
  141.       Left            =   6000
  142.       ScaleHeight     =   165
  143.       ScaleWidth      =   1080
  144.       TabIndex        =   21
  145.       Top             =   2790
  146.       Width           =   1140
  147.    End
  148.    Begin VB.OptionButton Option 
  149.       Height          =   255
  150.       Index           =   3
  151.       Left            =   5745
  152.       Style           =   1  'Graphical
  153.       TabIndex        =   20
  154.       Top             =   2775
  155.       Width           =   225
  156.    End
  157.    Begin VB.PictureBox CPicture 
  158.       BackColor       =   &H00FFFF00&
  159.       Height          =   225
  160.       Index           =   4
  161.       Left            =   6000
  162.       ScaleHeight     =   165
  163.       ScaleWidth      =   1080
  164.       TabIndex        =   19
  165.       Top             =   3180
  166.       Width           =   1140
  167.    End
  168.    Begin VB.OptionButton Option 
  169.       Height          =   255
  170.       Index           =   4
  171.       Left            =   5745
  172.       Style           =   1  'Graphical
  173.       TabIndex        =   18
  174.       Top             =   3165
  175.       Width           =   225
  176.    End
  177.    Begin VB.PictureBox CPicture 
  178.       BackColor       =   &H00FF0000&
  179.       Height          =   225
  180.       Index           =   5
  181.       Left            =   6000
  182.       ScaleHeight     =   165
  183.       ScaleWidth      =   1080
  184.       TabIndex        =   17
  185.       Top             =   3585
  186.       Width           =   1140
  187.    End
  188.    Begin VB.OptionButton Option 
  189.       Height          =   255
  190.       Index           =   5
  191.       Left            =   5745
  192.       Style           =   1  'Graphical
  193.       TabIndex        =   16
  194.       Top             =   3570
  195.       Width           =   225
  196.    End
  197.    Begin VB.PictureBox CPicture 
  198.       BackColor       =   &H00FF00FF&
  199.       Height          =   225
  200.       Index           =   6
  201.       Left            =   6015
  202.       ScaleHeight     =   165
  203.       ScaleWidth      =   1080
  204.       TabIndex        =   15
  205.       Top             =   3990
  206.       Width           =   1140
  207.    End
  208.    Begin VB.OptionButton Option 
  209.       Height          =   255
  210.       Index           =   6
  211.       Left            =   5745
  212.       Style           =   1  'Graphical
  213.       TabIndex        =   14
  214.       Top             =   3975
  215.       Width           =   225
  216.    End
  217.    Begin VB.PictureBox CPicture 
  218.       BackColor       =   &H00000000&
  219.       Height          =   225
  220.       Index           =   7
  221.       Left            =   6030
  222.       ScaleHeight     =   165
  223.       ScaleWidth      =   1080
  224.       TabIndex        =   13
  225.       Top             =   4380
  226.       Width           =   1140
  227.    End
  228.    Begin VB.OptionButton Option 
  229.       Height          =   255
  230.       Index           =   7
  231.       Left            =   5745
  232.       Style           =   1  'Graphical
  233.       TabIndex        =   12
  234.       Top             =   4365
  235.       Value           =   -1  'True
  236.       Width           =   225
  237.    End
  238.    Begin VB.PictureBox CPicture 
  239.       BackColor       =   &H00FFFFFF&
  240.       Height          =   225
  241.       Index           =   8
  242.       Left            =   6015
  243.       ScaleHeight     =   165
  244.       ScaleWidth      =   1080
  245.       TabIndex        =   11
  246.       Top             =   4785
  247.       Width           =   1140
  248.    End
  249.    Begin VB.OptionButton Option 
  250.       Height          =   255
  251.       Index           =   8
  252.       Left            =   5745
  253.       Style           =   1  'Graphical
  254.       TabIndex        =   10
  255.       Top             =   4770
  256.       Width           =   225
  257.    End
  258.    Begin VB.HScrollBar HScroll4 
  259.       Height          =   210
  260.       LargeChange     =   10
  261.       Left            =   2070
  262.       Max             =   40
  263.       TabIndex        =   9
  264.       Top             =   6255
  265.       Width           =   3345
  266.    End
  267.    Begin VB.CommandButton Command2 
  268.       Caption         =   "Clear Graph"
  269.       BeginProperty Font 
  270.          Name            =   "Times New Roman"
  271.          Size            =   12
  272.          Charset         =   0
  273.          Weight          =   400
  274.          Underline       =   0   'False
  275.          Italic          =   0   'False
  276.          Strikethrough   =   0   'False
  277.       EndProperty
  278.       Height          =   405
  279.       Left            =   5655
  280.       TabIndex        =   7
  281.       Top             =   675
  282.       Width           =   1575
  283.    End
  284.    Begin VB.HScrollBar HScroll3 
  285.       Height          =   240
  286.       Left            =   255
  287.       Max             =   20
  288.       Min             =   10
  289.       MousePointer    =   1  'Arrow
  290.       TabIndex        =   4
  291.       Top             =   8760
  292.       Value           =   20
  293.       Width           =   6210
  294.    End
  295.    Begin VB.HScrollBar HScroll2 
  296.       Height          =   210
  297.       LargeChange     =   10
  298.       Left            =   2070
  299.       Max             =   150
  300.       MousePointer    =   1  'Arrow
  301.       SmallChange     =   10
  302.       TabIndex        =   3
  303.       Top             =   5955
  304.       Value           =   100
  305.       Width           =   3345
  306.    End
  307.    Begin VB.HScrollBar HScroll1 
  308.       Height          =   210
  309.       LargeChange     =   10
  310.       Left            =   2070
  311.       Max             =   150
  312.       Min             =   50
  313.       SmallChange     =   10
  314.       TabIndex        =   2
  315.       Top             =   5625
  316.       Value           =   110
  317.       Width           =   3345
  318.    End
  319.    Begin VB.CommandButton Command1 
  320.       Caption         =   "Start"
  321.       BeginProperty Font 
  322.          Name            =   "Times New Roman"
  323.          Size            =   12
  324.          Charset         =   0
  325.          Weight          =   400
  326.          Underline       =   0   'False
  327.          Italic          =   0   'False
  328.          Strikethrough   =   0   'False
  329.       EndProperty
  330.       Height          =   405
  331.       Left            =   5655
  332.       TabIndex        =   1
  333.       Top             =   120
  334.       Width           =   1575
  335.    End
  336.    Begin VB.PictureBox Picture1 
  337.       BackColor       =   &H00808080&
  338.       FillStyle       =   0  'Solid
  339.       ForeColor       =   &H000000FF&
  340.       Height          =   5310
  341.       Left            =   100
  342.       ScaleHeight     =   350
  343.       ScaleMode       =   3  'Pixel
  344.       ScaleWidth      =   350
  345.       TabIndex        =   0
  346.       Top             =   135
  347.       Width           =   5310
  348.    End
  349.    Begin VB.Frame Frame2 
  350.       Caption         =   "Pen Color"
  351.       BeginProperty Font 
  352.          Name            =   "Times New Roman"
  353.          Size            =   9.75
  354.          Charset         =   0
  355.          Weight          =   400
  356.          Underline       =   0   'False
  357.          Italic          =   0   'False
  358.          Strikethrough   =   0   'False
  359.       EndProperty
  360.       Height          =   3960
  361.       Left            =   5610
  362.       TabIndex        =   32
  363.       Top             =   1200
  364.       Width           =   1620
  365.    End
  366.    Begin VB.Label Label3 
  367.       Caption         =   "Inner Offset"
  368.       BeginProperty Font 
  369.          Name            =   "Times New Roman"
  370.          Size            =   9.75
  371.          Charset         =   0
  372.          Weight          =   400
  373.          Underline       =   0   'False
  374.          Italic          =   0   'False
  375.          Strikethrough   =   0   'False
  376.       EndProperty
  377.       Height          =   225
  378.       Left            =   195
  379.       TabIndex        =   8
  380.       Top             =   6255
  381.       Width           =   1755
  382.    End
  383.    Begin VB.Label Label2 
  384.       Caption         =   "Inner Radius"
  385.       BeginProperty Font 
  386.          Name            =   "Times New Roman"
  387.          Size            =   9.75
  388.          Charset         =   0
  389.          Weight          =   400
  390.          Underline       =   0   'False
  391.          Italic          =   0   'False
  392.          Strikethrough   =   0   'False
  393.       EndProperty
  394.       Height          =   270
  395.       Left            =   195
  396.       TabIndex        =   6
  397.       Top             =   5925
  398.       Width           =   1785
  399.    End
  400.    Begin VB.Label Label1 
  401.       Caption         =   "Outer Radius"
  402.       BeginProperty Font 
  403.          Name            =   "Times New Roman"
  404.          Size            =   9.75
  405.          Charset         =   0
  406.          Weight          =   400
  407.          Underline       =   0   'False
  408.          Italic          =   0   'False
  409.          Strikethrough   =   0   'False
  410.       EndProperty
  411.       Height          =   270
  412.       Left            =   195
  413.       TabIndex        =   5
  414.       Top             =   5595
  415.       Width           =   1785
  416.    End
  417. Attribute VB_Name = "AXSpiral"
  418. Attribute VB_GlobalNameSpace = False
  419. Attribute VB_Creatable = True
  420. Attribute VB_PredeclaredId = False
  421. Attribute VB_Exposed = True
  422. Dim BreakNow As Integer
  423. Dim PenColor As Long
  424. Sub DrawRoullette()
  425. Dim R1, R2, r, pi
  426. R1 = HScroll1.Value
  427. R2 = HScroll2.Value - 80
  428. If R2 = o Then R2 = 10
  429. r = HScroll4.Value
  430. pi = 4 * Atn(1)
  431. Dim loop1, loop2
  432. Dim t, X, Y As Double
  433. Dim Rotations As Integer
  434. If Int(R1 / R2) = R1 / R2 Then
  435.     Rotations = 1
  436.     Rotations = Abs(R2 / 10)
  437.     If Int(R2 / 10) <> R2 / 10 Then Rotations = 10 * Rotations
  438. End If
  439. For loop1 = 1 To Rotations
  440.     If BreakNow Then
  441.         Command1.Caption = "Start"
  442.         BreakNow = False
  443.         Exit Sub
  444.     End If
  445.     For loop2 = 0 To 2 * pi Step pi / (4 * 360)
  446.         t = loop1 * 2 * pi + loop2
  447.         X = (R1 + R2) * Cos(t) - (R2 + r) * Cos(((R1 + R2) / R2) * t)
  448.         Y = (R1 + R2) * Sin(t) - (R2 + r) * Sin(((R1 + R2) / R2) * t)
  449.         Picture1.PSet (Picture1.ScaleWidth / 2 + X, Picture1.ScaleHeight / 2 + Y), PenColor
  450.     Next
  451.     DoEvents
  452. Command1.Caption = "Start"
  453. BreakNow = False
  454. End Sub
  455. Private Sub UserDocument_Initialize()
  456.     Call Form_Load
  457. End Sub
  458. Private Sub Command1_Click()
  459. If Command1.Caption = "Stop" Then
  460.     BreakNow = True
  461.     Exit Sub
  462.     BreakNow = False
  463.     Command1.Caption = "Stop"
  464. End If
  465. DrawRoullette
  466. End Sub
  467. Private Sub Command2_Click()
  468.     UserDocument.Picture1.Cls
  469. End Sub
  470. Private Sub Form_Load()
  471.     PenColor = RGB(0, 0, 0)
  472.     HScroll1_Change
  473.     HScroll2_Change
  474.     HScroll4_Change
  475. End Sub
  476. Private Sub HScroll1_Change()
  477.     Label1.Caption = "Outer Radius  " & HScroll1.Value
  478. End Sub
  479. Private Sub HScroll1_Scroll()
  480.     Label1.Caption = "Outer Radius  " & HScroll1.Value
  481. End Sub
  482. Private Sub HScroll2_Change()
  483.     Label2.Caption = "Inner Radius   " & HScroll2.Value - 80
  484.         
  485. End Sub
  486. Private Sub HScroll2_Scroll()
  487.     Label2.Caption = "Inner Radius   " & HScroll2.Value - 80
  488. End Sub
  489. Private Sub HScroll4_Change()
  490.     Label3.Caption = "Inner Offset     " & HScroll4.Value
  491. End Sub
  492. Private Sub Option_Click(Index As Integer)
  493.     PenColor = CPicture(Index).BackColor
  494. End Sub
  495. Private Sub WOption_Click(Index As Integer)
  496.     Picture1.DrawWidth = Index
  497. End Sub
  498.