Lazy-brush – smooth drawing with mouse or finger

lazybrush.dulnan.net

584 points by tvdvd 6 days ago


NikxDa - 2 days ago

An alternative that works very well for signatures too is Perfect Freehand (by the guy behind TLDRaw)

https://perfect-freehand-example.vercel.app/

pstadler - 2 days ago

Check out drawmote from the same author, where this library is being used.

https://drawmote.app/

marsavar - 2 days ago

OP's personal website deserves its own post! https://dulnan.net/ <3

iamjackg - 2 days ago

This technique was also used in mid-late non-motion-plus Wii games to smooth out the pointer movement! Early games hadan incredibly twitchy pointer because they were simply mapping the IR data 1:1 to cursor movement, whereas later ones have an invisible circle around the cursor and only move the cursor itself once the circle edges start "dragging" it.

gdubs - 6 days ago

This is so satisfying. These types of experiments are something I really love about the open-web, and part of what bums me out about how most social networks tend to throttle links.

The dragging behavior is so intuitive – it's funny because usually if you create this kind of resistance in a UI it can be confusing, but in this context it works so well.

davedx - 2 days ago

Really cool!

I wonder what Duo Lingo are using behind the scenes. I've been busy with the Chinese and Japanese courses, and one thing I quickly noticed is how there are two different 'grades' of practising drawing hanzi/kana: when you first learn how to write it (with your finger, in the app) it constrains your movements so they perfectly follow the guidelines. But then later, it relaxes the constraints totally, or almost totally, so your hiragana can really be a shorthand squiggle. They then assess it quite liberally too, so as long as the general gist is correct, your kana will pass -- but it's also easy to fail it if you're just guessing.

rebuilder - 2 days ago

This is very nice, not just for finger/mouse painting! I tried it on my Cintiq and it was actually a lot better for me than brush stabilization usually is - I think the logic is the same as seen in e.g. Krita, but the visualization of the cursor and where the paint will appear is very helpful. Usually painting software doesn't have such an indicator of where the actual stroke will be placed and when it will move.

moritonal - 2 days ago

I believe a logic similar to this was used to enact the "Gestures" system in Black and White 1. Breaking down the mouse-movements into vectors following a guide-point. (https://blackandwhite.fandom.com/wiki/Gesture).

WithinReason - 2 days ago

The trick is hysteresis but in 2D:

https://en.wikipedia.org/wiki/Hysteresis

edflsafoiewq - 2 days ago

I think this is the same as the brush stabilizer in Krita.

zastai0day - 2 days ago

Wow, this is amazing! I see you've been building this on GitHub for 7 years - that's truly impressive dedication. What keeps you motivated to stick with this product for so long?

IshKebab - 2 days ago

I think it would be much better to use some kind of Kalman filtering so you don't have the huge lag. You don't need to commit to permanent output immediately so it is possible to draw with zero lag and then smooth the output afterwards.

- 2 days ago
[deleted]
skybrian - 2 days ago

The cursor lags behind so your finger doesn’t cover it. That helps for drawing carefully, but it means you need to use an exaggerated motion when changing direction. It’s a little unnatural at first, but might be better than alternatives with practice?

- 2 days ago
[deleted]
test1235 - 2 days ago

OT, but I love the author's retro homepage. Just seeing that made me smile this morning

voidmain0001 - 2 days ago

Lazy radius of 1, friction of .50 and brush radius of 3 provides the ideal environment for me to cursive write with a mouse.

levmiseri - a day ago

I wonder how a real-world pen/equivalent of this would feel like to write or draw with.

- 2 days ago
[deleted]
jeremyscanvic - 2 days ago

Neat! This is known as a stabilizer in the digital art community.

keepamovin - 2 days ago

This is really cool and reminded me of drawing as a kid. Thank you!

jflessau - 2 days ago

Simple, fun, precise and works on mobile. Love it!

karpour - 2 days ago

Great project, I had some fun playing around :)

DonHopkins - 2 days ago

Very nice! I love the way the leash droops from gravity when you give it some slack, to unobtrusively and intuitively show users what's really going on, how the control system actually works, so it's tangible and physical, not a mysterious unpredictable black box. True honest wysiwyg "direct manipulation", no invisible magic.

https://en.wikipedia.org/wiki/Direct_manipulation_interface

It reminds me of artist/engineer's Paul Haeberli's legendary and monumentally influential "DynaDraw" which he wrote at SGI.

DynaDraw: A Dynamic Drawing Technique (June 1989):

https://web.archive.org/web/19970605062552/http://www.sgi.co...

>Here's a really fun and useful hack.

>The program Dynadraw implements a dynamic drawing technique that applies a simple filter to mouse positions. Here the brush is modeled as a physical object with mass, velocity and friction. The mouse pulls on the brush with a synthetic rubber band. By changing the amount of friction and mass, various kinds of strokes can be made. This kind of dynamic filtering makes it easy to create smooth, consistent calligraphic strokes.

>The C source for the dynadraw demo program is available. You can save this onto your IRIS, compile it, and give it a try. If you're a Mac or PC hacker, you might be able to port this program easily to your own platform.

Source Code (for SGI GL):

https://web.archive.org/web/19970727185417/http://www.sgi.co...

Lots more great stuff from Paul Haeberli on his "Graphica Obscura" page:

https://web.archive.org/web/19970706205455/http://www.sgi.co...

https://en.wikipedia.org/wiki/Paul_Haeberli

He inspired another artist/engineer Golan Levin to write an implementation of DynaDraw with Processing and p5.js:

https://editor.p5js.org/golan/sketches/cZPRgx6q9

  // This is a rudimentary p5.js 'port' of Paul Haeberli's
  // legendary and monumentally influential program "Dynadraw",
  // which is described at: http://www.sgi.com/grafica/dyna/index.html
  // Originally created in June 1989 by Paul Haeberli (@GraficaObscura)
  // Ported to Processing January 2004 by Golan Levin (@golan)
  // Ported to p5.js September 2021 by Golan Levin.
Golan does a mind blowing amount of amazingly creative stuff:

http://www.flong.com/archive/index.html

https://en.wikipedia.org/wiki/Golan_Levin

I love his Double-Taker (Snout) (2008):

http://www.flong.com/archive/projects/snout/index.html

He explained that and more in this Ted talk "Golan Levin makes art that looks back at you":

https://www.youtube.com/watch?v=1G0MzlfMPuM

>As Joy Mountford once said, "The mouse is probably the narrowest straw you could try to suck all of human expressions through."

https://en.wikipedia.org/wiki/Joy_Mountford

I also love "Rouen Revisited" (1996)̀, a "monumental" architectural visualization that Golan Levin and another artist/engineer Paul Debevec collaborated on at Interval Research Labs, which led to Paul's later work at USC:

http://www.flong.com/archive/projects/rouen/index.html

Paul Debevec teaches and researches at USC and Eyeline Studios (powered by Netflix):

https://www.pauldebevec.com/

https://en.wikipedia.org/wiki/Paul_Debevec

Paul Debevec's "Light Stage" was featured in The Congress (2013), in the dramatically riveting and technically accurate scan scene:

https://www.youtube.com/watch?v=pPAl5GwvdY8

More links:

https://news.ycombinator.com/item?id=34953477

eaglelizard - 2 days ago

this is really fun, thank you for making this and sharing it!

sdafasdfad - 2 days ago

This does not work at all, half of my drawing is missing

mehulashah - 2 days ago

Neat.

lassenordahl - 2 days ago

this is sick

altern8 - a day ago

[dead]

rickdarlino - a day ago

[dead]