Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Acrylics or oil?


Canvas + WebGL


WebGL I haven't quite got the hang of yet, but I just discovered `PointerEvent.pressure` and got terribly distracted playing with it with my phone :) thanks!

  <!doctype html>
  <style>html, body { width: 100%; height: 100%; margin: 0 }</style>
  <canvas style="touch-action: none" id=c></canvas>
  <div id=z style="position: fixed; left: 0; top: 0"></div>
  <script>
    c.width = window.innerWidth;
    c.height = window.innerHeight;
    var x = -1, y;
    var ctx = c.getContext('2d');
    c.onpointermove = ev => {
      //var p = Math.pow(ev.pressure, 3) * 20;  // both bad;
      var p = 0.5/(-Math.log10(ev.pressure));   // try one
      z.innerText = ev.pressure + '\n' + p;
      if (x != -1) {
        ctx.lineWidth = p;
        ctx.beginPath();
        ctx.moveTo(x, y);
        ctx.lineTo(ev.x, ev.y);
        ctx.stroke();
      }
      x = ev.x;
      y = ev.y;
    }
    c.onpointerup = () => x = -1;
  </script>
I also learned about the concept of pressure curves, and that they're really annoying both to implement and to get right: https://github.com/xournalpp/xournalpp/issues/2619, https://github.com/xournalpp/xournalpp/pull/2622, https://github.com/xournalpp/xournalpp/issues/1170

The two one-liners above to convert pressure to lineWidth are the result of playing around with no idea what I'm doing for a few minutes. They... work, in the sense that I can tolerate them for about 30 seconds :) but I keep playing with them because they don't "click". I wouldn't mind suggestions for how to actually do this (my google-fu isn't finding anything, likely because I don't know what to look for). I had a poke around Krita, but only found C++ abstractions.

I also stumbled on http://willowsystems.github.io/jSignature/#/about/linesmooth..., which is an awesome looking bit of open source code. It implements both realtime curve extrapolation and pressure approximation for devices/environments that don't report that.


That's pretty awesome. Last time I burnt out to painting I was doing paper sketches and shader graphs!


Wacom or not ?


fingerpainting


Do you prefer the walls or the floor?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: