Glowing line effect?

I’ve been looking around for a way to do this with shaders, its possible with textures though, but that looks ugly if your changing width or the distance for each stroke this can make some disliked changes and makes it deformed. Is. There a way to do this using a shader, well I know there is… I can use sobel edge detection and only draw the pixels that are greater in rgb than 0.9, then use a Gaussian blur to make a glow effect, but even just by reading that you know it’s expensive. So are there any other ways of creating a half decent glow effect? Thanks.

This doesn’t need a shader, and will be efficient if you want to reuse the line

function setup()
    g=DrawGlowLine(200,5,20,color(255,0,0),color(255))
end

function draw()
    background(22)
    sprite(g,WIDTH/2,HEIGHT/2)
end

function DrawGlowLine(lineLength,lineWidth,glowWidth,lineColor,glowColor)
    img=image(lineLength+glowWidth*2,lineWidth+glowWidth*2)
    pushStyle()
    setContext(img)
    noSmooth()
    lineCapMode(SQUARE)
    for i=1,glowWidth do
        local p=255*i/glowWidth/glowWidth
        stroke(color(glowColor.r,glowColor.g,glowColor.b,p))
        local w=lineWidth+(glowWidth+1-i)*2
        strokeWidth(w)
        line(i,i+w/2,i+lineLength+(glowWidth+1-i)*2,i+w/2)
    end
    stroke(lineColor)
    strokeWidth(lineWidth)
    line(glowWidth,glowWidth+lineWidth/2,lineLength+glowWidth,glowWidth+lineWidth/2)
    setContext()
    popStyle()
    return img
end

Thanks @ignatz that does what I want but if I use this as a brush I’ll end up with visible segments as the cap mode is round, will I not? Anyway since I’ve been looking at shaders they’ve got me really excited because you can feel the power! The rasterisation process is amazing in itself. But anyway I’m doing this more for learning purposes, there are a lot of ways to accomplish this but I’m not in it for just drawing sprites with textures although you do it quite nicely :slight_smile:

Removed