picture fade ? 
Author Message
 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  
 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  
 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  
 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  
 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),

- Show quoted text -

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  
 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  
 picture fade ?


Wed, 18 Jun 1902 08:00:00 GMT  
 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  
 
 [ 8 post ] 

 Relevant Pages 

1. Picture Fade In/Out

2. Help: Resized picture fades to black !!

3. Make a Picture fade effect

4. fading of two pictures (blend one picture into the other)

5. Fading a picture box

6. Fade Transition Using Picture Box

7. Fading out a picture

8. Fading a Picture Box -- help!!

9. Fade picture...

10. fading pictures

11. 'Fades' between pictures

12. Fading of Pictures/Animations

 

 
Powered by phpBB® Forum Software