home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Advanced S22185742001.psc / mdTest.bas < prev    next >
Encoding:
BASIC Source File  |  2001-06-28  |  1.8 KB  |  57 lines

  1. Attribute VB_Name = "mdTest"
  2. ' mdTest
  3. ' This module contains some declarations, types, and functions
  4. ' used in other parts of the project.
  5.  
  6. Option Explicit
  7.  
  8. Type PointAPI
  9.     X As Double
  10.     Y As Double
  11. End Type
  12.  
  13. ' This variable stores information on the selected shape window.
  14. Public SelWindow As frmTest
  15.  
  16. '------------------------------------------------------
  17. ' Used in color functions. Contains R, G, and B values
  18. ' for a color.
  19. '------------------------------------------------------
  20. Type cColor
  21.     R As Integer
  22.     G As Integer
  23.     B As Integer
  24. End Type
  25.  
  26. Public Function SetPnt(X As Double, Y As Double) As PointAPI
  27.     ' Allow PointAPI data change in one command
  28.     With SetPnt
  29.         .X = X
  30.         .Y = Y
  31.     End With
  32. End Function
  33.  
  34. '--------------------------------------------------
  35. ' Color Function, converts a long color value into
  36. ' a cColor Type
  37. ' -------------------------------------------------
  38. Public Function ColorRGB(ByVal LongColor As Long) As cColor
  39.     ColorRGB.R = LongColor Mod 256
  40.     ColorRGB.G = (LongColor And &HFF00FF00) / 256
  41.     ColorRGB.B = (LongColor And &HFF0000) / 256 ^ 2
  42. End Function
  43.  
  44. '-------------------------------------------------
  45. ' Color Function, finds a color value Fraction *
  46. ' the distance between two colors.
  47. '-------------------------------------------------
  48. Public Function ColorBetween(StartCol As Long, EndCol As Long, Fraction As Currency) As Long
  49. Dim ResultColor As cColor, Col1 As cColor, Col2 As cColor
  50.     Col1 = ColorRGB(StartCol)
  51.     Col2 = ColorRGB(EndCol)
  52.     ResultColor.R = Fraction * (Col1.R - Col2.R) + Col2.R
  53.     ResultColor.G = Fraction * (Col1.G - Col2.G) + Col2.G
  54.     ResultColor.B = Fraction * (Col1.B - Col2.B) + Col2.B
  55.     ColorBetween = RGB(ResultColor.R, ResultColor.G, ResultColor.B)
  56. End Function
  57.