ALINE suitable for simple smooth finger-style drawing?

For years I’ve tried to find the best way in Unity to simply draw lines simply in 2D “on the screen”,

trivial example of me doing this in everyday software -

mac example

from an engine I built, user drawing a line with a finger (I used some crap technology to render the line!)

I’m completely familiar with spline handling and basically everything in Unity, but I’ve never found a good way to render such lines!

I can easily get the user input from mouse/finger, and present the data in any way needed, and/or take care of mathematically smoothing if needed.

But I have never found a way to nicely render a nice anti-aliased line - just as in any drawing program such as the red line example image up top.

Is ALINE for me?

if so, tip on how to use ALINE in this way? completely 2D, simple “on screen”, flat, UX-like lines - is ALINE for me? Thanks!

Just like in the example image red line up top!

1 Like


Currently no. ALINE is currently only suitable for 1px thick lines. It will work perfectly for your use case if you just want 1px thick lines, but from the images it sounds like you want a bit thicker lines.

I do plan on adding support for line widths too, but currently this feature is not included I’m afraid.

If you want a quick and dirty solution. Sampling a point say ever 2 or 3 pixels along the curve and then rendering a quad at each such point will work well. Each quad should be rendered with normal alpha blending with a texture that is just a circle. This is pretty much identical to how brush tools work in drawing applications such as photoshop.

@aron_granberg thank you so much for the prompt and excellent answer,

Ah, 1px thick only - I was not clear on that, fantastic. It really makes sense now.

Thanks for the great explanation.

Regarding your final para, “how it is done in photoshop!”, that makes 1000% sense and is a great explanation, indeed I’ll try that. Thank you so much again!! Fantastically useful. Thanks!