<commit_before>"use strict";
define(["smoothly", "recorder"], function(Smoothly, Recorder) {
  var Turtle = function(element, w, h) {
    function xCenter() { return w / 2 }
    function yCenter() { return h / 2 }
    function setSize(width, height) {
      w = width
      h = height
      element.css({position: "relative", width: w, height: h})
      element.find("canvas").attr("width", w).attr("height", h)
    }
    var pendown = true

    var paper = createCanvas(0)
    var turtle = createCanvas(1)
    setSize(w, h)
    var cursor = {} // keys: image, width, height, left, top

    paper.save()
    turtle.save()

    init()

    function fontWithSize(size) {
      return size + "px Courier"
    }

    function init() {
      clearTurtle()
      paper.setTransform(1, 0, 0, 1, 0, 0)
      turtle.setTransform(1, 0, 0, 1, 0, 0)
      paper.clearRect(0, 0, w, h)
      turtle.clearRect(0, 0, w, h)
      paper.translate(xCenter(), yCenter())
      turtle.translate(xCenter(), yCenter())
      setBackground("white")
      paper.font=fontWithSize(20)
      setColor("black")
      drawTurtle()
    }
    function setBackground(color) {
      element.css("background-color", color);
    }
    function turtleToHome() {
      clearTurtle()
      paper.setTransform(1, 0, 0, 1, 0, 0)
      turtle.setTransform(1, 0, 0, 1, 0, 0)
      paper.translate(xCenter(), yCenter());
      turtle.translate(xCenter(), yCenter());
      drawTurtle()
    }
    function createCanvas(zIndex) {
      var canvas = $("<canvas></canvas>")
      canvas.css({position: "absolute", left: 0, right: 0})
      canvas.css({"z-index": zIndex})
      element.append(canvas)
      return canvas.get(0).getContext('2d');
    }
    function clearTurtle() {
      if ("image" in cursor) {
        turtle.clearRect(cursor.clearOffset, cursor.clearOffset, cursor.clearSize, cursor.clearSize)
      } else {
        turtle.clearRect(-11, -11, 23, 23)
      }
    }
    function drawTurtle() {
      if ("image" in cursor) {
        turtle.drawImage(cursor.image, cursor.left, cursor.top)
      } else {
        turtle.beginPath();
        turtle.moveTo(0, -10);
        turtle.lineTo(5, 10);
        turtle.lineTo(-5, 10);
        turtle.lineTo(0, -10);
        turtle.stroke();
      }
    }
    function setColor(color) {
      paper.strokeStyle=color
      paper.fillStyle=color
    }

    var api = {
      resize: function(newWidth, newHeight) {
        setSize(newWidth, newHeight)
        init()
      },
      fd: function(dist) {
        Smoothly.step(dist, 5, function(step) {
          if (pendown) {
            paper.beginPath()
            paper.moveTo(0, 0)
            paper.lineTo(0, -step)
            paper.stroke()
          }
          clearTurtle()
          paper.translate(0, -step)
          turtle.translate(0, -step)
          drawTurtle()
        })
      },
      lt: function(angle) {
        this.rt(-angle)
      },
      rt: function(angle) {
        Smoothly.step(angle, 10, function(a) {
          clearTurtle()
          paper.rotate(a * Math.PI / 180)
          turtle.rotate(a * Math.PI / 180)
          drawTurtle()
        })
      },
      pendown: Smoothly.do(function() {
        pendown = true
      }),
      penup: Smoothly.do(function() {
        pendown = false
      }),
      spin: function(degrees, delay) {
        this.lt(360)
      },
      setshape: function(name) {
        var image = new Image()
        image.onload = function() {
          clearTurtle()
          cursor.image = image
          cursor.height = this.height
          cursor.width = this.width
          cursor.left = -this.width / 2
          cursor.top = -this.height / 2
          cursor.clearSize = Math.sqrt(Math.pow(this.height, 2) + Math.pow(this.width, 2)) + 1
          cursor.clearOffset = -cursor.clearSize / 2
          drawTurtle()
        }
        image.src = "images/" + name + ".png"
      },<commit_msg>pendown on clear<commit_after>"use strict";
define(["smoothly", "recorder"], function(Smoothly, Recorder) {
  var Turtle = function(element, w, h) {
    function xCenter() { return w / 2 }
    function yCenter() { return h / 2 }
    function setSize(width, height) {
      w = width
      h = height
      element.css({position: "relative", width: w, height: h})
      element.find("canvas").attr("width", w).attr("height", h)
    }
    var pendown = true

    var paper = createCanvas(0)
    var turtle = createCanvas(1)
    setSize(w, h)
    var cursor = {} // keys: image, width, height, left, top

    paper.save()
    turtle.save()

    init()

    function fontWithSize(size) {
      return size + "px Courier"
    }

    function init() {
      clearTurtle()
      paper.setTransform(1, 0, 0, 1, 0, 0)
      turtle.setTransform(1, 0, 0, 1, 0, 0)
      paper.clearRect(0, 0, w, h)
      turtle.clearRect(0, 0, w, h)
      paper.translate(xCenter(), yCenter())
      turtle.translate(xCenter(), yCenter())
      setBackground("white")
      paper.font=fontWithSize(20)
      setColor("black")
      drawTurtle()
    }
    function setBackground(color) {
      element.css("background-color", color);
    }
    function turtleToHome() {
      clearTurtle()
      paper.setTransform(1, 0, 0, 1, 0, 0)
      turtle.setTransform(1, 0, 0, 1, 0, 0)
      paper.translate(xCenter(), yCenter());
      turtle.translate(xCenter(), yCenter());
      drawTurtle()
    }
    function createCanvas(zIndex) {
      var canvas = $("<canvas></canvas>")
      canvas.css({position: "absolute", left: 0, right: 0})
      canvas.css({"z-index": zIndex})
      element.append(canvas)
      return canvas.get(0).getContext('2d');
    }
    function clearTurtle() {
      if ("image" in cursor) {
        turtle.clearRect(cursor.clearOffset, cursor.clearOffset, cursor.clearSize, cursor.clearSize)
      } else {
        turtle.clearRect(-11, -11, 23, 23)
      }
    }
    function drawTurtle() {
      if ("image" in cursor) {
        turtle.drawImage(cursor.image, cursor.left, cursor.top)
      } else {
        turtle.beginPath();
        turtle.moveTo(0, -10);
        turtle.lineTo(5, 10);
        turtle.lineTo(-5, 10);
        turtle.lineTo(0, -10);
        turtle.stroke();
      }
    }
    function setColor(color) {
      paper.strokeStyle=color
      paper.fillStyle=color
    }

    var api = {
      resize: function(newWidth, newHeight) {
        setSize(newWidth, newHeight)
        init()
      },
      fd: function(dist) {
        Smoothly.step(dist, 5, function(step) {
          if (pendown) {
            paper.beginPath()
            paper.moveTo(0, 0)
            paper.lineTo(0, -step)
            paper.stroke()
          }
          clearTurtle()
          paper.translate(0, -step)
          turtle.translate(0, -step)
          drawTurtle()
        })
      },
      lt: function(angle) {
        this.rt(-angle)
      },
      rt: function(angle) {
        Smoothly.step(angle, 10, function(a) {
          clearTurtle()
          paper.rotate(a * Math.PI / 180)
          turtle.rotate(a * Math.PI / 180)
          pendown = true
          drawTurtle()
        })
      },
      pendown: Smoothly.do(function() {
        pendown = true
      }),
      penup: Smoothly.do(function() {
        pendown = false
      }),
      spin: function(degrees, delay) {
        this.lt(360)
      },
      setshape: function(name) {
        var image = new Image()
        image.onload = function() {
          clearTurtle()
          cursor.image = image
          cursor.height = this.height
          cursor.width = this.width
          cursor.left = -this.width / 2
          cursor.top = -this.height / 2
          cursor.clearSize = Math.sqrt(Math.pow(this.height, 2) + Math.pow(this.width, 2)) + 1
          cursor.clearOffset = -cursor.clearSize / 2
          drawTurtle()
        }
        image.src = "images/" + name + ".png"
      },
{'fraction_non_alphanumeric': 0.14327485380116958, 'fraction_numerical': 0.020594965675057208, 'mean_word_length': 1.9664404223227752, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '5653756', 'n_tokens_mistral': 2715, 'n_tokens_neox': 2507, 'n_words': 534}