701 lines
34 KiB
JavaScript
701 lines
34 KiB
JavaScript
|
/*
|
||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
|
if you want to view the source, please visit the github repository of this plugin
|
||
|
*/
|
||
|
|
||
|
var __defProp = Object.defineProperty;
|
||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
|
var __export = (target, all) => {
|
||
|
for (var name in all)
|
||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||
|
};
|
||
|
var __copyProps = (to, from, except, desc) => {
|
||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||
|
for (let key of __getOwnPropNames(from))
|
||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
|
}
|
||
|
return to;
|
||
|
};
|
||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||
|
var __async = (__this, __arguments, generator) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
var fulfilled = (value) => {
|
||
|
try {
|
||
|
step(generator.next(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var rejected = (value) => {
|
||
|
try {
|
||
|
step(generator.throw(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||
|
});
|
||
|
};
|
||
|
|
||
|
// main.ts
|
||
|
var main_exports = {};
|
||
|
__export(main_exports, {
|
||
|
default: () => DynamicBackgroundPlugin
|
||
|
});
|
||
|
module.exports = __toCommonJS(main_exports);
|
||
|
var import_obsidian = require("obsidian");
|
||
|
|
||
|
// effects/dark-dynamic-star-sky.ts
|
||
|
function Add_StarSky(dynamicBackgroundContainer) {
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-dt-star-sky-dynamic-effect" });
|
||
|
effect.createEl("div", { cls: "star-sky" });
|
||
|
}
|
||
|
}
|
||
|
function Remove_StarSky(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-star-sky-dynamic-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// effects/dark-dynamic-snow.ts
|
||
|
var DarkTheme_Snow_Background_Property = "radial-gradient(ellipse at bottom, #1b2735 20%, #090a0f 100%)";
|
||
|
function Add_Snow(dynamicBackgroundContainer) {
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-dt-snow-dynamic-effect" });
|
||
|
effect.createEl("div", { cls: "snow" });
|
||
|
}
|
||
|
}
|
||
|
function Remove_Snow(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-snow-dynamic-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// effects/dark-dynamic-rain.ts
|
||
|
var DarkTheme_Rain_Background_Property = "radial-gradient(ellipse at bottom, #1b2735 20%, #090a0f 100%)";
|
||
|
function Add_Rain(dynamicBackgroundContainer) {
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-dt-rain-dynamic-effect" });
|
||
|
let drop1 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 34; --y: 90; --o: 0.6654153804683264; --a: 0.9917710156945896; --d: -0.8043425740744814; --s: 0.6951142349804096"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop2 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 49; --y: 81; --o: 0.0317509941505465; --a: 1.4150340796041947; --d: -0.8977060475990615; --s: 0.3560926038758976"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop3 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 93; --y: 6; --o: 0.6536147164205229; --a: 1.3150980722082548; --d: -0.5493637177821533; --s: 0.5552132370247103"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop4 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 22; --y: 13; --o: 0.4259600004078947; --a: 0.5854285185377734; --d: -0.5293135001180258; --s: 0.3526760878325925"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop5 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 36; --y: 20; --o: 0.5609448459063665; --a: 1.4252956133711117; --d: -0.7690131594986251; --s: 0.6689223471599941"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop6 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 48; --y: 54; --o: 0.2850601343180057; --a: 1.4235635026018683; --d: -0.4523568427598179; --s: 0.19763333766570312"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop7 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 16; --y: 4; --o: 0.4224367492164993; --a: 0.9291570251573422; --d: -0.7072288650072931; --s: 0.3225005986968783"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop8 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 50; --y: 52; --o: 0.5163724944648716; --a: 0.5163417250721392; --d: -0.24562675844904858; --s: 0.7462277243198527"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop9 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 35; --y: 66; --o: 0.31206402174244974; --a: 0.6059744356541634; --d: 0.37906548779328597; --s: 0.7307418662633716"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop10 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 64; --y: 81; --o: 0.8158102807508611; --a: 0.6722718682672502; --d: 0.2444215747954348; --s: 0.8667250195046547"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop11 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 88; --y: 35; --o: 0.02762815253441553; --a: 0.9555468749843488; --d: 0.08996319031500377; --s: 0.7428281610861129"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop12 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 88; --y: 91; --o: 0.6103134847919844; --a: 0.9001734345539698; --d: -0.917351021576823; --s: 0.0040542399155854"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop13 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 62; --y: 54; --o: 0.2856796208317729; --a: 0.9046554131241138; --d: -0.13645809866400516; --s: 0.5739079247947556"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop14 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 26; --y: 67; --o: 0.3249777593937293; --a: 1.0274350664090073; --d: -0.8605688159121647; --s: 0.7199893214500341"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop15 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 74; --y: 39; --o: 0.6085176773865959; --a: 1.1647324962389058; --d: -0.08643048534587949; --s: 0.5449421802860281"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drop16 = '<svg class="rain__drop" preserveAspectRatio="xMinYMin" viewBox="0 0 5 50" style="--x: 3; --y: 78; --o: 0.7413154227917105; --a: 0.7082137175865917; --d: 0.931629538260506; --s: 0.48335465500642294"><path stroke="none" d="M 2.5,0 C 2.6949458,3.5392017 3.344765,20.524571 4.4494577,30.9559 5.7551357,42.666753 4.5915685,50 2.5,50 0.40843152,50 -0.75513565,42.666753 0.55054234,30.9559 1.655235,20.524571 2.3050542,3.5392017 2.5,0 Z"></path></svg>';
|
||
|
let drops = drop1 + drop2 + drop3 + drop4 + drop5 + drop6 + drop7 + drop8 + drop9 + drop10;
|
||
|
drops += drop11 + drop12 + drop13 + drop14 + drop15 + drop16;
|
||
|
effect.innerHTML += drops;
|
||
|
}
|
||
|
}
|
||
|
function Remove_Rain(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-rain-dynamic-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// effects/dark-dynamic-random-circle.ts
|
||
|
var DarkTheme_Random_Circle_Background_Property = "radial-gradient(ellipse at bottom, #1b2735 20%, #090a0f 100%)";
|
||
|
function Add_RandomCircle(dynamicBackgroundContainer) {
|
||
|
let effectScript;
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-dt-random-circle-dynamic-effect" });
|
||
|
effect.createEl("canvas");
|
||
|
let code = `
|
||
|
var odb_random_circle_ctx;
|
||
|
var odb_random_circle_grd;
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Start() {
|
||
|
var canvas = document.querySelector("div.odb-dt-random-circle-dynamic-effect canvas");
|
||
|
canvas.width = window.innerWidth;
|
||
|
canvas.height = window.innerHeight;
|
||
|
|
||
|
odb_random_circle_ctx = canvas.getContext("2d");
|
||
|
|
||
|
odb_random_circle_grd = odb_random_circle_ctx.createLinearGradient(0, window.innerHeight, 0, 0);
|
||
|
|
||
|
odb_random_circle_ctx.fillStyle = odb_random_circle_grd;
|
||
|
odb_random_circle_ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
|
||
|
Obsidian_Dynamic_Background_Animate();
|
||
|
}
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Firework(x, y) {
|
||
|
this.x = x;
|
||
|
this.y = y;
|
||
|
this.radius = 5;
|
||
|
this.time = 0;
|
||
|
this.lifespan = Math.random()*180 + 150;
|
||
|
|
||
|
this.draw = function() {
|
||
|
odb_random_circle_ctx.beginPath();
|
||
|
odb_random_circle_ctx.arc(this.x, window.innerHeight - this.y, this.radius, 0, 2*Math.PI, false);
|
||
|
var alpha = (this.lifespan - this.time)/this.lifespan;
|
||
|
odb_random_circle_ctx.strokeStyle = "rgba(255, 255, 255, " + alpha + ")";
|
||
|
odb_random_circle_ctx.stroke();
|
||
|
}
|
||
|
|
||
|
this.update = function() {
|
||
|
if (this.time < this.lifespan) {
|
||
|
this.radius += .25;
|
||
|
this.time += 1;
|
||
|
this.draw();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var fireworks = [];
|
||
|
var time = 0;
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Animate() {
|
||
|
odb_random_circle_ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
odb_random_circle_ctx.fillStyle = odb_random_circle_grd;
|
||
|
odb_random_circle_ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
|
||
|
if (time % Math.floor(Math.random()*100 + 40) == 0) {
|
||
|
var x = Math.floor(Math.random()*window.innerWidth);
|
||
|
var y = Math.floor(Math.random()*window.innerHeight);
|
||
|
fireworks.push(new Obsidian_Dynamic_Background_Firework(x, y));
|
||
|
}
|
||
|
|
||
|
fireworks.forEach(firework => {
|
||
|
firework.update();
|
||
|
if ((firework.time - firework.explosionTime) > 20) {
|
||
|
for (var i = 0; i < fireworks.length; i++) {
|
||
|
if (firework === fireworks[i]) {
|
||
|
delete fireworks[i];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
time += 1;
|
||
|
|
||
|
if (Obsidian_Dynamic_Background_Animate)
|
||
|
requestAnimationFrame(Obsidian_Dynamic_Background_Animate);
|
||
|
}
|
||
|
|
||
|
Obsidian_Dynamic_Background_Start();
|
||
|
`;
|
||
|
effectScript = effect.createEl("script");
|
||
|
effectScript.textContent = code;
|
||
|
}
|
||
|
}
|
||
|
function Remove_RandomCircle(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-random-circle-dynamic-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
Unload_Effect_Script();
|
||
|
}
|
||
|
function Unload_Effect_Script() {
|
||
|
window["Obsidian_Dynamic_Background_Start"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Firework"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Animate"] = null;
|
||
|
}
|
||
|
|
||
|
// effects/light-dynamic-random-circle.ts
|
||
|
var LightTheme_Random_Circle_Background_Property = "linear-gradient(0deg, rgba(255,255,255,1) 62%, rgba(230,244,255,1) 100%)";
|
||
|
function Add_RandomCircle_Light(dynamicBackgroundContainer) {
|
||
|
let effectScript;
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-lt-random-circle-dynamic-effect" });
|
||
|
effect.createEl("canvas");
|
||
|
let code = `
|
||
|
var odb_random_circle_ctx;
|
||
|
var odb_random_circle_grd;
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Start() {
|
||
|
var canvas = document.querySelector("div.odb-lt-random-circle-dynamic-effect canvas");
|
||
|
canvas.width = window.innerWidth;
|
||
|
canvas.height = window.innerHeight;
|
||
|
|
||
|
odb_random_circle_ctx = canvas.getContext("2d");
|
||
|
|
||
|
odb_random_circle_grd = odb_random_circle_ctx.createLinearGradient(0, window.innerHeight, 0, 0);
|
||
|
|
||
|
odb_random_circle_ctx.fillStyle = odb_random_circle_grd;
|
||
|
odb_random_circle_ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
|
||
|
Obsidian_Dynamic_Background_Animate();
|
||
|
}
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Firework(x, y) {
|
||
|
this.x = x;
|
||
|
this.y = y;
|
||
|
this.radius = 5;
|
||
|
this.time = 0;
|
||
|
this.lifespan = Math.random()*180 + 150;
|
||
|
|
||
|
this.draw = function() {
|
||
|
odb_random_circle_ctx.beginPath();
|
||
|
odb_random_circle_ctx.arc(this.x, window.innerHeight - this.y, this.radius, 0, 2*Math.PI, false);
|
||
|
var alpha = (this.lifespan - this.time)/this.lifespan;
|
||
|
odb_random_circle_ctx.strokeStyle = "rgba(0, 128, 255, " + alpha + ")";
|
||
|
odb_random_circle_ctx.stroke();
|
||
|
}
|
||
|
|
||
|
this.update = function() {
|
||
|
if (this.time < this.lifespan) {
|
||
|
this.radius += .25;
|
||
|
this.time += 1;
|
||
|
this.draw();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var fireworks = [];
|
||
|
var time = 0;
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Animate() {
|
||
|
odb_random_circle_ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
odb_random_circle_ctx.fillStyle = odb_random_circle_grd;
|
||
|
odb_random_circle_ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
|
||
|
|
||
|
if (time % Math.floor(Math.random()*100 + 40) == 0) {
|
||
|
var x = Math.floor(Math.random()*window.innerWidth);
|
||
|
var y = Math.floor(Math.random()*window.innerHeight);
|
||
|
fireworks.push(new Obsidian_Dynamic_Background_Firework(x, y));
|
||
|
}
|
||
|
|
||
|
fireworks.forEach(firework => {
|
||
|
firework.update();
|
||
|
if ((firework.time - firework.explosionTime) > 20) {
|
||
|
for (var i = 0; i < fireworks.length; i++) {
|
||
|
if (firework === fireworks[i]) {
|
||
|
delete fireworks[i];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
time += 1;
|
||
|
|
||
|
if (Obsidian_Dynamic_Background_Animate)
|
||
|
requestAnimationFrame(Obsidian_Dynamic_Background_Animate);
|
||
|
}
|
||
|
|
||
|
Obsidian_Dynamic_Background_Start();
|
||
|
`;
|
||
|
effectScript = effect.createEl("script");
|
||
|
effectScript.textContent = code;
|
||
|
}
|
||
|
}
|
||
|
function Remove_RandomCircle_Light(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-lt-random-circle-dynamic-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
Unload_Effect_Script2();
|
||
|
}
|
||
|
function Unload_Effect_Script2() {
|
||
|
window["Obsidian_Dynamic_Background_Start"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Firework"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Animate"] = null;
|
||
|
}
|
||
|
|
||
|
// effects/light-dynamic-wave.ts
|
||
|
var LightTheme_Wave_Background_Property = "linear-gradient(0deg, rgba(255,255,255,1) 60%, rgba(201,233,255,1) 100%)";
|
||
|
function Add_Wave_Light(dynamicBackgroundContainer) {
|
||
|
let effectScript;
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-lt-wave-effect" });
|
||
|
effect.createEl("div", { cls: "ocean" });
|
||
|
let code = `
|
||
|
function Obsidian_Dynamic_Background_ShowWave() {
|
||
|
var ocean = document.querySelector("div.odb-lt-wave-effect div.ocean"),
|
||
|
waveWidth = 10,
|
||
|
waveCount = Math.floor(window.innerWidth/waveWidth),
|
||
|
docFrag = document.createDocumentFragment();
|
||
|
|
||
|
for(var i = 0; i < waveCount; i++){
|
||
|
var wave = document.createElement("div");
|
||
|
wave.className += " wave-0723";
|
||
|
docFrag.appendChild(wave);
|
||
|
wave.style.left = i * waveWidth + "px";
|
||
|
wave.style.webkitAnimationDelay = (i/100) + "s";
|
||
|
}
|
||
|
|
||
|
ocean.appendChild(docFrag);
|
||
|
}
|
||
|
|
||
|
Obsidian_Dynamic_Background_ShowWave();
|
||
|
`;
|
||
|
effectScript = effect.createEl("script");
|
||
|
effectScript.textContent = code;
|
||
|
}
|
||
|
}
|
||
|
function Remove_Wave_Light(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-lt-wave-effect");
|
||
|
if (effect) {
|
||
|
effect.remove();
|
||
|
}
|
||
|
Unload_Effect_Script3();
|
||
|
}
|
||
|
function Unload_Effect_Script3() {
|
||
|
window["Obsidian_Dynamic_Background_ShowWave"] = null;
|
||
|
}
|
||
|
|
||
|
// effects/dark-dynamic-digital-rain.ts
|
||
|
var DarkTheme_Digital_Rain_Background_Property = "radial-gradient(ellipse at bottom, #1b2735 20%, #090a0f 100%)";
|
||
|
function Add_DigitalRain(dynamicBackgroundContainer) {
|
||
|
let effectScript;
|
||
|
if (dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.createEl("div", { cls: "odb-dt-digital-rain-dynamic-effect" });
|
||
|
effect.createEl("canvas");
|
||
|
let code = `
|
||
|
var odb_digital_rain_canvas
|
||
|
var odb_digital_rain_ctx;
|
||
|
var odb_digital_rain_grd;
|
||
|
var odb_digital_rain_digitals = "1001101010110101010101010010101010101011101111010101010110101010101010101110010101";
|
||
|
var odb_digital_rain_font_size = 15;
|
||
|
var odb_digital_rain_columns; //number of columns for the rain
|
||
|
var odb_digital_rain_drops = []; //an array of drops - one per column
|
||
|
var odb_digital_rain_interval;
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Draw(){
|
||
|
odb_digital_rain_ctx.fillStyle = "rgba(0, 0, 0, 0.1)";
|
||
|
odb_digital_rain_ctx.fillRect(0, 0, odb_digital_rain_canvas.width, odb_digital_rain_canvas.height);
|
||
|
|
||
|
odb_digital_rain_ctx.fillStyle = "#0F0";
|
||
|
odb_digital_rain_ctx.font = odb_digital_rain_font_size + "px arial";
|
||
|
|
||
|
for(var i = 0; i < odb_digital_rain_drops.length; i++)
|
||
|
{
|
||
|
var digital = odb_digital_rain_digitals[Math.floor(Math.random()*odb_digital_rain_digitals.length)];
|
||
|
|
||
|
odb_digital_rain_ctx.fillText(digital, i*odb_digital_rain_font_size, odb_digital_rain_drops[i]*odb_digital_rain_font_size);
|
||
|
|
||
|
if(odb_digital_rain_drops[i]*odb_digital_rain_font_size > odb_digital_rain_canvas.height && Math.random() > 0.975)
|
||
|
odb_digital_rain_drops[i] = 0;
|
||
|
|
||
|
odb_digital_rain_drops[i]++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Start() {
|
||
|
odb_digital_rain_canvas = document.querySelector("div.odb-dt-digital-rain-dynamic-effect canvas");
|
||
|
odb_digital_rain_canvas.width = window.innerWidth;
|
||
|
odb_digital_rain_canvas.height = window.innerHeight;
|
||
|
|
||
|
odb_digital_rain_ctx = odb_digital_rain_canvas.getContext("2d");
|
||
|
odb_digital_rain_ctx.globalAlpha = 1;
|
||
|
odb_digital_rain_ctx.globalCompositeOperation = "xor";
|
||
|
|
||
|
odb_digital_rain_columns = odb_digital_rain_canvas.width/odb_digital_rain_font_size;
|
||
|
|
||
|
for(var x = 0; x < odb_digital_rain_columns; x++)
|
||
|
odb_digital_rain_drops[x] = 1;
|
||
|
}
|
||
|
|
||
|
function Obsidian_Dynamic_Background_SetBrightness(brightness) {
|
||
|
odb_digital_rain_canvas.width = window.innerWidth; // clear canvas
|
||
|
odb_digital_rain_ctx.globalCompositeOperation = "xor";
|
||
|
odb_digital_rain_ctx.globalAlpha = brightness;
|
||
|
}
|
||
|
|
||
|
function Obsidian_Dynamic_Background_Clear() {
|
||
|
clearInterval(odb_digital_rain_interval);
|
||
|
}
|
||
|
|
||
|
Obsidian_Dynamic_Background_Start();
|
||
|
odb_digital_rain_interval = setInterval(Obsidian_Dynamic_Background_Draw, 80);
|
||
|
`;
|
||
|
effectScript = effect.createEl("script");
|
||
|
effectScript.textContent = code;
|
||
|
}
|
||
|
}
|
||
|
function Remove_DigitalRain(dynamicBackgroundContainer) {
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-digital-rain-dynamic-effect");
|
||
|
if (effect) {
|
||
|
CallClear(dynamicBackgroundContainer);
|
||
|
effect.remove();
|
||
|
}
|
||
|
Unload_Effect_Script4();
|
||
|
}
|
||
|
function Unload_Effect_Script4() {
|
||
|
window["Obsidian_Dynamic_Background_Start"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Draw"] = null;
|
||
|
window["Obsidian_Dynamic_Background_Clear"] = null;
|
||
|
window["Obsidian_Dynamic_Background_SetBrightness"] = null;
|
||
|
}
|
||
|
function CallClear(dynamicBackgroundContainer) {
|
||
|
let effectScript;
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-digital-rain-dynamic-effect");
|
||
|
let code = `
|
||
|
Obsidian_Dynamic_Background_Clear();
|
||
|
`;
|
||
|
effectScript = effect.createEl("script");
|
||
|
effectScript.textContent = code;
|
||
|
}
|
||
|
function SetBrightness(dynamicBackgroundContainer, brightness) {
|
||
|
let setBrightnessScript;
|
||
|
let setBrightnessScriptContainer;
|
||
|
let effect = dynamicBackgroundContainer.find("div.odb-dt-digital-rain-dynamic-effect");
|
||
|
if (effect) {
|
||
|
let setBrightnessScriptContainer2 = dynamicBackgroundContainer.find("div.odb-dt-digital-rain-dynamic-effect div.set-brightness-script-container");
|
||
|
if (setBrightnessScriptContainer2) {
|
||
|
setBrightnessScriptContainer2.remove();
|
||
|
}
|
||
|
setBrightnessScriptContainer2 = effect.createEl("div", { cls: "div.set-brightness-script-container" });
|
||
|
let code = "Obsidian_Dynamic_Background_SetBrightness(" + brightness + ")";
|
||
|
setBrightnessScript = setBrightnessScriptContainer2.createEl("script");
|
||
|
setBrightnessScript.textContent = code;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// main.ts
|
||
|
var DEFAULT_SETTINGS = {
|
||
|
dynamicEffect: 1 /* Dark_StarSky */,
|
||
|
digitalRainBrightness: 0.7,
|
||
|
enableDynamicEffect: true,
|
||
|
backgroundImageFile: "",
|
||
|
blur: 0
|
||
|
};
|
||
|
var DynamicBackgroundPlugin = class extends import_obsidian.Plugin {
|
||
|
onload() {
|
||
|
return __async(this, null, function* () {
|
||
|
console.log("loading dynamic background plugin...");
|
||
|
this.preDynamicEffect = -1 /* Unknown */;
|
||
|
yield this.loadSettings();
|
||
|
this.addSettingTab(new DynamicBackgroundSettingTab(this.app, this));
|
||
|
this.app.workspace.onLayoutReady(() => {
|
||
|
this.AddDynamicBackgroundContainer();
|
||
|
this.SetDynamicBackgroundContainerBgProperty();
|
||
|
if (this.settings.enableDynamicEffect == true) {
|
||
|
this.AddDynamicBackgroundEffect(this.settings.dynamicEffect);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
onunload() {
|
||
|
console.log("unloading dynamic background plugin...");
|
||
|
this.RemoveDynamicBackgroundContainer();
|
||
|
}
|
||
|
loadSettings() {
|
||
|
return __async(this, null, function* () {
|
||
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
|
||
|
});
|
||
|
}
|
||
|
saveSettings() {
|
||
|
return __async(this, null, function* () {
|
||
|
yield this.saveData(this.settings);
|
||
|
});
|
||
|
}
|
||
|
AddDynamicBackgroundContainer() {
|
||
|
let div_root = app.workspace.containerEl.find("div.workspace > div.mod-root");
|
||
|
this.dynamicBackgroundContainer = null;
|
||
|
if (div_root) {
|
||
|
this.dynamicBackgroundContainer = div_root.createEl("div", { cls: "rh-obsidian-dynamic-background-container" });
|
||
|
this.wallpaperCover = this.dynamicBackgroundContainer.createEl("div", { cls: "rh-wallpaper-cover" });
|
||
|
this.SetWallpaperBlur();
|
||
|
}
|
||
|
}
|
||
|
SetWallpaperBlur() {
|
||
|
let value = "blur(" + this.settings.blur.toString() + "px)";
|
||
|
this.wallpaperCover.style.setProperty("filter", value);
|
||
|
}
|
||
|
RemoveDynamicBackgroundContainer() {
|
||
|
if (this.dynamicBackgroundContainer) {
|
||
|
this.dynamicBackgroundContainer.remove();
|
||
|
this.dynamicBackgroundContainer = null;
|
||
|
}
|
||
|
}
|
||
|
SetDynamicBackgroundContainerBgProperty() {
|
||
|
return __async(this, null, function* () {
|
||
|
if (this.dynamicBackgroundContainer == null)
|
||
|
return;
|
||
|
let backgroundImageAlreadySet = false;
|
||
|
let imageFullFilename = "";
|
||
|
try {
|
||
|
imageFullFilename = this.app.vault.adapter.getResourcePath(this.settings.backgroundImageFile);
|
||
|
} catch (e) {
|
||
|
}
|
||
|
if (imageFullFilename != "") {
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", 'url("' + imageFullFilename + '"');
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background-size", "cover");
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background-position", "center");
|
||
|
backgroundImageAlreadySet = true;
|
||
|
} else {
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background");
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background-size");
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background-position");
|
||
|
}
|
||
|
if (backgroundImageAlreadySet == false) {
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background");
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background-size");
|
||
|
this.dynamicBackgroundContainer.style.removeProperty("background-position");
|
||
|
if (this.settings.enableDynamicEffect == false)
|
||
|
return;
|
||
|
switch (this.settings.dynamicEffect) {
|
||
|
case 1 /* Dark_StarSky */:
|
||
|
break;
|
||
|
case 2 /* Dark_Snow */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", DarkTheme_Snow_Background_Property);
|
||
|
break;
|
||
|
case 3 /* Dark_Rain */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", DarkTheme_Rain_Background_Property);
|
||
|
break;
|
||
|
case 4 /* Dark_RandomCircle */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", DarkTheme_Random_Circle_Background_Property);
|
||
|
break;
|
||
|
case 40 /* Light_RandomCircle */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", LightTheme_Random_Circle_Background_Property);
|
||
|
break;
|
||
|
case 41 /* Light_Wave */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", LightTheme_Wave_Background_Property);
|
||
|
break;
|
||
|
case 5 /* Dark_DigitalRain */:
|
||
|
this.dynamicBackgroundContainer.style.setProperty("background", DarkTheme_Digital_Rain_Background_Property);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
SetDigitalRainBrightnessHelper() {
|
||
|
if (this.dynamicBackgroundContainer) {
|
||
|
SetBrightness(this.dynamicBackgroundContainer, this.settings.digitalRainBrightness);
|
||
|
}
|
||
|
}
|
||
|
AddDynamicBackgroundEffect(effect) {
|
||
|
switch (effect) {
|
||
|
case 1 /* Dark_StarSky */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_StarSky(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 2 /* Dark_Snow */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_Snow(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 3 /* Dark_Rain */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_Rain(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 5 /* Dark_DigitalRain */:
|
||
|
if (this.dynamicBackgroundContainer) {
|
||
|
Add_DigitalRain(this.dynamicBackgroundContainer);
|
||
|
this.SetDigitalRainBrightnessHelper();
|
||
|
}
|
||
|
break;
|
||
|
case 4 /* Dark_RandomCircle */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_RandomCircle(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 40 /* Light_RandomCircle */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_RandomCircle_Light(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 41 /* Light_Wave */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Add_Wave_Light(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
RemoveDynamicBackgroundEffect(effect) {
|
||
|
if (effect == -1 /* Unknown */)
|
||
|
return;
|
||
|
switch (effect) {
|
||
|
case 1 /* Dark_StarSky */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_StarSky(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 2 /* Dark_Snow */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_Snow(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 3 /* Dark_Rain */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_Rain(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 5 /* Dark_DigitalRain */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_DigitalRain(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 4 /* Dark_RandomCircle */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_RandomCircle(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 40 /* Light_RandomCircle */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_RandomCircle_Light(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
case 41 /* Light_Wave */:
|
||
|
if (this.dynamicBackgroundContainer)
|
||
|
Remove_Wave_Light(this.dynamicBackgroundContainer);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
var DynamicBackgroundSettingTab = class extends import_obsidian.PluginSettingTab {
|
||
|
constructor(app2, plugin) {
|
||
|
super(app2, plugin);
|
||
|
this.plugin = plugin;
|
||
|
}
|
||
|
display() {
|
||
|
const { containerEl } = this;
|
||
|
containerEl.empty();
|
||
|
containerEl.createEl("h2", { text: "Dynamic Background Plugin - Settings" });
|
||
|
new import_obsidian.Setting(containerEl).setName("Dynamic Effect").setDesc("Select a dynamic effect").addDropdown((dropdown) => dropdown.addOption(5 /* Dark_DigitalRain */.toString(), "Dark - Matrix / Digital Rain").addOption(3 /* Dark_Rain */.toString(), "Dark - Rain").addOption(4 /* Dark_RandomCircle */.toString(), "Dark - Random Circle").addOption(2 /* Dark_Snow */.toString(), "Dark - Snow").addOption(1 /* Dark_StarSky */.toString(), "Dark - Star Sky").addOption(40 /* Light_RandomCircle */.toString(), "Light - Random Circle").addOption(41 /* Light_Wave */.toString(), "Light - Wave").setValue(this.plugin.settings.dynamicEffect.toString()).onChange((value) => __async(this, null, function* () {
|
||
|
this.plugin.preDynamicEffect = this.plugin.settings.dynamicEffect;
|
||
|
this.plugin.settings.dynamicEffect = Number(value);
|
||
|
yield this.plugin.saveSettings();
|
||
|
this.plugin.RemoveDynamicBackgroundEffect(this.plugin.preDynamicEffect);
|
||
|
if (this.plugin.settings.enableDynamicEffect == true)
|
||
|
this.plugin.AddDynamicBackgroundEffect(this.plugin.settings.dynamicEffect);
|
||
|
this.plugin.SetDynamicBackgroundContainerBgProperty();
|
||
|
this.display();
|
||
|
})));
|
||
|
if (this.plugin.settings.dynamicEffect == 5 /* Dark_DigitalRain */) {
|
||
|
new import_obsidian.Setting(containerEl).setName("Brightness").setDesc("Set Digital Rain Brightness.").addSlider((tc) => {
|
||
|
tc.setDynamicTooltip().setLimits(0.5, 1, 0.01).setValue(this.plugin.settings.digitalRainBrightness).onChange((value) => __async(this, null, function* () {
|
||
|
this.plugin.settings.digitalRainBrightness = value;
|
||
|
this.plugin.SetDigitalRainBrightnessHelper();
|
||
|
yield this.plugin.saveSettings();
|
||
|
}));
|
||
|
});
|
||
|
}
|
||
|
new import_obsidian.Setting(containerEl).setName("Enable Dynamic Effect").setDesc("Enable or disable dynamic effect").addToggle((tc) => tc.setValue(this.plugin.settings.enableDynamicEffect).onChange((value) => __async(this, null, function* () {
|
||
|
this.plugin.settings.enableDynamicEffect = value;
|
||
|
yield this.plugin.saveSettings();
|
||
|
if (this.plugin.settings.enableDynamicEffect == false) {
|
||
|
this.plugin.RemoveDynamicBackgroundEffect(this.plugin.settings.dynamicEffect);
|
||
|
} else {
|
||
|
this.plugin.AddDynamicBackgroundEffect(this.plugin.settings.dynamicEffect);
|
||
|
}
|
||
|
})));
|
||
|
new import_obsidian.Setting(containerEl).setName("Static Wallpaper Image").setDesc("Image file in Vault. Please use the relative path of the image file inside Vault.").addTextArea((text) => text.setValue(this.plugin.settings.backgroundImageFile).setPlaceholder("Example: attachments/moon.jpg or wallpapers/green.png").then((cb) => {
|
||
|
cb.inputEl.style.width = "100%";
|
||
|
cb.inputEl.rows = 5;
|
||
|
}).onChange((value) => __async(this, null, function* () {
|
||
|
this.plugin.settings.backgroundImageFile = value;
|
||
|
yield this.plugin.saveSettings();
|
||
|
this.plugin.SetDynamicBackgroundContainerBgProperty();
|
||
|
})));
|
||
|
new import_obsidian.Setting(containerEl).setName("Blur").setDesc("The blurriness of the wallpaper, 0 means no blur.").addSlider((tc) => {
|
||
|
tc.setDynamicTooltip().setLimits(0, 100, 1).setValue(this.plugin.settings.blur).onChange((value) => __async(this, null, function* () {
|
||
|
this.plugin.settings.blur = value;
|
||
|
yield this.plugin.saveSettings();
|
||
|
this.plugin.SetWallpaperBlur();
|
||
|
}));
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
/* nosourcemap */
|