|
-
May 14th, 2004, 12:02 AM
#1
Thread Starter
Hyperactive Member
Gradient's**(Resolved)**
OK, I've searched on this forum and PSC and I can't find the code to do this.
I know it can be done, but I just don't know how...
How do you make a label have a 3 way gradient?
e.g. start as one color go to another color and back again (RED, BLUE, RED) for instance.
I have seen it done with 2, 4, 6, and even made to look like a color chooser box with all the color in the rainbow.
I just want to know how to make it go from one to another and back. I don't even care what colors are used.
I've included a pic of sorta what I need it to look like
Last edited by New to VB 6; May 18th, 2004 at 02:01 AM.
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 14th, 2004, 05:07 PM
#2
Thread Starter
Hyperactive Member
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 14th, 2004, 05:51 PM
#3
So Unbanned
Well, a gradient is merely iterating through colors.
VB Code:
'color iteration = (dest color - start color) / length
ri = (r2 - r1) / length
gi = (g2 - g1) / length
bi = (b2 - b1) / length
For x = 1 to length
'dest color = start color + color iter
dr = r1 + ri
dg = g1 + gi
db = b1 + bi
Next
-
May 14th, 2004, 07:05 PM
#4
Here is a quick sample.
VB Code:
Private Sub Command1_Click()
Dim r As Integer
Dim g As Integer
Dim b As Integer
Dim intCenter As Integer
Dim intWidth As Integer
Dim i As Integer
intCenter = Picture1.ScaleWidth / 2
For i = 0 To 255
' Draw the left side
r = 255 - i
g = 0
b = i
intWidth = ((255 - i) / 255) * intCenter
Picture1.Line (0, 0)-(intWidth, Picture1.ScaleHeight), RGB(r, g, b), BF
' Draw the Right side
r = i
g = 0
b = 255 - i
intWidth = (((255 - i) / 255) * intCenter) + intCenter
Picture1.Line (intCenter, 0)-(intWidth, Picture1.ScaleHeight), RGB(r, g, b), BF
Next i
End Sub
-
May 15th, 2004, 02:08 AM
#5
Thread Starter
Hyperactive Member
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 15th, 2004, 03:53 AM
#6
Addicted Member
just another piece of code, hope you'll like it
it doesnt produce exactly what you want,
but guess you'll find it interesting.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim x As Integer, i As Integer, j As Integer
'all you need is:
'-make a new form
'-put a label in it
'set index property of the label to 0
'here initializing some values
Label1(0).Height = 255
Label1(0).Width = 255
Label1(0).Caption = ""
x = Label1(0).Width
'this loads 9*9 label1(x) array into positions
Label1(i).Left = x
Label1(i).Top = x
For i = 1 To 80
Load Label1(i)
Label1(i).Left = (i Mod 9 + 1) * x
Label1(i).Top = (i \ 9 + 1) * x
Label1(i).Visible = True
Next i
'this is just a matter of mathematical formulae
'customize the color pattern with it
For i = 0 To 256 Step 32
For j = 0 To 256 Step 32
Label1(i / 32 + j * 9 / 32).BackColor = RGB(i, j, 0)
Next j
Next i
End Sub
Last edited by ZaidGS; May 15th, 2004 at 04:02 AM.
-
May 15th, 2004, 10:43 PM
#7
Thread Starter
Hyperactive Member
MarkT came the closest to what I'm looking for.
but how do I change the colors?
192,0,192
255,255,255
192,0,192
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 16th, 2004, 02:17 AM
#8
So Unbanned
-
May 16th, 2004, 05:38 AM
#9
Addicted Member
play with these values to get what u want
(from MarkT's code)
try:
dont forget to change the right hand side to be a reflection
of left side.
-
May 17th, 2004, 03:35 AM
#10
Thread Starter
Hyperactive Member
Originally posted by DiGiTaIErRoR
You must mean something like this:
yes but on a picbox
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 17th, 2004, 06:00 AM
#11
So Unbanned
So you'll have to change:
Form1.ForeColor
and
Form1.Line
to:
Picture1.ForeColor
and
Picture1.Line
You could also add another param to the Gradient sub to pass a control to it.
-
May 17th, 2004, 05:01 PM
#12
Thread Starter
Hyperactive Member
could you please post the croped of code
I assume that it goes something like
VB Code:
,ByVal Sg As Long, ByVal Sb As Long, ByVal Fr As Long, ByVal Fg As Long, ByVal Fb As Long, ByVal x As Single)
[VBCODE]
Option Explicit
Dim XXX As Porn
Dim Wife As Nag
Private Sub *****_Resize()
On Error Resume Next
Get Viagra
End Sub
[/VBCODE]
-
May 17th, 2004, 05:09 PM
#13
So Unbanned
VB Code:
,ByVal Sg As Long, ByVal Sb As Long, ByVal Fr As Long, ByVal Fg As Long, ByVal Fb As Long)
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
|