Follow us on...
Follow us on Twitter Follow us on Facebook
Register

User Tag List

Results 1 to 8 of 8
  1. #1
    Approved Artist CometTheMicroraptor's Avatar
    Join Date
    22 Mar 2011
    Location
    Liaoning Province, China. est. 126 mya
    Posts
    313
    Threads
    31
    Blog Entries
    2

    My User Ranks


    My Reputation

    Canvas Cycling in HTML5?

    Okay, so I'm curious about something, and this is entirely for future reference, so don't get too excited just yet. I also apologize if I'm not articulating myself very well, since I know very little about how this works.

    Now, I happened upon this site a while ago now, and it remains to be something that absolutely stuns and baffles me every time I look at it.
    The artist says that he and another programmer used HTML5 to make these images, which are like traditional canvas cycling pixelled images seen in older games.

    This is the site in question: http://www.effectgames.com/demos/canvascycle/
    I highly recommend going through it to see what I'm trying to describe here. Basically, though, they are images (with pleasant accompanying sounds, I might add) that have certain pixels cycling in color to create animations (most of which you see is precipitation and moving water).

    Now, out of curiosity... is anybody on here able to do that? I've mentioned before that a friend of mine and myself want to open a site that is slowly turning into something exclusively pixel based and we'd love to have our maps be like this. However, we'd love to have different weather patterns and light cycles happening on them as well (not that these would cycle but I think you get what I mean), and I'd love to know how it works or if anybody can help me do this so that I don't have to make the animations myself, as that is incredibly complicated. It just seems incredibly fascinating.


    deviantART: CometTheMicroraptor
    Tumblr: Cometkins
    PetRPG: Comet

  2. #2
    Senior Member
    Join Date
    27 Feb 2011
    Posts
    1,310
    Threads
    71

    My User Ranks

    My Reputation

    Re: Canvas Cycling in HTML5?

    I'm trying to wrap my head around how they are doing this. I assumed that this was done simply with images, and just cycling through them on the canvas to create the animation. But the way you described it sounds a little bit more complicated. Do you have a link to them describing this method?

  3. #3
    Approved Artist CometTheMicroraptor's Avatar
    Join Date
    22 Mar 2011
    Location
    Liaoning Province, China. est. 126 mya
    Posts
    313
    Threads
    31
    Blog Entries
    2

    My User Ranks


    My Reputation

    Re: Canvas Cycling in HTML5?

    http://www.effectgames.com/effect/ar...ing_with_HTML5

    This is where they described how it was done. I haven't read it in a while so I may not be describing it correctly s:


    deviantART: CometTheMicroraptor
    Tumblr: Cometkins
    PetRPG: Comet

  4. #4
    Proud Geek
    Join Date
    23 Jan 2011
    Posts
    844
    Threads
    221
    Blog Entries
    6

    My User Ranks


    My Reputation

    Re: Canvas Cycling in HTML5?

    A better way is array operations on imagedata objects. I'm working on an example.
    Commissions are closed temporarily.

  5. #5
    Proud Geek
    Join Date
    23 Jan 2011
    Posts
    844
    Threads
    221
    Blog Entries
    6

    My User Ranks


    My Reputation

    Re: Canvas Cycling in HTML5?

    The following example uses imagedata manipulation:

    http://www.brawnpower.com/img/test.html

    Programming this demo reinforced my preference of flash over HTML5 (CanvasPixelArray doesn't support the regular Array methods, meaning I had to use for loops to set each pixel value individually, adding extra code and time)

    On the bright side, it's still more flexible than using images (suppose, for example, that you wanted to slow down the animation. With this method, you can simply change a single number)
    Commissions are closed temporarily.

  6. #6
    Moderator Lewis's Avatar
    Join Date
    21 Jan 2011
    Location
    UK
    Posts
    1,715
    Threads
    108

    My User Ranks





    My Reputation

    Re: Canvas Cycling in HTML5?

    It's done by using one image and changing the colours of the palette and blending them with the original colour. If you click "Show Options »" you can see the colours changing.

    Quote Originally Posted by xtmx View Post
    The following example uses imagedata manipulation:

    http://www.brawnpower.com/img/test.html

    Programming this demo reinforced my preference of flash over HTML5 (CanvasPixelArray doesn't support the regular Array methods, meaning I had to use for loops to set each pixel value individually, adding extra code and time)

    On the bright side, it's still more flexible than using images (suppose, for example, that you wanted to slow down the animation. With this method, you can simply change a single number)
    How does that compare to this?

  7. #7
    Proud Geek
    Join Date
    23 Jan 2011
    Posts
    844
    Threads
    221
    Blog Entries
    6

    My User Ranks


    My Reputation

    Re: Canvas Cycling in HTML5?

    Quote Originally Posted by Lewis View Post
    It's done by using one image and changing the colours of the palette and blending them with the original colour. If you click "Show Options »" you can see the colours changing.



    How does that compare to this?
    And how do you think they show / change the colors?

    Basically you use a loop to check each set of four values (the data of each pixel) to see if it matches the target color, and if it does you set the values to 255, 255, 255, 0.

    ------

    That being said, I will concede that they were actually using images for the animation.
    Last edited by xtmx; 07-01-2012 at 12:01 PM.
    Commissions are closed temporarily.

  8. #8
    VPL Supporter Hituro's Avatar
    Join Date
    01 Feb 2011
    Posts
    1,293
    Threads
    220

    My User Ranks


    My Reputation

    Re: Canvas Cycling in HTML5?

    On an 8-bit animation system you achieved these effects by directly manipulating the color palette used to draw an image. This provided very fast color cycling animations, where waves of color moved across an image. I used to have a screensaver that acted just like that. By changing only part of the palette you could make only part of the image animate.

    In the JS implementation you can't change the actual color palette, so the author makes an object representing the palette, with cycles defined for each color, and then updates the canvas image as the colors change. For speed he redraws only the individual pixels whose colors have changed. He doesn't ever test the pixel's current color, just changes the palette.

 

 

Similar Threads

  1. Offering HTML5 Domain Name
    By xtmx in forum General Marketplace
    Replies: 8
    Last Post: 07-03-2012, 02:39 PM
  2. Need HTML5 games?
    By xtmx in forum Programming Marketplace
    Replies: 3
    Last Post: 06-08-2012, 01:39 PM
  3. For those who think HTML5 is better than flash.
    By xtmx in forum General Discussion
    Replies: 19
    Last Post: 02-01-2012, 10:41 AM
  4. My First Canvas Game
    By xtmx in forum Programming General
    Replies: 5
    Last Post: 01-30-2012, 07:59 PM
  5. HTML5 canvas- Ready to commit yet?
    By soulmirror in forum Programming General
    Replies: 5
    Last Post: 10-20-2011, 02:03 PM

Bookmarks

Posting Permissions

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