Rippin
December 16th, 1999, 08:51 PM
Does anyone know how to fill a form (or a picture box) with a gradient? Any help would be appreciated?
Thanks.
Thanks.
|
Click to See Complete Forum and Search --> : Gradient fill? Rippin December 16th, 1999, 08:51 PM Does anyone know how to fill a form (or a picture box) with a gradient? Any help would be appreciated? Thanks. AndyK December 16th, 1999, 10:28 PM For "sided" gradient for z = 0 to 255 me.Line (Y * 10, height)-(Width, Y * 10), RGB(0, Y, 0), BF Y = Y + 1 next z for horizontal for z = 0 to 255 me.Line (Y * 20, Height)-(Width, 0), RGB(0, Y, 0), BF Y = Y + 1 next z for vertical for z = 0 to 255 me.Line (0, Height)-(Width, Y * 15), RGB(0, Y, 0), BF Y = Y + 1 next z if you want to invert the colors then just use negative values and use scalewidth/scaleheight, you might also want to place a scalemode to pixel to create really nice gradients, playy around with variables and you can make really nice effects...like light ray or tunnel, etc. Good Luck AndyK December 16th, 1999, 10:41 PM just another example: Y2 = me.ScaleHeight X2 = me.ScaleWidth for z = 0 to 255 me.Line (0, me.ScaleHeight)-(Y2, Y2), RGB(0, y, 0), B me.Line (me.ScaleWidth, Y2)-(Y2, 0), RGB(0, y, 0), B y = y + 1 Y2 = Y2 - 1 next z FStocker December 17th, 1999, 12:22 AM and another example: [vbcode] Private Sub Form_Paint() PaintForm Me, 1, 100, 0, 255, 1, 0, -1 End Sub Private Sub PaintForm(FormName As Form, Orientation%, RStart%, GStart%, BStart%, RInc%, GInc%, BInc%) ' This routine does NOT use API calls On Error Resume Next Dim x As Integer, y As Integer, z As Integer, Cycles As Integer Dim R%, G%, B% R% = RStart%: G% = GStart%: B% = BStart% ' Dividing the form into 100 equal parts If Orientation% = 0 Then Cycles = FormName.ScaleHeight \ 100 Else Cycles = FormName.ScaleWidth \ 100 End If For z = 1 To 100 x = x + 1 Select Case Orientation Case 0: 'Top to Bottom If x > FormName.ScaleHeight Then Exit For FormName.Line (0, x)-(FormName.Width, x + Cycles - 1), RGB(R%, G%, B%), BF Case 1: 'Left to Right If x > FormName.ScaleWidth Then Exit For FormName.Line (x, 0)-(x + Cycles - 1, FormName.Height), RGB(R%, G%, B%), BF End Select x = x + Cycles R% = R% + RInc%: G% = G% + GInc%: B% = B% + BInc% If R% > 255 Then R% = 255 If R% < 0 Then R% = 0 If G% > 255 Then G% = 255 If G% < 0 Then G% = 0 If B% > 255 Then B% = 255 If B% < 0 Then B% = 0 Next z End Sub [vbcode] FStocker December 17th, 1999, 12:22 AM and another example: Private Sub Form_Paint() PaintForm Me, 1, 100, 0, 255, 1, 0, -1 End Sub Private Sub PaintForm(FormName As Form, Orientation%, RStart%, GStart%, BStart%, RInc%, GInc%, BInc%) ' This routine does NOT use API calls On Error Resume Next Dim x As Integer, y As Integer, z As Integer, Cycles As Integer Dim R%, G%, B% R% = RStart%: G% = GStart%: B% = BStart% ' Dividing the form into 100 equal parts If Orientation% = 0 Then Cycles = FormName.ScaleHeight \ 100 Else Cycles = FormName.ScaleWidth \ 100 End If For z = 1 To 100 x = x + 1 Select Case Orientation Case 0: 'Top to Bottom If x > FormName.ScaleHeight Then Exit For FormName.Line (0, x)-(FormName.Width, x + Cycles - 1), RGB(R%, G%, B%), BF Case 1: 'Left to Right If x > FormName.ScaleWidth Then Exit For FormName.Line (x, 0)-(x + Cycles - 1, FormName.Height), RGB(R%, G%, B%), BF End Select x = x + Cycles R% = R% + RInc%: G% = G% + GInc%: B% = B% + BInc% If R% > 255 Then R% = 255 If R% < 0 Then R% = 0 If G% > 255 Then G% = 255 If G% < 0 Then G% = 0 If B% > 255 Then B% = 255 If B% < 0 Then B% = 0 Next z End Sub codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |