<commit_before>Tools
=====

    Brushes = require "./brushes"
    {circle, line, rect, rectOutline, endDeltoid} = require "./util"

    line2 = (start, end, fn) ->
      fn start
      line start, end, fn

    neighbors = (point) ->
      [
        {x: point.x, y: point.y-1}
        {x: point.x-1, y: point.y}
        {x: point.x+1, y: point.y}
        {x: point.x, y: point.y+1}
      ]

    shapeTool = (hotkey, offsetX, offsetY, icon, fn) ->
      start = null
      end = null

      hotkeys: hotkey
      iconUrl: icon
      iconOffset:
        x: offsetX
        y: offsetY
      touch: ({position}) ->
        start = position

      move: ({editor, position}) ->
        end = position

        editor.restore()
        fn(editor, editor.canvas, start, end)

      release: ({position, editor}) ->
        editor.restore()
        fn(editor, editor.canvas, start, end)

    brushTool = (brushName, hotkey, offsetX, offsetY, icon, options) ->
      previousPosition = null
      brush = Brushes[brushName]

      OP = (out) ->
        (p) ->
          out(p, options)

      paint = (out) ->
        (x, y) ->
          brush({x, y}).forEach OP out

      hotkeys: hotkey
      iconUrl: icon
      iconOffset:
        x: offsetX
        y: offsetY
      touch: ({position, editor})->
        paint(editor.draw) position
        previousPosition = position
      move: ({editor, position})->
        line previousPosition, position, paint(editor.draw)
        previousPosition = position
      release: -><commit_msg>:volcano::libra: Updated in browser at strd6.github.io/editor<commit_after>Tools
=====

    Brushes = require "./brushes"
    {circle, line, rect, rectOutline, endDeltoid} = require "./util"

    line2 = (start, end, fn) ->
      fn start
      line start, end, fn

    neighbors = (point) ->
      [
        {x: point.x, y: point.y-1}
        {x: point.x-1, y: point.y}
        {x: point.x+1, y: point.y}
        {x: point.x, y: point.y+1}
      ]

    shapeTool = (hotkey, offsetX, offsetY, icon, fn) ->
      start = null
      end = null

      hotkeys: hotkey
      iconUrl: icon
      iconOffset:
        x: offsetX
        y: offsetY
      touch: ({position}) ->
        start = position

      move: ({editor, position}) ->
        end = position

        editor.restore()
        fn(editor, editor.canvas, start, end)

      release: ({position, editor}) ->
        editor.restore()
        fn(editor, editor.canvas, start, end)

    brushTool = (brushName, hotkey, offsetX, offsetY, icon, options) ->
      previousPosition = null
      brush = Brushes[brushName]

      OP = (out) ->
        (p) ->
          out(p, options)

      paint = (out) ->
        (x, y) ->
          brush({x, y}).forEach OP out

      hotkeys: hotkey
      iconUrl: icon
      iconOffset:
        x: offsetX
        y: offsetY
      touch: ({position, editor})->
        paint(editor.draw) position.x, position.y
        previousPosition = position
      move: ({editor, position})->
        line previousPosition, position, paint(editor.draw)
        previousPosition = position
      release: ->
{'fraction_non_alphanumeric': 0.13633440514469453, 'fraction_numerical': 0.003536977491961415, 'mean_word_length': 1.8333333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '298481', 'n_tokens_mistral': 990, 'n_tokens_neox': 966, 'n_words': 266}