vb中关于以下颜色代码?
PrivateSubCommand1_Click()DimjAsInteger,C1AsLong,C2AsLongDimcnnAsNewADODB.ConnectionD...
Private Sub Command1_Click()
Dim j As Integer, C1 As Long, C2 As Long
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\程序\mydata.mdb;Persist Security Info=False"
rs.Open "select * from files2", cnn, 3, 2
rs.MoveFirst
Picture1.Cls
Picture1.Scale (0, 0)-(300, 1900)
Picture1.DrawWidth = 2
For I = 1 To rs.RecordCount '记录从第一条至总条数
X = rs.Fields("温度1").Value
Y = rs.Fields("温度2").Value
Select Case X
Case 1350 To 1550
Picture1.PSet (35, -1 + I), RGB(255, (255 / 200) * (1550 - X), 0)
Case 1150 To 1350
Picture1.PSet (35, -1 + I), RGB((255 / 200) * (X - 1150), 255, 0)
Case 950 To 1150
Picture1.PSet (35, -1 + I), RGB(0, 255, (255 / 200) * (1150 - X))
Case 750 To 950
Picture1.PSet (35, -1 + I), RGB(0, (255 / 200) * (X - 750), 255)
End Select
Select Case Y
Case 1350 To 1550
Picture1.PSet (150, -1 + I), RGB(255, (255 / 200) * (1550 - Y), 0)
Case 1150 To 1350
Picture1.PSet (150, -1 + I), RGB((255 / 200) * (Y - 1150), 255, 0)
Case 950 To 1150
Picture1.PSet (150, -1 + I), RGB(0, 255, (255 / 200) * (1150 - Y))
Case 750 To 950
Picture1.PSet (150, -1 + I), RGB(0, (255 / 200) * (Y - 750), 255)
End Select
C1 = Picture1.Point(35, -1 + I)
C2 = Picture1.Point(150, -1 + I)
Picture1.Line (35, -1 + I)-(150, -1 + I), NewColor(C1, C2, j)
rs.MoveNext
Next I
Set rs = Nothing
Set cnn = Nothing
Function NewColor(Color1 As Long, Color2 As Long, I As Integer) As Long
Dim C1 As Long, C2 As Long, j As Integer
For j = 0 To 2
C1 = (Color1 And 255 * 256 ^ j) / 256 ^ j
C2 = (Color2 And 255 * 256 ^ j) / 256 ^ j
NewColor = NewColor Or (C1 + (C2 - C1) * I \ 100) * 256 ^ j
Next
End Function
End Sub
其中颜色不能从(35, -1 + I)-(150, -1 + I)过渡,不知道为何? 展开
Dim j As Integer, C1 As Long, C2 As Long
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\程序\mydata.mdb;Persist Security Info=False"
rs.Open "select * from files2", cnn, 3, 2
rs.MoveFirst
Picture1.Cls
Picture1.Scale (0, 0)-(300, 1900)
Picture1.DrawWidth = 2
For I = 1 To rs.RecordCount '记录从第一条至总条数
X = rs.Fields("温度1").Value
Y = rs.Fields("温度2").Value
Select Case X
Case 1350 To 1550
Picture1.PSet (35, -1 + I), RGB(255, (255 / 200) * (1550 - X), 0)
Case 1150 To 1350
Picture1.PSet (35, -1 + I), RGB((255 / 200) * (X - 1150), 255, 0)
Case 950 To 1150
Picture1.PSet (35, -1 + I), RGB(0, 255, (255 / 200) * (1150 - X))
Case 750 To 950
Picture1.PSet (35, -1 + I), RGB(0, (255 / 200) * (X - 750), 255)
End Select
Select Case Y
Case 1350 To 1550
Picture1.PSet (150, -1 + I), RGB(255, (255 / 200) * (1550 - Y), 0)
Case 1150 To 1350
Picture1.PSet (150, -1 + I), RGB((255 / 200) * (Y - 1150), 255, 0)
Case 950 To 1150
Picture1.PSet (150, -1 + I), RGB(0, 255, (255 / 200) * (1150 - Y))
Case 750 To 950
Picture1.PSet (150, -1 + I), RGB(0, (255 / 200) * (Y - 750), 255)
End Select
C1 = Picture1.Point(35, -1 + I)
C2 = Picture1.Point(150, -1 + I)
Picture1.Line (35, -1 + I)-(150, -1 + I), NewColor(C1, C2, j)
rs.MoveNext
Next I
Set rs = Nothing
Set cnn = Nothing
Function NewColor(Color1 As Long, Color2 As Long, I As Integer) As Long
Dim C1 As Long, C2 As Long, j As Integer
For j = 0 To 2
C1 = (Color1 And 255 * 256 ^ j) / 256 ^ j
C2 = (Color2 And 255 * 256 ^ j) / 256 ^ j
NewColor = NewColor Or (C1 + (C2 - C1) * I \ 100) * 256 ^ j
Next
End Function
End Sub
其中颜色不能从(35, -1 + I)-(150, -1 + I)过渡,不知道为何? 展开
1个回答
展开全部
颜色的过渡,不能直接用整体的RGB值来过渡,要看每一个RGB的值来综合起来过渡,这样才会有效果
看看下面的颜色过渡代码(注意是用函数来实现的)
Private Sub Form_Click()
Dim i As Integer, C1 As Long, C2 As Long
C1 = vbRed
C2 = vbBlue
Form1.DrawWidth = 10
For i = 1 To 100
Line -(i * 50, i * 50), NewColor(C1, C2, i)
Next
End Sub
Function NewColor(Color1 As Long, Color2 As Long, i As Integer) As Long
Dim C1 As Long, C2 As Long, j As Integer
For j = 0 To 2
C1 = (Color1 And 255 * 256 ^ j) / 256 ^ j
C2 = (Color2 And 255 * 256 ^ j) / 256 ^ j
NewColor = NewColor Or (C1 + (C2 - C1) * i \ 100) * 256 ^ j
Next
End Function
看看下面的颜色过渡代码(注意是用函数来实现的)
Private Sub Form_Click()
Dim i As Integer, C1 As Long, C2 As Long
C1 = vbRed
C2 = vbBlue
Form1.DrawWidth = 10
For i = 1 To 100
Line -(i * 50, i * 50), NewColor(C1, C2, i)
Next
End Sub
Function NewColor(Color1 As Long, Color2 As Long, i As Integer) As Long
Dim C1 As Long, C2 As Long, j As Integer
For j = 0 To 2
C1 = (Color1 And 255 * 256 ^ j) / 256 ^ j
C2 = (Color2 And 255 * 256 ^ j) / 256 ^ j
NewColor = NewColor Or (C1 + (C2 - C1) * i \ 100) * 256 ^ j
Next
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询