|
-
Feb 23rd, 2002, 10:46 AM
#11
Fanatic Member
Well, the gradient fill seems to be complicated, how about this?
Put a picturebox in a form, set it's Autoredraw property to
True
VB Code:
Private Sub Picture1_Click()
Dim FR, FG, FB, LR, LG, LB
Dim SR, SG, SB
'Any value between 0 and 255 will do for these variables
'They determine ur first color and last color
FR = 255: FG = 0: FB = 255
LR = 0: LG = 255: LB = 0
With Picture1
SR = (LR - FR) / .Width
SG = (LG - FG) / .Width
SB = (LB - FB) / .Width
For X = 0 To .Width
.Line (X,0) - (X, .Height), RGB(FR, FG, FB)
FR = FR + SR: FG = FG + SG: FB = FB + SB
Next
End With
End Sub
Now, this would be too slow, How about this?
This is a few thousand times faster...
VB Code:
Prinvate Sub Picture1_Click()
Dim FR, FG, FB, LR, LG, LB, PCol, Col, PX
'Any value between 0 and 255 will do for these variables
'They determine ur first color and last color
FR = 255: FG = 0: FB = 255
LR = 0: LG = 255: LB = 0
PCol = RGB(FR, FG, FB): PX = 0
With Picture1
SR = (LR - FR) / .Width
SG = (LG - FG) / .Width
SB = (LB - FB) / .Width
Do Until X >= .Width
Col = RGB(FR, FG, FB)
If PCol <> Col Then
.Line (PX, 0) - (X, .Height), PCol, BF
PCol = Col
PX = X
End If
X = X + 1
FR = FR + SR: FG = FG + SG: FB = FB + SB
Loop
End With
End Sub
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|