Refactor earthday.js: move flowerColors definition to a constant and use it in flower generation
This commit is contained in:
@@ -3,6 +3,8 @@ const config = window.SeasonalsPluginConfig?.EarthDay || {};
|
||||
const enabled = config.EnableEarthDay !== undefined ? config.EnableEarthDay : true;
|
||||
const vineCount = config.VineCount || 4;
|
||||
|
||||
const flowerColors = ['#FF69B4', '#FFD700', '#87CEFA', '#FF4500', '#BA55D3', '#FFA500', '#FF1493'];
|
||||
|
||||
let msgPrinted = false;
|
||||
|
||||
// Toggle Function
|
||||
@@ -66,12 +68,11 @@ function createElements() {
|
||||
}
|
||||
|
||||
// Generate Flowers
|
||||
const colors = ['#FF69B4', '#FFD700', '#87CEFA', '#FF4500', '#BA55D3', '#FFA500', '#FF1493'];
|
||||
const flowerCount = Math.max(10, vineCount * 15);
|
||||
for (let i = 0; i < flowerCount; i++) {
|
||||
const x = 10 + Math.random() * (w - 20);
|
||||
const y = hSVG * 0.1 + Math.random() * (hSVG * 0.5);
|
||||
const col = colors[Math.floor(Math.random() * colors.length)];
|
||||
const col = flowerColors[Math.floor(Math.random() * flowerColors.length)];
|
||||
|
||||
paths += `<path d="M ${x} ${hSVG} Q ${x - 5 + Math.random() * 10} ${y+15} ${x} ${y}" stroke="#006400" stroke-width="1.5" fill="none"/>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user