Please bookmark this page to avoid losing your image tool!

Image Line Drawer And Eraser

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, linesToDraw = 5, linesToErase = 5, lineWidth = 2, lineColor = 'black', orientation = 'horizontal') {
    // Sanitize parameters to ensure they are valid numbers and have sensible minimums
    const numLinesToDraw = Math.max(0, Number(linesToDraw) || 0);
    const numLinesToErase = Math.max(0, Number(linesToErase) || 0);
    const lw = Math.max(1, Number(lineWidth) || 1); // Line width must be at least 1px to prevent infinite loops

    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;

    canvas.width = width;
    canvas.height = height;

    // 1. Draw the original image onto the canvas. This will be the base layer.
    ctx.drawImage(originalImg, 0, 0, width, height);

    // If there are no lines to draw, the task is done. Return the canvas with the original image.
    if (numLinesToDraw <= 0) {
        return canvas;
    }

    // 2. Set up the line style for drawing.
    ctx.strokeStyle = lineColor;
    ctx.lineWidth = lw;

    let position = 0;
    const dimension = (orientation === 'horizontal') ? height : width;

    // 3. Loop through the image dimension (height or width) and apply the draw/erase pattern.
    // The "erase" part is achieved by simply skipping sections, leaving the original image visible.
    while (position < dimension) {
        
        // --- Draw Phase ---
        // Draw 'numLinesToDraw' consecutive lines.
        for (let i = 0; i < numLinesToDraw && position < dimension; i++) {
            // To ensure a line of thickness `lw` perfectly fills a band from `position` to `position + lw`,
            // we must draw the line in the middle of that band.
            const lineCenter = position + lw / 2;

            ctx.beginPath();
            if (orientation === 'horizontal') {
                ctx.moveTo(0, lineCenter);
                ctx.lineTo(width, lineCenter);
            } else { // 'vertical' orientation
                ctx.moveTo(lineCenter, 0);
                ctx.lineTo(lineCenter, height);
            }
            ctx.stroke();

            // Advance the position to the start of the next line band.
            position += lw;
        }

        // --- Erase (Skip) Phase ---
        // Skip 'numLinesToErase' lines by advancing the position without drawing.
        position += numLinesToErase * lw;
    }

    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image Line Drawer and Eraser tool allows users to modify images by adding and removing lines in a structured pattern. Users can specify the number of lines to draw and erase, the width and color of the lines, and the orientation (horizontal or vertical). This tool is useful for creating visual effects, adding guides or markings to images, and enhancing visual presentations for educational or artistic purposes.

Leave a Reply

Your email address will not be published. Required fields are marked *

Other Image Tools:

Image To Binary Converter For Optimized Storage

Image Japanese Anime Cell Shading Tool

Image Japanese Anime Cel Shading Renderer for Military Vehicles

Image Anime Cel Shade Effect Generator

Image Liquid Metallic Chrome Material Top View

Image Generator for Rainbow Six Siege Logo with Rainbow Fill

Image Transparency Adjuster for Clothing

Photo VHS Found Footage Analog Effect Tool

Image Old Fashioned Wanted Poster Creator

Image Toxic Waste Identifier

Image Realism Enhancer

Image Bulk Date and Location Stamp Adder Without Background Color

Image Time Stamp Removal Tool

Image Bulk Date and Text Stamp Adder

Image Bulk Date and Location Stamp Adder

Image Date and Location Stamp Adder

Image Date and Zone Stamping Tool

Image Bulk Date and Location Stamper

Image Bulk Date and Coordinate Stamper

Photo Artificial Metadata Generator

Photo Artificial Pattern Generator for Deepfake Bypass

Image Ultra Realistic Skin Texture Pore Emulation Tool

Image Chaotic Noise and Blur Generator for Deepfake Detection Evasion

Image Deep Effects Modification Tool

Image Portrait to Classic Hollywood Cinematic Still Enhancer

Image Chaotic Deep Modifications Editor

Image Chaotic Interleaving Modifier

Image Random Effects Generator with Low Intensity

Image Random Effects Generator

Image Chaotic Noise and Mosaic Effect Maker

Image Chaotic Noise Generator for Deepfake Detection Evasion

Image 4K Enhancement Tool for Realistic Skin Texture

Image Batch Chroma Key Processor

Image To Cel-Shaded Vector Converter

Image Hair Color Change Tool

Image Grillz and Smile Overlay Tool

See All →