Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-v3-0324· DeepSeekHugging Face LMArena Human Preference 140K

generate a text mask using an svg for the text and an image. Include the ability to…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash’s answer.
  1. User

    generate a text mask using an svg for the text and an image. Include the ability to dynamically change font size.

  2. DeepSeek Assistant

    SVG Text Mask with Dynamic Font Size

    Here's an SVG that creates a text mask over an image, with the ability to dynamically change the font size using JavaScript:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Dynamic Text Mask</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                display: flex;
                flex-direction: column;
                align-items: center;
                padding: 20px;
            }
            .container {
                position: relative;
                width: 600px;
                height: 400px;
                margin-bottom: 20px;
            }
            .controls {
                margin-top: 20px;
                display: flex;
                align-items: center;
                gap: 15px;
            }
            label {
                font-weight: bold;
            }
            input {
                width: 200px;
            }
        </style>
    </head>
    <body>
        <h1>SVG Text Mask with Dynamic Font Size</h1>
        
        <div class="container">
            <!-- The image that will be masked -->
            <img id="background-image" src="https://source.unsplash.com/random/600x400" alt="Background" style="width: 100%; height: 100%; object-fit: cover;">
            
            <!-- SVG for the text mask -->
            <svg id="text-mask" width="100%" height="100%" viewBox="0 0 600 400" style="position: absolute; top: 0; left: 0;">
                <defs>
                    <mask id="mask" x="0" y="0" width="100%" height="100%">
                        <rect x="0" y="0" width="100%" height="100%" fill="white"/>
                        <text id="mask-text" x="50%" y="50%" 
                              font-family="Arial" 
                              font-weight="bold" 
                              text-anchor="middle" 
                              dominant-baseline="middle"
                              fill="black">TEXT MASK</text>
                    </mask>
                </defs>
                
                <!-- This rectangle will show the image through the text mask -->
                <rect x="0" y="0" width="100%" height="100%" mask="url(#mask)" fill="url(#image-pattern)"/>
                
                <!-- Pattern definition for the image -->
                <defs>
                    <pattern id="image-pattern" patternUnits="userSpaceOnUse" width="600" height="400">
                        <image href="https://source.unsplash.com/random/600x400" width="600" height="400"/>
                    </pattern>
                </defs>
            </svg>
        </div>
        
        <div class="controls">
            <label for="font-size">Font Size:</label>
            <input type="range" id="font-size" min="20" max="200" value="80" step="1">
            <span id="font-size-value">80px</span>
        </div>
        
        <script>
            const fontSizeSlider = document.getElementById('font-size');
            const fontSizeValue = document.getElementById('font-size-value');
            const maskText = document.getElementById('mask-text');
            
            // Update font size when slider changes
            fontSizeSlider.addEventListener('input', function() {
                const size = this.value;
                maskText.setAttribute('font-size', size);
                fontSizeValue.textContent = `${size}px`;
            });
            
            // You can also change the text dynamically if needed
            // maskText.textContent = "NEW TEXT";
        </script>
    </body>
    </html>
    

    How This Works:

    1. Structure:

      • The image is displayed as a background
      • An SVG overlay contains the text mask
      • Controls allow adjusting the font size
    2. Masking Technique:

      • The SVG creates a mask with white rectangle (shows content) and black text (hides content)
      • A rectangle with this mask applied shows the image only where the mask is white (around the text)
    3. Dynamic Features:

      • The font size can be adjusted with the slider
      • The text content can also be changed via JavaScript (commented example included)
    4. Customization Options:

      • Change the image URL to use your own image
      • Modify the text content, font family, or position
      • Adjust the size range in the slider (currently 20-200px)

    To use your own image, replace the src attribute in both the <img> tag and the <image> tag within the SVG pattern.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.