Snow animation

I found a Script for snowflakes in my Edge-Animation film:

http://www.heathrowe.com/edge/snowflakes/snowflakes.zip

My Question:

How can I get the snowflakes before all other objects?

At present, they are only in the background, behind other objects.

Thanks for your help :-)

Here is the Code I use:



//canvas init


$('<canvas id="canvas"></canvas>').appendTo("#Stage");


var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");


//canvas dimensions
var W = window.innerWidth;
var H = window.innerHeight;
canvas.width = W;
canvas.height = H;


//snowflake particles
var mp = 95; //max particles
var particles = [];
for(var i = 0; i < mp; i++)
{
  particles.push({
  x: Math.random()*W, //x-coordinate
  y: Math.random()*H, //y-coordinate
  r: Math.random()*4+1, //radius
  d: Math.random()*mp //density
  })
}


//Lets draw the flakes
function draw()
{
  ctx.clearRect(0, 0, W, H);


  ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
  ctx.beginPath();
  for(var i = 0; i < mp; i++)
  {
  var p = particles[i];
  ctx.moveTo(p.x, p.y);
  ctx.arc(p.x, p.y, p.r, 0, Math.PI*2, true);
  }
  ctx.fill();
  update();
}


//Function to move the snowflakes
//angle will be an ongoing incremental flag. Sin and Cos functions will be applied to it to create vertical and horizontal movements of the flakes
var angle = 0;
function update()
{
  angle += 0.01;
  for(var i = 0; i < mp; i++)
  {
  var p = particles[i];
  //Updating X and Y coordinates
  //We will add 1 to the cos function to prevent negative values which will lead flakes to move upwards
  //Every particle has its own density which can be used to make the downward movement different for each flake
  //Lets make it more random by adding in the radius
  p.y += Math.cos(angle+p.d) + 1 + p.r/2;
  p.x += Math.sin(angle) * 2;


  //Sending flakes back from the top when it exits
  //Lets make it a bit more organic and let flakes enter from the left and right also.
  if(p.x > W+5 || p.x < -5 || p.y > H)
  {
  if(i%3 > 0) //66.67% of the flakes
  {
  particles[i] = {x: Math.random()*W, y: -10, r: p.r, d: p.d};
  }
  else
  {
  //If the flake is exitting from the right
  if(Math.sin(angle) > 0)
  {
  //Enter from the left
  particles[i] = {x: -5, y: Math.random()*H, r: p.r, d: p.d};
  }
  else
  {
  //Enter from the right
  particles[i] = {x: W+5, y: Math.random()*H, r: p.r, d: p.d};
  }
  }
  }
  }
}


//animation loop
setInterval(draw, 33);





Old code:

$('___').appendTo ("#Stage");

var canvas = document.getElementById ("canvas");

CTX var = canvas.getContext ("2d");

dimensions of the canvas

var W = window.innerWidth;

var H = window.innerHeight;

New code:

SYM. $('') .appendTo (sym.$("Rectangle"));

var canvas = document.getElementById ("canvas");

CTX var = canvas.getContext ("2d");

var W = sym.$("Rectangle").innerWidth ();

var H = sym.$("Rectangle").innerHeight ();

Demo file: neige.zip - Box

Tags: Edge Animate

Similar Questions

  • Superposition of MovieClip

    I'm new to Flash and try to figure out how to get a snow movieclip to play behind a chart. No matter what I always play in front of everything else on the stage.

    The ActionScript of snow is Jacques... http://www.Kirupa.com/developer/MX/snow.htm

    I have two sitting layers above the layer 'snow', but this does not affect the way he plays on the stage.

    If someone could help me get a graphic to sit above the snow animation that would be wonderful!

    Any information is greatly appreciated!

    All snow code should be placed in the movieclip.

  • Creating effect of snow on the EDGE

    I'm fighting to get a snow effect to load on BOARD, I tried to get it to load a javascript snow effect but it either fails or he spends behind any animation? can you please help me because I am completely at a loss! Thank you

    So here are 2 demos: snowflake images.zip - box

    We use setInterval() and one other requestAnimationFrame()

    Your svg file was wrong. Therefore, I use another svg file.

  • How to create gusts of snow and fog

    Hello

    I have CS6 AE and Premiere Pro, etc...  and I was wondering how to make the snow squalls.  I know how to make snow, but I would like to do something like in the following video.

    Effect of snow squalls

    http://www.YouTube.com/watch?v=kNPALlLCY34

    It seems that there the snow that goes on the side and smoke.

    Thanks for any help/ideas?

    Peter Forrest

    More about CS6, Win 7 64 bit

    Until you try, I highly recommend the following method using supplant Turbulent, which is a built-in effect.  Personally, I think it creates the control, keyframe and layers of fog or smoke excellent you can animate completely manually:

    a.) create a solid white.

    (b) the mask in a form that is more or less as you wish your fog to watch.

    (c.) set the feather mask to about 500 pixels.  You can modify or animate later once it's in your scene.

    (d.) add the effect of supplanting Turbulent white solid layer.

    (e.) change the complexity to 6.0 and you want that moving the fog to change over the time that I would say animating the offset and possibly evolution.

    (f.) so if you want the blowing fog across the screen, I suggest animating its position and possibly the mask path.

    (g.) if the fog is too opaque, you can adjust the opacity.

  • Not playable AE CS5 animation codec?

    I've recently updated to CS5.5 so I did my clips off with EI either loss or lossless with alpha (both use the animation codec). Some of my clips made and played very well, while other renditions but show only a quicktime icon and is not playing or import in what either. It's as if the information is there, but it is corrupted somehow. The only thread I can understand to determine if it will work or not depends on the length of my clip. One of my clips he has 20 seconds or more, didn't work. But all my clips in less than 15 seconds worked perfectly! There is some magic number between 15-20 seconds causing my renders to not be read. If anyone has had this problem or there at - it a bug known concerning the animation codec? I've searched and couldn't find something similar. Help, please!

    Specifications of the computer:

    Mac Pro Dual 2.66 GHz Quad-Core Intel Xeon

    Memory: 8 GB

    OS: Snow Leopard version 10.6.7

    AHA!  Make these files on a local drive, not a network.

    There are known issues with rendering EI 10 and 10.5 to a network, and Adobe working on it.

    Yes, it can be a pain, but the only way is to make locally and then move the file to the network rendering.  I'm sorry.

  • Simple animation Question

    Hey everybody!

    I'm still new in the process of learning Flash, but so far it has been great fun. My problem is with an animation that uses x and is axis.

    for (loop = 0; loop < 5; loop ++) {}
    boxName = 'box' + loop;
    attachMovie ("box", boxName, 10 * loop);

    var randomPlace:Number = random (500) + 550;
    var NumX:Number = randomPlace;
    var NumY:Number = random (100);
    var mySpeed:Number = random (10) + 5;

    _root [boxName] ._x = NumX;
    _root [boxName] ._y = NumY;

    _root [boxName] .onEnterFrame = function() {}
    This ._x mySpeed-=;
    If (this ._x < 0)
    This ._x = random (500) + 550;
    } //end function
    } //end inside the loop

    What does the code above poster of small boxes that are moving right on the screen to the left, and then they come back again (like a loop, I guess) and to each time a 'box' reappear, it starts at a random location at the top of the screen.

    Now what I would do is pritty much the same, but I would say that it falls just out of the top of the screen down. (Like snow falling from the sky). But I can't get my future in the x / y axis and it really confuses me.

    In addition, the size of my frame is 550 x 400

    Any help would be fantastic!

    use:

    var gravity: number = 3;

    for (loop = 0; loop< 5;="">
    boxName = 'box' + loop;
    var mc:MovieClip = attachMovie ("box", boxName, 10 * loop);
       
    MC._x = (550 - mc._width) * Math.random ();
    MC._y = 100 * Math.random ();
    MC. Speed = 10 * Math.random () + 5;  If you want all objects with a different value of "drift".
      
    mc.onEnterFrame = function() {}
    This ._x-= this.speed;

    This gravity of += ._y;
    If (this ._x < 0||this._y=""> Stage.height) {}
    This ._x = 550;

    This ._y = 0;

    }

    }

    } //end inside the loop

  • falling snow: pls help with actionscript

    Hallo,

    I made a flash animation with the snow that falls from the sky in Flash 8 (actionscript 2.0)

    However, the snow, I did differs from the original.

    The original is here:

    http://www.Kirupa.com/developer/MX/snow.htm

    I put mine here:

    http://toetssite.webs.com/

    You will notice that my only falling snow down: there is no randomness for the flakes to go left or right. There is no movement.

    Where in the script below can I change this so that there is more movement for flakes? Thank you

    I use the following script for the snow itself:

    onClipEvent (load) {}


    Specifies the size of the movie scene
    movieWidth = 300;
    movieHeight = 200;

    variables that alter the snowfall
    I have = 1 + Math.random () * 2;
    k = - Math.PI + Math.random () * Math.PI;

    What gives each snowflake unique features
    This ._xscale = this ._yscale = 50 + Math.random () * 100;
    This ._alpha = 75 + Math.random () * 100;
    This ._x = - 10 + Math.random () * movieWidth;
    This ._y = - 10 + Math.random () * movieHeight;
    }
    onClipEvent (enterFrame) {}
    restore the
    += rad (k/180) * Math.PI;
    this ._x-= Math.cos (rad);
    This += i ._y;
    If (this ._y > = movieHeight) {}
    This ._y = - 5;
    }
    If ((cette._x > = movieWidth) |) (cette._x < = 0)) {
    This ._x = - 10 + Math.random () * movieWidth;
    This ._y = - 5;
    }
    }


    and on the first frame of my movie, I put the following:

    for (k = 0; k < 50; k ++) {}


    duplicateMovieClip (this.snow, "snow" + k, k);


    }

    Thank you!

    Just initialize the variable rad. I added following line to your code and it works fine.

    rad = 0; a line that I inserted.

    No other changes required. It is advisable to initialize all variables before using them.

    in any case, below, that I provided all script for snow after change

    onClipEvent (load) {}

    Specifies the size of the movie scene

    movieWidth = 300;

    movieHeight = 200;

    rad = 0; a line that I inserted.

    variables that alter the snowfall

    I have = 1 + Math.random () * 2;

    k = - Math.PI + Math.random () * Math.PI;

    What gives each snowflake unique features

    This ._xscale = this ._yscale = 50 + Math.random () * 100;

    This ._alpha = 75 + Math.random () * 100;

    This ._x = - 10 + Math.random () * movieWidth;

    This ._y = - 10 + Math.random () * movieHeight;

    }

    onClipEvent (enterFrame) {}

    restore the

    += rad (k/180) * Math.PI;

    this ._x-= Math.cos (rad);

    This += i ._y;

    If (this ._y > = movieHeight) {}

    This ._y = - 5;

    }

    If ((cette._x > = movieWidth) |) (this ._x<=0))>

    This ._x = - 10 + Math.random () * movieWidth;

    This ._y = - 5;

    }

    }

  • My inner smartdrive dvd player won't read DVDs more.  I have updated to Snow Leopard in Yosemite.

    I am currently using OS X Yosemite 10.10.5.  I bought in 2009 iMac with Snow Leopard and have to Lion then updated my current operating system.  The internal dvd player has worked with much fussing, (insert the disc - closing - turn after a wait - by pushing the drive when he jumped on reboot).  If I had the chance after a few hours, the video disc show up on my desk.  When this happened, I was opening the dvd player that was in the Finder and the disc would play. I also tried to open the dvd first player and then insert the disc.  That no longer works.  Yesterday, only it just stop working.  The reader still takes dvd and swirls and click as before but then ejects the dvd. Repeatedly stop and restart is no longer works.  I make sure that the dvd be clean before I use it and have tried many different DVDs without success.  I think it's a software issue.  Does anyone have an idea/instructions a nearly dead grandmother brain that can follow to update or redate back to original factory setting to help this poor Smartdrive not so smart?

    I have no TV, only my computer and phone at low prices.  I need to watch that my library borrowed from the dvd.

    Thank you.

    Try a cleaning CD/DVD

    You can also try to clean by:

    How to clean a Superdrive DVD using a credit card!

    I suspect the optical drive has failed. My 2009 Mac Mini could not shoot with same symptom 4 years ago.

    To confirm a drive failure, insert a Snow Leopard installation DVD and try to start with the C key.

    If this isn't the case, they drive could not be started.

    I would just get an external optical drive, one powered with an AC adapter. The Superdrive Apple USB does not work without a hack.

    This is the Office Mac Pro forum. I asked that your post moved to the forum of Intel iMac or another appropriate forum.

  • How to make animated gifs to work in FCPX?

    Hello

    How to make animated gifs to work in FCPX?

    They work in FCP7 (FCS) but not FCPX. Strange.

    assailed

    Elmer

    If you had FCP7, you have Quicktime 7 Pro (upgraded automatically at installation FCP7). Check your Applications > Utilities folder.

    Open the gif in QT7 and export as... (Sequence Quicktime Movie > Open Options)... might as well go with ProRes LT and make sure that you pay attention to the size option (select current if the original is 100%).

  • Animation switching Office issues

    Does anyone else know a different animation in the Yosemite Sierra? Switching between desktop computers, the files animate as well and will be geek sometimes. Just curious, if it is a bug. I also have problems with the desktop image not resizing not between my Apple screen and the laptop, but one thing at a time. Thank you!

    Link to screenshot: https://www.dropbox.com/s/tl2bb1el5p4trs7/Full%20Screen%20Switching.mov?dl=0

    Hello SixThreeThree,

    Welcome to Apple Support communities. I see your message and your video as the glitch icons visually in the transition from desktop computers. I know it shouldn't. I'll be more than happy to help.

    Since it is a Visual problem, I recommend you to reset the NVRAM. This is the temporary video memory. Instructions that are below:

    How to reset the NVRAM on your Mac - Apple Support

    Once done, test to see if it happens again. If so, it wouldn't hurt to test this question on a new user. Take a look at this article:

    How to test a question in another account on your Mac - Apple Support

    Take care!

  • Old iPhone users - Animations in text?

    Just out of curiosity, older models of iPhone users can do the new animations and writing in the text? Also, if they update iOS can they see how iPhone users 7 may?

    I think that all 10 iOS devices support touch digital.

    Use number key on your iPhone, iPad and iPod touch - Apple Support

  • How to uninstall El Capitan and replaces it with clone of Snow Leopard?

    I had a chance terrible execution El Capitan, including in connection with CS5. It takes (literally) 10 x more time to save a .tiff file in El Capitan, than that of Snow Leopard. I suspect much too many processes running in the background, which most is probably not necessary, but I don't know that for sure. Something is not.

    I have a clone perfect my Snow Leopard former plant and wonder if that can just be installed right on El Capitan, as when we do an update of the operating system, or do I have to erase the whole score first, then install clone?

    (I know, I'll then have browser problems, but...)

    FTR: Mac Pro (early 2009, 2.66 Ghz, single image), running OS 10.11.5

    Thank you very much

    Hi CFS88,

    Thanks for joining the communities Support from Apple. I see your message you need to restore your operating system Snow Leopard of El Capitan. I'm happy to help you!

    To install Snow Leopard on your system, you will need to use a snow leopard install DVD or disc of original installation if your Mac comes with Snow Leopard originally. Once you insert the disc, press and hold the C button it restarts and restart your Mac. This will allow you to boot from the installation disc. From there, you can use disk utility to wipe your drive and reinstall OS X. Once installation is complete, you can choose your preferred option to migrate your data to your Mac using the installation wizard.

    If you use Time Machine, you can restore from a backup Time Machine with installed thus 10.6:

    macOS Sierra: return to an earlier version of Mac OS

    See you soon!

  • I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    Without knowing what is happening when you try, it is difficult to recommend troubleshooting. However, one of the first steps is to ensure that you don't have to reduce the Motion activated in accessibility.

  • Why am I unable to send animation effects when I press and hold send key

    I have the ios10 update on my phone but when I hold down the Send button to add animations, little option to choose what I want will not appear in my messages nor can I receive the animation when someone sends me

    Disable the reduced movement.

    Settings > general > accessibility > reduce motion > [disable]

  • iPhone 7 slower Animations &amp; Chop?

    I use an iPhone 7, coming of the 6 s. I noticed that when an application is closed, there is a stutter that occurs about 80% of the time when you return to the home screen. On the 6s is one, smooth animation. I even recorded two screens in slow motion to make sure I wasn't crazy, and of course, the iPhone 7 stops just after that starts the animation. In addition, I noticed that using the task on the iPhone switch 7 is rougher. Even more, I noticed that unity apps are much more turbulent and unstable on the iPhone 7 when they are smooth as silk on the 6s. Has anyone else noticed similar experiences? I noticed lag on iPhone Home screen a friend 7 at work, and I've seen other people mention the same thing. I just want to get this out there while Apple is aware. (If they are not already.) And, Yes, I already wrote a request for feedback. Just want to get more visibility in the present, or if someone has found solutions.

    We could do with as many people as possible put your comments in on this one. I was in the Apple Store the other day, trying to attract the attention of the assistant to this problem; He couldn't see it. I know I'm picky, but I can really see it.

    The only solution I've seen involves reducing transparency and movement in accessibility options. They have some workarounds, however.

Maybe you are looking for