svg+canvas实现火山口喷发喷射火山灰云朵动画代码
代码语言:html
所属分类:动画
代码描述:svg+canvas实现火山口喷发喷射火山灰云朵动画代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> html, body { height: 100%; overflow: hidden; background-color: #189BBB; } canvas { display: block; background: transparent; position: relative; z-index: 1; } .volcano { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%) translateY(20%); height: 40vh; z-index: 0; } .volcano-front { z-index: 2; } .volcano svg { display: block; width: auto; height: 100%; position: relative; z-index: 0; } @-webkit-keyframes cloud { from { transform: translateX(-100vw); } from { transform: translateX(100vw); } } @keyframes cloud { from { transform: translateX(-100vw); } from { transform: translateX(100vw); } } .cloud { position: absolute; top: 10px; left: 0; width: 100px; transform: translateX(-100vw); -webkit-animation: cloud 10s linear infinite alternate; animation: cloud 10s linear infinite alternate; z-index: 0; } .cloud svg { width: 100%; } .cloud-1 { top: 70px; width: 120px; animation: cloud 16s linear infinite reverse; } .cloud-2 { top: 60px; width: 80px; -webkit-animation: cloud 20s linear infinite; animation: cloud 20s linear infinite; } .cloud-3 { top: 45px; -webkit-animation: cloud 10s linear infinite; animation: cloud 10s linear infinite; } </style> </head> <body> <canvas width="460" height="320"></canvas> <div class="volcano volcano-back"> <svg id="volcano-back" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="108 230.697 865 467.303" width="865" height="467.303"><g><path d=" M 789 689 L 533 698 L 283 682 L 108 668 Q 273.759 572.579 340 494 Q 363.402 466.239 400 410 L 440 329 L 468 254 Q 471.39 247.858 477 244 Q 482.61 240.142 490 244 Q 500.248 237.219 505 237 C 509.752 236.781 522.534 239.137 527 243 C 531.466 246.863 532.249 249.001 540 250 Q 547.751 250.999 552 249.686 L 560 240 Q 564.54 235.93 569 234 Q 574.057 231.812 584 233 Q 593.965 233.341 598 237 C 602.035 240.659 605.761 244.471 607 252 Q 608.239 259.529 618 291 L 635 339 L 653 379 L 669 410 L 706 467 L 754 520 L 821 576 L 865 606 L 922 641 L 973 671 L 789 689 Z " fill="rgb(130,80,38)"/><path d=" M 251 641 Q 228.031 624.359 348 501 L 434.963 374 L 477 274 L 478.976 249.686 L 478.976 249.686 L 494.593 265.346 L 513.05 277.092 L 535.766 271.872 L 549.964 265.346 L 561.322 244.466 L 587 245 L 612 287 L 653 403 L 699 476 Q 882.723 656.474 843 649 C 803.277 641.526 718.221 586.823 676.323 583.779 C 634.425 580.735 677.969 695.418 632.311 668.607 C 577.686 636.532 551.148 538.473 540.026 539.407 C 528.904 540.341 514.44 712.1 461.938 668.607 C 430.801 642.813 446.752 525.781 434.963 530.272 C 423.174 534.763 398.172 576.105 374 595 C 349.828 613.895 273.969 657.641 251 641 Z " fill="rgb(147,93,45)"/><path d=" M 318 582 Q 314.756 552.464 378 452 L 441 332 L 471 245 L 484 241 L 496 245 L 507 257 L 520 266 L 536 262 L 546 257 L 562 237 Q 571.865 232.571 578 231 Q 584.135 229.429 597 236 L 604 244.466 L 610 274 L 630 367 Q 642.243 399.109 655 425 Q 666.978 449.31 688 480 Q 794.978 587.727 767 582 C 739.022 576.273 664.51 503.332 635 501 C 605.49 498.668 636.159 586.544 604 566 C 565.526 541.422 546.834 466.284 539 467 C 531.166 467.716 520.979 599.326 484 566 C 462.068 546.235 473.303 456.559 465 460 C 456.697 463.441 416.863 521.226 392 543 C 367.137 564.774 320.85 607.952 318 582 Z " fill="rgb(173,113,54)"/></g></svg> </div> <div class="volcano volcano-front"> <svg id="volcano-front" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="108 230.697 865 467.303" width="865" height="467.303"><g><path d=" M 251 641 Q 228.031 624.359 348 501 L 434.963 374 L 477 274 L 478.976 249.686 L 478.976 249.686 L 494.593 265.346 L 513.05 277.092 L 535.766 271.872 L 549.964 265.346 L 561.322 244.466 L 587 245 L 612 287 L 653 403 L 699 476 Q 882.723 656.474 843 649 C 803.277 641.526 718.221 586.823 676.323 583.779 C 634.425 580.735 677.969 695.418 632.311 668.607 C 577.686 636.532 551.148 538.473 540.026 539.407 C 528.904 540.341 514.44 712.1 461.938 668.607 C 430.801 642.813 446.752 525.781 434.963 530.272 C 423.174 534.763 398.172 576.105 374 595 C 349.828 613.895 273.969 657.641 251 641 Z " fill="rgb(147,93,45)"/><path d=" M 318 582 Q 314.756 552.464 378 452 L 441 332 L 471 245 L 484 241 L 496 245 L 507 257 L 520 266 L 536 262 L 546 257 L 562 237 Q 571.865 232.571 578 231 Q 584.135 229.429 597 236 L 604 244.466 L 610 274 L 630 367 Q 642.243 399.109 655 425 Q 666.978 449.31 688 480 Q 794.978 587.727 767 582 C 739.022 576.273 664.51 503.332 635 501 C 605.49 498.668 636.159 586.544 604 566 C 565.526 541.422 546.834 466.284 539 467 C 531.166 467.716 520.979 599.326 484 566 C 462.068 546.235 473.303 456.559 465 460 C 456.697 463.441 416.863 521.226 392 543 C 367.137 564.774 320.85 607.952 318 582 Z " fill="rgb(173,113,54)"/><g opacity="0">.........完整代码请登录后点击上方下载按钮下载查看
网友评论0