Author |
Message |
chris swinso #1 / 8
|
 picture fade ?
hi all, I'm trying to fade a picture on a form, I've tried everything I can think of and can't find a answer, it can't be impossibly just to fade colours on a form ??? the only way I can see is just "draw it out" using lines ect but thats sooooooooo slowwwwwww taking about 2 mins to coverup a form, any ideas anyone ?? Thanks in advance, Chris
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Greg Siemo #2 / 8
|
 picture fade ?
This took a little longer than I thought it would. This works on the form but you can change it to a Picture Box. To slow it down use the Sleep API. Private Type xyType X As Long Y As Long End Type Private Sub Command1_Click() ReDim XY(0 To (ScaleWidth / Screen.TwipsPerPixelX) * (ScaleHeight / Screen.TwipsPerPixelY)) As xyType For i = 0 To (ScaleWidth / Screen.TwipsPerPixelX) - 1 For ii = 0 To ScaleHeight / Screen.TwipsPerPixelY - 1 XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).X = i XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).Y = ii Next Next RandomizeList XY() For i = 0 To UBound(XY) PSet (XY(i).X * Screen.TwipsPerPixelX, XY(i).Y * Screen.TwipsPerPixelY), vbWhite Next End Sub Private Sub RandomizeList(List() As xyType) Randomize For Start = LBound(List) To UBound(List) X = ((UBound(List) - Start) * Rnd) + Start Swap List(Start).X, List(X).X Swap List(Start).Y, List(X).Y Next End Sub Sub Swap(ByRef S1 As Variant, ByRef S2 As Variant) Dim Hold As Variant Hold = S1 S1 = S2 S2 = Hold End Sub -- Greg Siemon
Quote: > hi all, > I'm trying to fade a picture on a form, I've tried everything I can think of > and can't find a answer, it can't be impossibly just to fade colours on a > form ??? the only way I can see is just "draw it out" using lines ect but > thats sooooooooo slowwwwwww taking about 2 mins to coverup a form, any ideas > anyone ?? > Thanks in advance, > Chris
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Ian #3 / 8
|
 picture fade ?
Hi Greg Nice code, but it's nicer this way, instead of Command1_Click() having the code it has this Sub Command1_Click() FadePicture Me, vbWhite, 250 End Sub and then we use this sub Sub FadePicture(obj As Object, FadeTo As Long, _ Optional RefreshRate As Long = 100) Dim CurSM As Long Dim i As Long, ii As Long On Error GoTo ErrExit CurSM = obj.ScaleMode obj.ScaleMode = vbPixels ReDim XY(0 To obj.ScaleWidth * obj.ScaleHeight) As xyType For i = 0 To obj.ScaleWidth - 1 For ii = 0 To obj.ScaleHeight - 1 XY(i * obj.ScaleHeight + ii).X = i XY(i * obj.ScaleHeight + ii).Y = ii Next Next RandomizeList XY() For i = 0 To UBound(XY) obj.PSet (XY(i).X, XY(i).Y), FadeTo If i Mod RefreshRate = 0 Then obj.Refresh Next obj.ScaleMode = CurSM ErrExit: Err.Clear Exit Sub End Sub regards Ian ** invalid email address, change dk to denmark homepage http://www.kingsoft-denmark.com/
<snip>
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Greg Siemo #4 / 8
|
 picture fade ?
That was quick and dirty example. Attached is cleaned up as module. Iam curious why you need the Refresh. Greg Siemon
Quote: > Hi Greg > Nice code, but it's nicer this way, instead of Command1_Click() having the > code it has this > Sub Command1_Click() > FadePicture Me, vbWhite, 250 > End Sub > and then we use this sub > Sub FadePicture(obj As Object, FadeTo As Long, _ > Optional RefreshRate As Long = 100) > Dim CurSM As Long > Dim i As Long, ii As Long > On Error GoTo ErrExit > CurSM = obj.ScaleMode > obj.ScaleMode = vbPixels > ReDim XY(0 To obj.ScaleWidth * obj.ScaleHeight) As xyType > For i = 0 To obj.ScaleWidth - 1 > For ii = 0 To obj.ScaleHeight - 1 > XY(i * obj.ScaleHeight + ii).X = i > XY(i * obj.ScaleHeight + ii).Y = ii > Next > Next > RandomizeList XY() > For i = 0 To UBound(XY) > obj.PSet (XY(i).X, XY(i).Y), FadeTo > If i Mod RefreshRate = 0 Then obj.Refresh > Next > obj.ScaleMode = CurSM > ErrExit: > Err.Clear > Exit Sub > End Sub > regards > Ian > ** invalid email address, change dk to denmark > homepage http://www.kingsoft-denmark.com/
> <snip>
begin 666 Fade.bas <encoded_portion_removed>
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
chris swinso #5 / 8
|
 picture fade ?
HI, Thanks a bunch for working this one out :o) I never would have thought Pset to be a graphics command Doh! Thanks again Chris
Quote: > This took a little longer than I thought it would. This works on the form > but you can change it to a Picture Box. To slow it down use the Sleep API. > Private Type xyType > X As Long > Y As Long > End Type > Private Sub Command1_Click() > ReDim XY(0 To (ScaleWidth / Screen.TwipsPerPixelX) * (ScaleHeight / > Screen.TwipsPerPixelY)) As xyType > For i = 0 To (ScaleWidth / Screen.TwipsPerPixelX) - 1 > For ii = 0 To ScaleHeight / Screen.TwipsPerPixelY - 1 > XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).X = i > XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).Y = ii > Next > Next > RandomizeList XY() > For i = 0 To UBound(XY) > PSet (XY(i).X * Screen.TwipsPerPixelX, XY(i).Y *
Screen.TwipsPerPixelY), Quote: > vbWhite > Next > End Sub > Private Sub RandomizeList(List() As xyType) > Randomize > For Start = LBound(List) To UBound(List) > X = ((UBound(List) - Start) * Rnd) + Start > Swap List(Start).X, List(X).X > Swap List(Start).Y, List(X).Y > Next > End Sub > Sub Swap(ByRef S1 As Variant, ByRef S2 As Variant) > Dim Hold As Variant > Hold = S1 > S1 = S2 > S2 = Hold > End Sub > -- > Greg Siemon
> > hi all, > > I'm trying to fade a picture on a form, I've tried everything I can think > of > > and can't find a answer, it can't be impossibly just to fade colours on a > > form ??? the only way I can see is just "draw it out" using lines ect but > > thats sooooooooo slowwwwwww taking about 2 mins to coverup a form, any > ideas > > anyone ?? > > Thanks in advance, > > Chris
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Tigran A #6 / 8
|
 picture fade ?
Where is the definition of the RandomizeList function? thanks. Tigran Quote:
> Hi Greg > Nice code, but it's nicer this way, instead of Command1_Click() having the > code it has this > Sub Command1_Click() > FadePicture Me, vbWhite, 250 > End Sub > and then we use this sub > Sub FadePicture(obj As Object, FadeTo As Long, _ > Optional RefreshRate As Long = 100) > Dim CurSM As Long > Dim i As Long, ii As Long > On Error GoTo ErrExit > CurSM = obj.ScaleMode > obj.ScaleMode = vbPixels > ReDim XY(0 To obj.ScaleWidth * obj.ScaleHeight) As xyType > For i = 0 To obj.ScaleWidth - 1 > For ii = 0 To obj.ScaleHeight - 1 > XY(i * obj.ScaleHeight + ii).X = i > XY(i * obj.ScaleHeight + ii).Y = ii > Next > Next > RandomizeList XY() > For i = 0 To UBound(XY) > obj.PSet (XY(i).X, XY(i).Y), FadeTo > If i Mod RefreshRate = 0 Then obj.Refresh > Next > obj.ScaleMode = CurSM > ErrExit: > Err.Clear > Exit Sub > End Sub > regards > Ian > ** invalid email address, change dk to denmark > homepage http://www.kingsoft-denmark.com/
> <snip>
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
#7 / 8
|
 picture fade ?
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Joseph M. Erhard #8 / 8
|
 picture fade ?
Quote:
> HI, > Thanks a bunch for working this one out :o) I never would have thought > Pset to be a graphics command Doh! > Thanks again > Chris
> > This took a little longer than I thought it would. This works on the form > > but you can change it to a Picture Box. To slow it down use the Sleep > API. > > Private Type xyType > > X As Long > > Y As Long > > End Type > > Private Sub Command1_Click() > > ReDim XY(0 To (ScaleWidth / Screen.TwipsPerPixelX) * (ScaleHeight / > > Screen.TwipsPerPixelY)) As xyType > > For i = 0 To (ScaleWidth / Screen.TwipsPerPixelX) - 1 > > For ii = 0 To ScaleHeight / Screen.TwipsPerPixelY - 1 > > XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).X = i > > XY(i * (ScaleHeight / Screen.TwipsPerPixelY) + ii).Y = ii > > Next > > Next > > RandomizeList XY() > > For i = 0 To UBound(XY) > > PSet (XY(i).X * Screen.TwipsPerPixelX, XY(i).Y * > Screen.TwipsPerPixelY), > > vbWhite > > Next > > End Sub > > Private Sub RandomizeList(List() As xyType) > > Randomize > > For Start = LBound(List) To UBound(List) > > X = ((UBound(List) - Start) * Rnd) + Start > > Swap List(Start).X, List(X).X > > Swap List(Start).Y, List(X).Y > > Next > > End Sub > > Sub Swap(ByRef S1 As Variant, ByRef S2 As Variant) > > Dim Hold As Variant > > Hold = S1 > > S1 = S2 > > S2 = Hold > > End Sub > > -- > > Greg Siemon
> > > hi all, > > > I'm trying to fade a picture on a form, I've tried everything I can > think > > of > > > and can't find a answer, it can't be impossibly just to fade colours on > a > > > form ??? the only way I can see is just "draw it out" using lines ect > but > > > thats sooooooooo slowwwwwww taking about 2 mins to coverup a form, any > > ideas > > > anyone ?? > > > Thanks in advance, > > > Chris
Question: When the SWAP statement return? TIA Joe
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
|
|