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"><rect x="108" y="230.7" width="865" height="467.3" transform="matrix(1,0,0,1,0,0)" fill="rgb(235,235,235)"/></g></g></svg> </div> <div class="clouds"> <div class="cloud cloud-1"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="474.751 67.039 275.339 125.625" width="275.339" height="125.625"><g><path d=" M 728.724 122.794 C 725.435 105.961 710.612 93.256 692.816 93.256 C 685.263 93.256 678.245 95.545 672.416 99.466 C 661.708 80.133 641.107 67.039 617.441 67.039 C 585.965 67.039 559.899 90.191 555.338 120.396 C 552.716 119.799 549.992 119.473 547.189 119.473 C 532.37 119.473 519.618 128.286 513.863 140.953 C 510.27 139.205 506.236 138.222 501.972 138.222 C 486.938 138.222 474.751 150.409 474.751 165.442 C 474.751 180.476 486.938 192.663 501.972 192.663 L 547.189 192.663 L 557.812 192.663 L 662.202 192.663 L 665.595 192.663 L 713.495 192.663 C 733.705 192.663 750.09 176.279 750.09 156.068 C 750.09 141.294 741.329 128.573 728.724 122.794 Z " fill="rgb(236,236,236)"/><path d=" M 578.788 134.243 C 572.573 129.169 563.183 128.405 556.229 132.406 C 549.276 136.408 545.22 144.912 546.485 152.834 C 548.977 146.639 553.76 142.253 559.429 138.725 C 565.098 135.198 572.129 133.743 578.788 134.243 Z " fill="rgb(245,245,245)"/><path d=" M 660.434 142.034 C 659.948 134.027 654.139 126.608 646.483 124.213 C 638.827 121.818 629.826 124.605 624.864 130.909 C 631.106 128.538 637.573 129.077 644.009 130.849 C 650.447 132.622 656.286 136.803 660.434 142.034 Z " fill="rgb(245,245,245)"/><path d=" M 560.509 137.715 C 560.913 113.69 576.422 90.948 597.832 80.041 C 614.388 71.606 634.499 70.851 651.866 77.317 C 641.98 70.822 630.155 67.039 617.441 67.039 C 585.965 67.039 559.899 90.192 555.338 120.396 C 552.716 119.799 549.991 119.474 547.189 119.474 C 540.255 119.474 533.776 121.403 528.252 124.754 C 532.749 123.687 537.488 123.627 541.991 124.668 C 549.534 126.411 556.328 131.198 560.509 137.715 Z " fill="rgb(245,245,245)"/><path d=" M 750.09 156.068 C 750.09 141.294 741.329 128.573 728.724 122.794 C 725.435 105.961 710.611 93.256 692.816 93.256 C 685.263 93.256 678.245 95.546 672.416 99.466 C 672.189 99.056 651.356 117.201 645.646 129.765 C 654.987 118.87 666.405 110.341 680.402 107.17 C 694.4 103.998 710.907 108.897 717.971 121.391 C 704.231 118.638 689.194 124.251 679.587 134.452 C 693.135 121.938 714.857 122.123 730.505 131.884 C 740.765 138.283 747.665 149.402 749.714 161.28 C 749.957 159.577 750.09 157.839 750.09 156.068 Z " fill="rgb(245,245,245)"/></g></svg> </div> <div class="cloud cloud-2"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="465.396 228.683 270.227 137..........完整代码请登录后点击上方下载按钮下载查看
网友评论0