<commit_before>class TextPositioner

  bind_div: (div) ->
    @div = $(div)
    @set_img_attrs()

    @canvas_id = 'position-canvas'

    @dom_canvas = @create_dom_canvas()

    @div.empty().append(@dom_canvas)

    @fabric_canvas = @create_fabric_canvas()

    @fabric_canvas.renderAll()

  add_rect: (name, x_input, y_input, width_input, height_input) ->
    rect = new fabric.Rect
      name: name
      top: @scale_height(y_input.val()) + @scale_height(height_input.val()) / 2.0
      left: @scale_width(x_input.val()) + @scale_width(width_input.val()) / 2.0
      width: @scale_width(width_input.val())
      height: @scale_height(height_input.val())
      fill: '#808080'
      cornersize: 20
      lockRotation: true
      hasRotatingPoint: false

    @fabric_canvas.add rect

  set_img_attrs: ->
    @img_url = @div.attr('data-img-url')
    @img_width = @div.attr('data-img-width')
    @img_height = @div.attr('data-img-height')

  create_dom_canvas: ->
    $('<canvas />').attr('id', @canvas_id)

  create_fabric_canvas: ->
    canvas = new fabric.Canvas @canvas_id,
                               'backgroundImage': @img_url
    canvas.setWidth @img_width
    canvas.setHeight @img_height
<commit_msg>Gradient fill text positioning rectangles.<commit_after>class TextPositioner

  bind_div: (div) ->
    @div = $(div)
    @set_img_attrs()

    @canvas_id = 'position-canvas'

    @dom_canvas = @create_dom_canvas()

    @div.empty().append(@dom_canvas)

    @fabric_canvas = @create_fabric_canvas()

    @fabric_canvas.renderAll()

  add_rect: (name, x_input, y_input, width_input, height_input) ->
    rect = new fabric.Rect
      name: name
      top: @scale_height(y_input.val()) + @scale_height(height_input.val()) / 2.0
      left: @scale_width(x_input.val()) + @scale_width(width_input.val()) / 2.0
      width: @scale_width(width_input.val())
      height: @scale_height(height_input.val())
      fill: '#808080'
      cornersize: 20
      lockRotation: true
      hasRotatingPoint: false

    rect.setGradientFill
      x1: '0%'
      y1: '0%'
      x2: '100%'
      y2: '100%'
      colorStops:
        0: 'black'
        1: 'white'

    @fabric_canvas.add rect

  set_img_attrs: ->
    @img_url = @div.attr('data-img-url')
    @img_width = @div.attr('data-img-width')
    @img_height = @div.attr('data-img-height')

  create_dom_canvas: ->
    $('<canvas />').attr('id', @canvas_id)

  create_fabric_canvas: ->
    canvas = new fabric.Canvas @canvas_id,
                               'backgroundImage': @img_url
    canvas.setWidth @img_width
    canvas.setHeight @img_height

{'fraction_non_alphanumeric': 0.14516750096264922, 'fraction_numerical': 0.014632268001540239, 'mean_word_length': 2.9483282674772036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '5519170', 'n_tokens_mistral': 949, 'n_tokens_neox': 894, 'n_words': 158}