-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
237 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<div class="aurora-bubble"> | ||
<div class="aurora-bubble-box" id="aurora-bubble-box"></div> | ||
<canvas class="aurora-bubble-canvas" id="aurora-bubble-canvas"></canvas> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
//获取用户传入的配置 | ||
let bubbleNumber = 0.15 | ||
let bubbleAlpha = 0.7 | ||
let alphaChangeSpeed = 0.0005 | ||
let size = 0.5 | ||
let sizeChangeSpeed = 0.002 | ||
let riseSpeed = 0.9 | ||
let color = '255,255,255' | ||
try { | ||
bubbleNumber = __BUBBLE_NUMBER__ | ||
bubbleAlpha = __BUBBLE_ALPHA__ | ||
alphaChangeSpeed = __ALPHA_CHANGE_SPEED__ | ||
size = __SIZE__ | ||
sizeChangeSpeed = __SIZE_CHANGE_SPEED__ | ||
riseSpeed = __RISE_SPEED__ | ||
color = __COLOR__ | ||
}catch (e) { | ||
console.warn(e) | ||
} | ||
const bubble = require('./bubble') | ||
export default { | ||
name: "AuroraBubble", | ||
mounted() { | ||
bubble.bubble(bubbleNumber,bubbleAlpha,alphaChangeSpeed,size,sizeChangeSpeed,riseSpeed,color) | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="css" scoped> | ||
.aurora-bubble { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: -1; | ||
} | ||
.aurora-bubble-box,.aurora-bubble-canvas { | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
top: 0; | ||
/*background: red;*/ | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* 这个气泡特效是收集于网络,作者为一为忆, http://www.iowen.cn */ | ||
let canvas, ctx, width, height, bubbles, animateHeader = true; | ||
let bubbleNumber,bubbleAlpha,alphaChangeSpeed,size,sizeChangeSpeed,riseSpeed,color; | ||
function initHeader() { | ||
canvas = document.getElementById('aurora-bubble-canvas'); | ||
window_resize(); | ||
ctx = canvas.getContext('2d'); | ||
//建立泡泡 | ||
bubbles = []; | ||
let num = width * bubbleNumber;//气泡数量 | ||
for (let i = 0; i < num; i++) { | ||
let c = new Bubble(); | ||
bubbles.push(c); | ||
} | ||
animate(); | ||
} | ||
|
||
function animate() { | ||
if (animateHeader) { | ||
ctx.clearRect(0, 0, width, height); | ||
for (let i in bubbles) { | ||
bubbles[i].draw(); | ||
} | ||
} | ||
requestAnimationFrame(animate); | ||
} | ||
|
||
function window_resize() { | ||
//canvas铺满窗口 | ||
width = window.innerWidth; | ||
height = window.innerHeight; | ||
|
||
//如果需要铺满内容可以换下面这个 | ||
let panel = document.getElementById('aurora-bubble-box'); | ||
width=panel.offsetWidth; | ||
height=panel.offsetHeight; | ||
|
||
canvas.width = width; | ||
canvas.height = height; | ||
} | ||
|
||
window.onresize = function(){ | ||
window_resize(); | ||
} | ||
|
||
function Bubble() { | ||
let _this = this; | ||
(function() { | ||
_this.pos = {}; | ||
init(); | ||
})(); | ||
function init() { | ||
_this.pos.x = Math.random() * width; | ||
_this.pos.y = height + Math.random() * 100; | ||
_this.alpha = 0.1 + Math.random() * bubbleAlpha;//气泡透明度 | ||
_this.alpha_change = 0.0002 + Math.random() * alphaChangeSpeed;//气泡透明度变化速度 | ||
_this.scale = 0.2 + Math.random() * size;//气泡大小 | ||
_this.scale_change = Math.random() * sizeChangeSpeed;//气泡大小变化速度 | ||
_this.speed = 0.1 + Math.random() * riseSpeed;//气泡上升速度 | ||
} | ||
//气泡 | ||
this.draw = function() { | ||
if (_this.alpha <= 0) { | ||
init(); | ||
} | ||
_this.pos.y -= _this.speed; | ||
_this.alpha -= _this.alpha_change; | ||
_this.scale += _this.scale_change; | ||
ctx.beginPath(); | ||
ctx.arc(_this.pos.x, _this.pos.y, _this.scale * 10, 0, 2 * Math.PI, false); | ||
ctx.fillStyle = 'rgba(' + color + ',' + _this.alpha + ')'; | ||
ctx.fill(); | ||
}; | ||
} | ||
|
||
|
||
module.exports = { | ||
bubble: function (aurora_bubbleNumber,aurora_bubbleAlpha,aurora_alphaChangeSpeed,aurora_size,aurora_sizeChangeSpeed,aurora_riseSpeed,aurora_color) { | ||
bubbleNumber = aurora_bubbleNumber | ||
bubbleAlpha = aurora_bubbleAlpha | ||
alphaChangeSpeed = aurora_alphaChangeSpeed | ||
size = aurora_size | ||
sizeChangeSpeed = aurora_sizeChangeSpeed | ||
riseSpeed = aurora_riseSpeed | ||
color = aurora_color | ||
|
||
initHeader(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Aurora-plugin/vuepress-plugin-bubble/lib/clientAppEnhance.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare const _default: import("@vuepress/client").ClientAppEnhance; | ||
export default _default; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineClientAppEnhance } from '@vuepress/client'; | ||
export default defineClientAppEnhance(({ app, router }) => { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { BubblePluginOptions } from './vuepress-plugin-bubble'; | ||
export * from './vuepress-plugin-bubble'; | ||
export default BubblePluginOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const bubblePlugin_1 = require("./vuepress-plugin-bubble"); | ||
__exportStar(require("./vuepress-plugin-bubble"), exports); | ||
exports.default = bubblePlugin_1.bubblePlugin; |
3 changes: 3 additions & 0 deletions
3
Aurora-plugin/vuepress-plugin-bubble/lib/node/vuepress-plugin-bubble.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { Plugin } from '@vuepress/core'; | ||
export declare type BubblePluginOptions = Record<never, never>; | ||
export declare const BubblePluginOptions: Plugin<BubblePluginOptions>; |
26 changes: 26 additions & 0 deletions
26
Aurora-plugin/vuepress-plugin-bubble/lib/node/vuepress-plugin-bubble.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cozePlugin = void 0; | ||
const { path } = require('@vuepress/utils') | ||
const utils_1 = require("@vuepress/utils"); | ||
const vuepressPluginBubble = ({bubbleNumber,bubbleAlpha,alphaChangeSpeed,size,sizeChangeSpeed,riseSpeed,color}) => { | ||
return { | ||
onInitialized: (app) => { | ||
|
||
}, | ||
name: 'vuepress-plugin-bubble', | ||
define: { | ||
__BUBBLE_NUMBER__: bubbleNumber, | ||
__BUBBLE_ALPHA__: bubbleAlpha, | ||
__ALPHA_CHANGE_SPEED__: alphaChangeSpeed, | ||
__SIZE__: size, | ||
__SIZE_CHANGE_SPEED__: sizeChangeSpeed, | ||
__RISE_SPEED__: riseSpeed, | ||
__COLOR__: color | ||
}, | ||
multiple: false, | ||
clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../clientAppEnhance.js'), | ||
clientAppRootComponentFiles: path.resolve(__dirname, '../AuroraBubble.vue'), | ||
}; | ||
}; | ||
exports.bubblePlugin = vuepressPluginBubble; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ | |
|
||
|
||
body::-webkit-scrollbar { | ||
display: none; | ||
/*display: none;*/ | ||
} |