You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, auraColor = '#FFD700', symbol = '🍀', guardianOpacity = 70, guardianText = 'Страж удачи') {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// Set canvas dimensions to match the original image
canvas.width = originalImg.width;
canvas.height = originalImg.height;
// Draw the original image as the background
ctx.drawImage(originalImg, 0, 0);
const cx = canvas.width / 2;
const cy = canvas.height / 2;
const minDim = Math.min(canvas.width, canvas.height);
const radius = minDim * 0.45;
// Ensure parameters are parsed correctly
const parsedOp = parseInt(guardianOpacity);
const opacityVal = isNaN(parsedOp) ? 70 : Math.max(0, Math.min(100, parsedOp));
// Draw a subtle dark vignette to make the glowing magical ward pop out
const grad = ctx.createRadialGradient(cx, cy, radius * 0.5, cx, cy, Math.max(canvas.width, canvas.height) * 0.8);
grad.addColorStop(0, 'rgba(0, 0, 0, 0)');
grad.addColorStop(1, `rgba(0, 0, 0, ${Math.min(0.8, opacityVal / 100)})`);
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.globalAlpha = opacityVal / 100;
// Guardian Magic Ward Setup
ctx.strokeStyle = auraColor;
ctx.lineWidth = Math.max(2, radius * 0.015);
ctx.shadowColor = auraColor;
ctx.shadowBlur = Math.max(10, radius * 0.05);
// 1. Array of interlocking Inner Circles (Seed of Luck / Mandala)
const R_inner = radius * 0.85;
const r = R_inner / 2;
for (let i = 0; i < 8; i++) {
const angle = i * Math.PI / 4;
const x = cx + Math.cos(angle) * r;
const y = cy + Math.sin(angle) * r;
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.stroke();
}
// 2. Main Outer solid band
ctx.beginPath();
ctx.arc(cx, cy, radius, 0, Math.PI * 2);
ctx.stroke();
// 3. Middle dashed band for intricate style
ctx.setLineDash([Math.max(2, radius * 0.02), Math.max(4, radius * 0.04)]);
ctx.beginPath();
ctx.arc(cx, cy, radius * 0.95, 0, Math.PI * 2);
ctx.stroke();
ctx.setLineDash([]); // Reset dashed strokes backwards
// 4. Solid inner band
ctx.beginPath();
ctx.arc(cx, cy, radius * 0.85, 0, Math.PI * 2);
ctx.stroke();
// 5. Outer Rectangular Protective Frame along the borders
const frameWidth = Math.max(4, minDim * 0.02);
ctx.lineWidth = frameWidth;
ctx.strokeRect(frameWidth / 2, frameWidth / 2, canvas.width - frameWidth, canvas.height - frameWidth);
// 6. Draw Guardian Symbols on the ring, oriented outward
const symbolDist = radius * 0.9;
const symbolSize = radius * 0.10;
ctx.font = `${symbolSize}px sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = auraColor;
ctx.shadowColor = auraColor; // Apply aura glow to symbols too
ctx.shadowBlur = Math.max(5, radius * 0.03);
for (let i = 0; i < 8; i++) {
const angle = i * Math.PI / 4;
const x = cx + Math.cos(angle) * symbolDist;
const y = cy + Math.sin(angle) * symbolDist;
ctx.save();
ctx.translate(x, y);
ctx.rotate(angle + Math.PI / 2); // Orient symbols radially
ctx.fillText(symbol, 0, 0);
ctx.restore();
}
ctx.restore();
// 7. Render Guardian Title text clearly at the bottom center if provided
if (guardianText && guardianText.trim() !== '') {
const textSize = Math.max(20, minDim * 0.08);
ctx.font = `bold ${textSize}px sans-serif`;
ctx.shadowColor = 'rgba(0, 0, 0, 0.9)';
ctx.shadowBlur = Math.max(6, textSize * 0.2);
ctx.fillStyle = auraColor;
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
const textY = canvas.height - Math.max(10, canvas.height * 0.03);
ctx.lineWidth = Math.max(2, textSize * 0.04);
ctx.strokeStyle = '#000';
// Stroke text twice to form a bold unreadable-proof boundary overlay, then fill
ctx.strokeText(guardianText, cx, textY);
ctx.strokeText(guardianText, cx, textY);
ctx.fillText(guardianText, cx, textY);
}
return canvas;
}
Apply Changes