canvas可拖拽旋转的三维随机曲线波动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas可拖拽旋转的三维随机曲线波动画效果代码,鼠标拖拽可进行三维旋转。
代码标签: canvas 拖拽 旋转 三维 随机 曲线 波 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { margin: 0px; padding: 0px; } body { background-color: black; overflow: hidden; } h2 { position: absolute; width: 100%; pointer-events: none; bottom: 40px; font: 12px/1 sans-serif; color: white; text-align: center; } .stage { position: absolute; width: 300px; height: 300px; left: 50%; top: 50%; margin: -150px 0 0 -150px; -wekit-perspective: 500px; -webkit-perspective: 500px; perspective: 500px; } #box { position: absolute; -webkit-transform-style: preserve-3d; -webkit-transform-origin: 50% 50%; -moz-transform-style: preserve-3d; -moz-transform-origin: 50% 50%; transform-style: preserve-3d; transform-origin: 50% 50%; left: 20px; top: 20px; width: 250px; height: 250px; cursor: move; } div.outer { -webkit-animation: fadeIn 0.5s ease-in 1 forwards; animation: fadeIn 0.5s ease-in 1 forwards; opacity: 0; } div, div div, div div div { width: 250px; height: 250px; position: absolute; left: 0; top: 0; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -webkit-transform-origin: 50% 50%; transform-origin: 50% 50%; transform-origin: 50% 50%; } div div { -webkit-animation: rotate1 12s linear infinite; animation: rotate1 12s linear infinite; } div div div { opacity: 0.7; position: absolute; left: 10px; top: 10px; width: 200px; height: 200px; border-radius: 50%; -webkit-transform: scale(0.2, 0.2); -webkit-animation: scale1 3s ease-in-out infinite alternate; -moz-transform: scale(0.2, 0.2); -moz-animation: scale1 3s ease-in-out infinite alternate; transform: scale(0.2, 0.2); animation: scale1 3s ease-in-out infinite alternate; } .b { left: auto; right: 10px; width: 100px; height: 100px; -webkit-animation: scale2 6s ease-in-out infinite alternate; animation: scale2 6s ease-in-out infinite alternate; } .c { left: auto; top: auto; right: 10px; bottom: 10px; -webkit-animation: scale1 3s ease-in-out infinite alternate; animation: scale1 3s ease-in-out infinite alternate; } .d { top: auto; bottom: 10px; width: 100px; height: 100px; -webkit-animation: scale2 6s ease-in-out infinite alternate; animation: scale2 6s ease-in-out infinite alternate; } @-webkit-keyframes rotate1 { from { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 50% { -webkit-transform: rotate(180deg); transform: rotate(180deg); } to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes rotate1 { from { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 50% { -webkit-transform: rotate(180deg); transform: rotate(180deg); } to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } } @-webkit-keyframes scale1 { from { -webkit-transform: rotateY(-90deg) scale(0.1, 0.1); transform: rotateY(-90deg) scale(0.1, 0.1); } to { -webkit-transform: rotateY(90deg) scale(1, 1); transform: rotateY(90deg) scale(1, 1); } } @keyframes scale1 { from { -webkit-transform: rotateY(-90deg) scale(0.1, 0.1); transform: rotateY(-90deg) scale(0.1, 0.1); } to { -webkit-transform: rotateY(90deg) scale(1, 1); transform: rotateY(90deg) scale(1, 1); } } @-webkit-keyframes scale2 { from { -webkit-transform: rotateY(90deg) scale(1, 1); transform: rotateY(90deg) scale(1, 1); } to { -webkit-transform: rotateY(-90deg) scale(0.1, 0.1); transform: rotateY(-90deg) scale(0.1, 0.1); } } @keyframes scale2 { from { -webkit-transform: rotateY(90deg) scale(1, 1); transform: rotateY(90deg) scale(1, 1); } to { -webkit-transform: rotateY(-90deg) scale(0.1, 0.1); transform: rotateY(-90deg) scale(0.1, 0.1); } } @-webkit-keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } </style> </head> <body> <section id="stage" class="stage"> <section id="box"></section> </section> <h2> Drag to rotate</h1> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/traqball.js"></script> <script> (function(scope){ //cheap and dirty color blending: Just create a gradient on a canvas and pick a list of colours. var createBlends = scope.createBlends = function(steps, startCol, endCol){ var canvas .........完整代码请登录后点击上方下载按钮下载查看
网友评论0