From 9686c9cb2ddd6a35c7a91e41c20f7b15c8e40a3e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Thu, 9 May 2024 00:46:32 -0400 Subject: [PATCH] Fix --- commands/edit-image/old-photo.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/commands/edit-image/old-photo.js b/commands/edit-image/old-photo.js index 2b43d575..f63f59dc 100644 --- a/commands/edit-image/old-photo.js +++ b/commands/edit-image/old-photo.js @@ -47,24 +47,22 @@ module.exports = class OldPhotoCommand extends Command { for (let i = 0; i < count; i++) { const x = Math.random() * width; const y = Math.random() * height; - const radius = 30 + (Math.random() * 70); - const r = 100 + (Math.random() * 55); - const g = 85 + (Math.random() * 70); - const b = 50 + (Math.random() * 30); - const color = `rgba(${r}, ${g}, ${b}, ${0.1 + (Math.random() * 0.4)})`; + const radius = 40 + Math.random() * 80; + const type = Math.random() > 0.5 ? 'coffee' : 'water'; ctx.beginPath(); - const angleStep = (Math.PI * 2) / 10; - for (let angle = 0; angle < Math.PI * 2; angle += angleStep) { - const modRadius = radius + (Math.random() * 15); - ctx.lineTo(x + (modRadius * Math.cos(angle)), y + (modRadius * Math.sin(angle))); + ctx.moveTo(x + radius * 0.6, y); + for (let angle = 0; angle < 360; angle += Math.random() * 45) { + const angleRad = (angle * Math.PI) / 180; + const nextAngleRad = ((angle + Math.random() * 45) * Math.PI) / 180; + const arcRadius = radius * (0.6 + Math.random() * 0.4); + ctx.arc(x, y, arcRadius, angleRad, nextAngleRad, false); } ctx.closePath(); + const baseColor = type === 'coffee' ? [101, 67, 33] : [173, 216, 230]; + const opacity = type === 'coffee' ? 0.6 : 0.3; const gradient = ctx.createRadialGradient(x, y, radius * 0.1, x, y, radius); - gradient.addColorStop(0, color); - const r2 = 100 + (Math.random() * 55); - const g2 = 85 + (Math.random() * 70); - const b2 = 50 + (Math.random() * 30); - gradient.addColorStop(1, `rgba(${r2}, ${g2}, ${b2}, 0)`); + gradient.addColorStop(0, `rgba(${baseColor[0]}, ${baseColor[1]}, ${baseColor[2]}, ${opacity})`); + gradient.addColorStop(1, `rgba(${baseColor[0]}, ${baseColor[1]}, ${baseColor[2]}, 0)`); ctx.fillStyle = gradient; ctx.fill(); }