基于HTML5 Canvas實現雨滴效果: Rainday.js

jopen 10年前發布 | 41K 次閱讀 HTML5 前端技術 Rainday.js

一個簡單的腳本來模擬雨滴落在玻璃表面效果。rainyday.js擁有功能可擴展的API,碰撞檢測,并很容易用自己不同的動畫組件實現擴展。Rainyday.js是一個純的JavaScript庫,用到了HTML5的特性,所以都支持大多數現代瀏覽器它。

How to use:

var engine = new RainyDay({ element: image, // Image element // This value is required parentElement: someDiv, // Element to be used as a parent for the canvas // If not provided assuming the 'body' element crop: [0, 0, 50, 60], // Coordinates if only a part of the image should be used // If not provided entire image will be used blur: 10, // Defines blur due to rain effect // Assuming 10 if not provided // Use 0 value to disable the blur opacity: 1 // Opacity of rain drops // Assuming 1 if not provided }); engine.rain( [ [1, 0, 20], // add 20 drops of size 1... [3, 3, 1] // ... and 1 drop of size from 3 - 6 ... ],
100); </pre>dm2.jpg

項目主頁:http://www.baiduhome.net/lib/view/home/1406863000218

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!