<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        canvas怎樣做出黑色背景的青色煙花

        來源:懂視網 責編:小采 時間:2020-11-27 20:01:03
        文檔

        canvas怎樣做出黑色背景的青色煙花

        canvas怎樣做出黑色背景的青色煙花:這次給大家帶來canvas怎樣做出黑色背景的青色煙花,canvas做出黑色背景的青色煙花的注意事項有哪些,下面就是實戰案例,一起來看一下。html<canvas></canvas><h1>201<span>8</span></h1>
        推薦度:
        導讀canvas怎樣做出黑色背景的青色煙花:這次給大家帶來canvas怎樣做出黑色背景的青色煙花,canvas做出黑色背景的青色煙花的注意事項有哪些,下面就是實戰案例,一起來看一下。html<canvas></canvas><h1>201<span>8</span></h1>
        這次給大家帶來canvas怎樣做出黑色背景的青色煙花,canvas做出黑色背景的青色煙花的注意事項有哪些,下面就是實戰案例,一起來看一下。

        1.png

        html

        <canvas></canvas><h1>201<span>8</span></h1>

        css

        html,body { padding: 0px; margin: 0px; background: #222; font-family: 'Karla', sans-serif; color: #FFF; height: 100%; overflow: hidden;
        }h1 { z-index: 1000; position: fixed; top: 50%; left: 50%; transform: translateX(-50%) translateY(-100%); font-size: 58px; overflow: hidden;
        }span { position: relative; display: inline-block; animation: drop 0.75s ease 0s;
        }canvas { width: 100%; height: 100%;
        }
        @keyframes drop {
         0% { transform: translateY(-100px); opacity: 0;
         }
         90% { opacity: 1; transform: translateY(10px);
         }
         100% { transform: translateY(0px);
         }
        }

        js

        var ctx = document.querySelector('canvas').getContext('2d')ctx.canvas.width = window.innerWidthctx.canvas.height = window.innerHeightvar sparks = []var fireworks = []var i = 20;while (i--) { fireworks.push( new Firework(Math.random() * window.innerWidth, window.innerHeight * Math.random()) )}render()function render() { setTimeout(render, 1000 / 60) ctx.fillStyle = 'rgba(0, 0, 0, 0.1)'; ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height) for (var firework of fireworks) { if (firework.dead) continue firework.move() firework.draw() } for (var spark of sparks) { if (spark.dead) continue spark.move() spark.draw() } if (Math.random() < 0.05) { fireworks.push(new Firework()) }}function Spark(x, y, color) { this.x = x this.y = y this.dir = Math.random() * (Math.PI * 2) this.dead = false this.color = color this.speed = Math.random() * 3 + 3; this.walker = new Walker({ radius: 20, speed: 0.25 }) this.gravity = 0.25 this.dur = this.speed / 0.1 this.move = function () { this.dur-- if (this.dur < 0) this.dead = true if (this.speed < 0) return if (this.speed > 0) this.speed -= 0.1 var walk = this.walker.step() this.x += Math.cos(this.dir + walk) * this.speed this.y += Math.sin(this.dir + walk) * this.speed this.y += this.gravity this.gravity += 0.05 } this.draw = function () { drawCircle(this.x, this.y, 3, this.color) }}function Firework(x, y) { this.xmove = new Walker({ radius: 10, speed: 0.5 }) this.x = x || Math.random() * ctx.canvas.width this.y = y || ctx.canvas.height this.height = Math.random() * ctx.canvas.height / 2 this.dead = false this.color = randomColor() this.move = function () { this.x += this.xmove.step() if (this.y > this.height) this.y -= 1; else this.burst() } this.draw = function () { drawCircle(this.x, this.y, 1, this.color) } this.burst = function () { this.dead = true var i = 100; while (i--) sparks.push(new Spark(this.x, this.y, this.color)) }}function drawCircle(x, y, radius, color) { color = color || '#FFF' ctx.fillStyle = color ctx.fillRect(x - radius / 2, y - radius / 2, radius, radius)}function randomColor() { return ['#6ae5ab', '#88e3b2', '#36b89b', '#7bd7ec', '#66cbe1'][Math.floor(Math.random() * 5)];}function Walker(options) { this.step = function () { this.direction = Math.sign(this.target) * this.speed this.value += this.direction this.target ? this.target -= this.direction : (this.value) ? (this.wander) ? this.target = this.newTarget() : this.target = -this.value : this.target = this.newTarget() return this.direction } this.newTarget = function () { return Math.round(Math.random() * (this.radius * 2) - this.radius) } this.start = 0 this.value = 0 this.radius = options.radius this.target = this.newTarget() this.direction = Math.sign(this.target) this.wander = options.wander this.speed = options.speed || 1}

        相信看了本文案例你已經掌握了方法,更多精彩請關注Gxl網其它相關文章!

        推薦閱讀:

        JS中的async/await

        canvas怎樣做出黑色背景的紅色煙花

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        canvas怎樣做出黑色背景的青色煙花

        canvas怎樣做出黑色背景的青色煙花:這次給大家帶來canvas怎樣做出黑色背景的青色煙花,canvas做出黑色背景的青色煙花的注意事項有哪些,下面就是實戰案例,一起來看一下。html<canvas></canvas><h1>201<span>8</span></h1>
        推薦度:
        標簽: 煙花 黑色的 煙火
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 好男人资源在线WWW免费| 亚洲黄色激情视频| 成人毛片视频免费网站观看| 久久亚洲精品视频| 免费无码又爽又刺激网站| 国产卡一卡二卡三免费入口| 综合自拍亚洲综合图不卡区| 亚洲国产美女精品久久久 | 精品亚洲AV无码一区二区| 日韩精品无码免费一区二区三区| 亚洲Av熟妇高潮30p| 亚洲中文字幕一二三四区| 国产一卡二卡3卡四卡免费| 91亚洲国产成人久久精品| 免费大片黄在线观看yw| 在线观看亚洲AV日韩AV| 免费国产精品视频| 青青操视频在线免费观看| 久久精品国产亚洲AV无码娇色| 99热这里只有精品免费播放| 亚洲人成伊人成综合网久久| 女人18毛片水真多免费播放 | 两性色午夜视频免费播放| 亚洲av最新在线网址| jizz在线免费播放| 久久久亚洲精品无码| 成人无码区免费A片视频WWW| 亚洲AV无码一区二区乱子仑| 国产美女亚洲精品久久久综合| 亚洲乱妇老熟女爽到高潮的片| 免费播放一区二区三区| 亚洲婷婷第一狠人综合精品| 尤物永久免费AV无码网站| 亚洲色中文字幕在线播放| 亚洲国产成人久久精品99| 亚洲视频在线免费观看| 亚洲av永久中文无码精品综合 | 日韩在线观看免费完整版视频| 国产AV无码专区亚洲精品| 性做久久久久久免费观看| 国产精品小视频免费无限app|