逼真的HTML5树叶飘落动画

2020-04-21 07:49:22易采站长站整理

    }   
}   
  
/*  
    Receives the lowest and highest values of a range and  
    returns a random integer that falls within that range.  
*/  
function randomInteger(low, high)   
{   
    return low + Math.floor(Math.random() * (high – low));   
}   
  
/*  
   Receives the lowest and highest values of a range and  
   returns a random float that falls within that range.  
*/  
function randomFloat(low, high)   
{   
    return low + Math.random() * (high – low);   
}   
  
/*  
    Receives a number and returns its CSS pixel value.  
*/  
function pixelValue(value)   
{   
    return value + ‘px’;   
}   
  
/*  
    Returns a duration value for the falling animation.  
*/  
  
function durationValue(value)   
{   
    return value + ‘s’;   
}   
  
/*  
    Uses an img element to create each leaf. "Leaves.css" implements two spin   
    animations for the leaves: clockwiseSpin and counterclockwiseSpinAndFlip. This  
    function determines which of these spin animations should be applied to each leaf.  
 
*/  
function createALeaf()   
{   
    /* Start by creating a wrapper div, and an empty img element */  
    var leafDiv = document.createElement(‘div’);   
    var image = document.createElement(‘img’);   
  
    /* Randomly choose a leaf image and assign it to the newly created element */