js实现canvas四叶草飞舞动画背景效果代码
代码语言:html
所属分类:背景
代码描述:js实现canvas四叶草飞舞动画背景效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Irish+Grover" rel="stylesheet"> <style> html, body { margin:0px; padding:0px; background-color:#020; font-family:sans-serif; font-size:16px; overflow:hidden; } #logo { position: absolute; right:0px; bottom:0px; } p { color:#020; } canvas { background-color:#020; } </style> </head> <body> <canvas id="testCanvas" width="550" height="500"></canvas> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/easeljs.js"></script> <script> var canvas; var stage; var container; var captureContainers; var captureIndex; function init() { // create a new stage and point it at our canvas: canvas = document.getElementById("testCanvas"); stage = new createjs.Stage(canvas); canvas.width = window.innerWidth; canvas.height = window.innerHeight; var w = canvas.width; var h = canvas.height; container = new createjs.Container(); stage.addChild(container); captureContainers = []; captureIndex = 0; // create a large number of slightly complex vector shapes, and give them random positions and velocities: var shadow = new createjs.Shadow("#000", 2,2,5); for (var i = 0; i < 50; i++) { var heart = new createjs.Container(); var h1 = new createjs.Shape(); h1.graphics.beginFill(createjs.Graphics.getHSL(Math.random() * 30 - 230, 100, 50 + Math.random() * 30)).p("AC3H6QgEg1hHi/IhGi0QAIBPgDAzQgDA9gWB1QgLA7guAoQgtAng+AHQhAAHg7geQhAgigohHQhJiCBrh7QBDhNBxg4IgtAOQh9Ajh6gLQhGgGgjhIQgghEALhdQALhgA0hFQA6hOBagOQCggZBhCNQAxBHARBLQgLhLAGhTQAOilBhgnQBjgnBkA3QAzAcAeAkQBZCBh2B/Qg8BAhNAmIBEgUQBIgTAVgBQCzgHAsB3QAuB7g/BhQgtBDhCAWQhDAVhgg7Qhhg7hQh5QCREgASBXQARBYgNALQgOALgQAEIgMABQggAAgDgwg") h1.shadow = shadow; heart.addChild(h1); heart.cache(-80,-80,160,160,0.5); heart.y = -100; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0