dcsimg
Results 1 to 19 of 19

Thread: Animated Spinner Class [vbRichClient5]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Animated Spinner Class [vbRichClient5]

    After contributing to the following thread (http://www.vbforums.com/showthread.p...Wheel-Spinning), I thought others might be interested in an animated spinner, so I packaged my code into a class and added a simple demo form that allows you to play around with the parameters in real-time.


    Demo Screenshot:

    Name:  Spinner7.png
Views: 4567
Size:  23.1 KB


    Samples:

    Name:  Spinners.png
Views: 3735
Size:  47.1 KB


    Source code:

    AnimatedSpinner.zip


    Features:
    Antialiased
    Clockwise/Counter-Clockwise animation
    Adjustable Speed of spin in, normal spin, and spin out frames
    Number of segments to draw
    Size of the spinner
    Padding between the edge of the spinner box and the spinner
    Base Color of the spinner
    Background color of the spinner (including transparent background)
    Size of the hole in the middle of the spinner
    Total Degrees that the spinner should span
    Degrees of margin between segments
    Gaussian Blur, optionally clipping blurred edges
    Optionally fade segments
    Optional animated fade on spin in/out
    Optional animated zoom on spin in/out


    NOTES
    This demo requires the vbRichClient5 framework to be registered on your development system.

    This code is free to use for any purpose. No warranties! This code has not been extensively tested, nor is it currently used in any production environment. It is also my first attempt at using the vbRC5 Cairo graphics methods, so there may well be bugs/inefficiencies.

    Enjoy!
    Last edited by Shaggy Hiker; Jan 12th, 2019 at 06:11 PM. Reason: Bug Fixes, More Features, New Screenshots

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: [vbRichClient5] Animated Spinner Class

    Updated with some bug fixes and new features

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: [vbRichClient5] Animated Spinner Class

    Updated again with new Gaussian Blur feature, minor bug fixes, and a new drawing approach to get transparency working properly. Latest code in first post.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: [vbRichClient5] Animated Spinner Class

    One last update tonight - added a SegmentMargin property so you can control the distance between segments.

  5. #5
    Addicted Member
    Join Date
    Oct 2004
    Location
    Philippines
    Posts
    149

    Re: [vbRichClient5] Animated Spinner Class

    Very nice. Thanks for the sample project. This will be usefull

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: [vbRichClient5] Animated Spinner Class

    @Zelot - Thanks a lot, glad you've found it useful!

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: [vbRichClient5] Animated Spinner Class

    Just added the ability to clip the outside and inside edges of the spinner. This can produce "tighter" effects when combined with the gaussian blur option. Latest source code in first post.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    Added the following options:

    Fade During Spin-In/Spin-Out
    Zoom During Spin-In/Spin-Out
    Enable/Disable Segment Fading

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    Sorry for all of the updates everyone - fixed a bug that was causing the spinner degree span to fall short slightly for each segment drawn...for example, at 32 segments and 360 degree desired span, the drawing would fall short a few degrees. Latest source in first post.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    Yet another update!

    Added a "Copy to Clipboard" button that will build VB6 source code based on the settings you have defined in the demo app, then copy the code to the clipboard for use in your own programs.

    Also fixed a size calculation error for the Hole % when gaussian blur >0 and the clip blurred edges option is selected.

    Latest source in first post.

  11. #11
    New Member
    Join Date
    Jul 2013
    Posts
    8

    Re: Animated Spinner Class [vbRichClient5]

    This is excellent!

    Have you considered to make it a Widget (something like cwSpinner) to be used like the other vbWidgets? Also this could be included in the vbWidgets project in GitHub if you are ok with that...

    I don't know what use you give to this beautiful animation, I was thinking in something like the Firefox's "page loading" spinning circle, for signaling that my application is working... Is that the main purpose of this animation or is something else?

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    @Kbre

    Thanks for the kind words! I appreciate the response, since sometimes it feels like I'm passing these demos off into the air.

    The main inspiration was a combination of this thread, and (as you mentioned) things like the Firefox "page loading" animation, and other spinners that have become especially common on webpages such as YouTube, etc.... The next inspiration was to get more familiar with the vbRC5 Cairo classes, so it seemed like a nice fit.

    I'll be honest though, it was mostly a learning experience for me - I don't use this code in any of my projects right now, and I don't know how it performs in the cases where it would be most useful (e.g. where a task completion time is undeterminable, yet you want to inform the user that work is being done).

    That said, I can see use cases where either:

    A) It is running in a class using the threading features of RC5 - the animation might be smoother, but it would likely be eating more processor time (making the overall task time longer), and possibly even continuing to animate when the parent has locked-up in an infinite loop, therefor being deceptively and infinitely responsive).

    B) It is being used in tasks that are easily separable into steps, so you could perform one step in every firing of a certain interval (the class could fire an event every X milliseconds, and during that time the parent could perform some processing, then relinquish control back to the animation). This would likely result in "choppier" animation, but the task would likely finish sooner. However, with fine tuning of the steps, it might be indistinguishable from the threaded version, without the chance for deadlock misrepresentation (e.g. when the animation stops, the user will know that there is a problem).

    I suppose it would be up to the programmer to decide what scenario was preferable, and how much time they want to spend tuning either approach.

    Regarding inclusion in vbRC5, I've actually directly offered the class to Olaf for inclusion in vbWidgets, so when he gets back in the mood for it, I hope it might be included.

  13. #13
    Member
    Join Date
    Oct 2012
    Posts
    32

    Re: Animated Spinner Class [vbRichClient5]

    This is great and I would like to use it but I am not sure how to actually get it going in a VB6 program.
    I am writing some data from memory to an excel spreadsheet then saving the worksheet.
    I would like to start the spinner before I start the write process and stop the spinner when the file has been saved.
    Could you tell me how to do this please? Thanks

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    Here's an example that creates an Excel spreadsheet while the timer is spinning, then stops the spinner when the population of the spreadsheet is done and shows the Excel window:

    AnimatedSpinnerExcel.zip

  15. #15
    Member
    Join Date
    Oct 2012
    Posts
    32

    Re: Animated Spinner Class [vbRichClient5]

    That's great, thanks a heap jpbro

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,356

    Re: Animated Spinner Class [vbRichClient5]

    Cheers!

  17. #17
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,598

    Re: Animated Spinner Class [vbRichClient5]

    Great, perhaps we can use Cairo to develop a control similar to Fusioncharts in the future. Thanks very much, jpbro.

  18. #18
    New Member
    Join Date
    May 2019
    Posts
    1

    Re: Animated Spinner Class [vbRichClient5]

    it is for vb ? im learnin vb 2012, how to use it?

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,046

    Re: Animated Spinner Class [vbRichClient5]

    No, it is for VB6. The two languages are almost completely different, despite similar names and syntax. VB2012 is VB.NET, so nothing in Classic VB, or VB6 can be considered compatible. However, you may have also managed to choose the single ugliest version of VS ever made. 2010 was the most beautiful, while anything after 2012 was an improvement over 2012.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width