{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 352a57dced4100d360f6","webpack:///./src/palette.js","webpack:///./src/index.js"],"names":["BLACK","BLUE","GREEN","CYAN","RED","MAGENTA","YELLOW","WHITE","BROWN","TAN","FOREST","AQUA","SALMON","PURPLE","ORANGE","GREY","DEFAULT_PALETTE","getColorString","palette","r","g","b","undefined","join","isNaN","parseInt","colorIndex","length","module","exports","require","toInt","x","Tortuga","canvasSelector","initx","inity","ctx","document","querySelector","getContext","e","Error","position","direction","_penDown","lineCap","background","penColor","color","size","fixAxis","clean","begin","setTransform","translate","canvas","width","height","scale","clearRect","home","beginPath","moveTo","stroke","style","backgroundColor","strokeStyle","drawPath","_step","_totalSteps","step","totalSteps","Math","ceil","_size","penSize","parseFloat","lineWidth","y","isPenDown","lineTo","setXY","setHeading","_length","angle","PI","round","cos","sin","forward","deg","right","heading","atan2"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;AChEA,IAAMA,QAAQ,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAd;AACA,IAAMC,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,GAAP,CAAb;AACA,IAAMC,QAAQ,CAAC,CAAD,EAAI,GAAJ,EAAS,CAAT,CAAd;AACA,IAAMC,OAAO,CAAC,CAAD,EAAI,GAAJ,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;;AACzB;AACA,WAAKiB,SAAL,IAAkB,GAAlB;AACA;AACA,WAAK8C,OAAL,CAAa3D,MAAMJ,MAAN,CAAb;AACA;AACA,WAAKiB,SAAL,IAAkB,GAAlB;AACD;;AAED;;;;0BACM+C,G,EAAK;AACT,WAAK/C,SAAL,GAAiB,CAAC,KAAKA,SAAL,GAAiBb,MAAM4D,GAAN,CAAlB,IAAgC,GAAjD;AACD;;AAED;;;;yBACKA,G,EAAK;AACR,WAAKC,KAAL,CAAW,CAAC,CAAD,GAAK7D,MAAM4D,GAAN,CAAhB;AACD;;AAED;;;;+BACWE,O,EAAS;AAClB,WAAKjD,SAAL,GAAiBb,MAAM8D,OAAN,IAAiB,GAAlC;AACD;;AAED;;;;4BACQ7D,C,EAAG+C,C,EAAG;AACZ;AACA,UAAM5D,IAAI,CACRY,MAAMC,CAAN,IAAW,KAAKW,QAAL,CAAc,CAAd,CADH,EAERZ,MAAMgD,CAAN,IAAW,KAAKpC,QAAL,CAAc,CAAd,CAFH,CAAV;AAIA;AACA,UAAMkD,UAAUpB,KAAKqB,KAAL,CAAW3E,EAAE,CAAF,CAAX,EAAiBA,EAAE,CAAF,CAAjB,CAAhB;AACA;AACA,aAAO0E,UAAU,GAAV,GAAgBpB,KAAKa,EAA5B;AACD;;;;;;AAGH1D,OAAOC,OAAP,GAAiBI,OAAjB,C","file":"Tortuga.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Tortuga\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Tortuga\"] = factory();\n\telse\n\t\troot[\"Tortuga\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 352a57dced4100d360f6","const BLACK = [0, 0, 0];\nconst BLUE = [0, 0, 255];\nconst GREEN = [0, 255, 0];\nconst CYAN = [0, 255, 255];\nconst RED = [255, 0, 0];\nconst MAGENTA = [255, 0, 255];\nconst YELLOW = [255, 255, 0];\nconst WHITE = [255, 255, 255];\nconst BROWN = [155, 96, 59];\nconst TAN = [255, 149, 119];\nconst FOREST = [34, 139, 34];\nconst AQUA = [127, 255, 212];\nconst SALMON = [250, 128, 114];\nconst PURPLE = [128, 0, 128];\nconst ORANGE = [255, 163, 0];\nconst GREY = [183, 183, 183];\n\nconst DEFAULT_PALETTE = [\n BLACK,\n BLUE,\n GREEN,\n CYAN,\n RED,\n MAGENTA,\n YELLOW,\n WHITE,\n BROWN,\n TAN,\n FOREST,\n AQUA,\n SALMON,\n PURPLE,\n ORANGE,\n GREY,\n];\n\n// Helper to get a color string out of multiple possible arguments.\n// Accepts either rgb values, a color string or palette index.\nconst getColorString = (palette, r, g, b) => {\n // If r is undefined, no argument is found, use white.\n if (r === undefined) {\n return `rgb(${WHITE.join(',')})`;\n }\n\n // If all colors are defined, return an rgb color string\n if (r !== undefined && g !== undefined && b !== undefined) {\n // rgb was passed as arguments\n return `rgb(${r},${g},${b})`;\n }\n\n // Check if first parameter is string or int\n if (isNaN(parseInt(r, 10))) {\n // Use this string as strokeStyle\n return r;\n }\n\n // Palette color was sent\n // Only allow indexes available for palette\n const colorIndex = parseInt(r, 10) % palette.length;\n return `rgb(${palette[colorIndex].join(',')})`;\n};\n\nmodule.exports = {\n DEFAULT_PALETTE,\n getColorString,\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/palette.js","// (c) 2015-2017 Hernán Rodríguez Colmeiro\n// Tortuga may be freely distributed under the MIT license.\n\nconst { DEFAULT_PALETTE, getColorString } = require('./palette.js');\nconst WHITE = 7;\nconst toInt = (x) => parseInt(x, 10);\n\n/*\n * Create a Tortuga.\n * canvasSelector: String, canvas element selector\n * initx: Int, initial X coordinate (optional, default 0)\n * inity: Int, initial Y coordinate (optional, default 0)\n * length: Int, default length used by forward (optional, default 100)\n */\nclass Tortuga {\n constructor(canvasSelector = '#tortuga', initx = 0, inity = 0, length = 100) {\n // Check if the selector matches\n try {\n this.ctx = document.querySelector(canvasSelector).getContext('2d');\n } catch (e) {\n throw Error(\n `The selector \\`${canvasSelector}\\` matched no canvas element.`\n );\n }\n\n // Parse optional parameters\n this.position = [toInt(initx), toInt(inity)];\n this.length = toInt(length);\n\n // Set internal variables\n this.direction = 0; // Direction is in degrees\n this._penDown = true;\n\n // Tortuga pre-set color palette. To store new colors or modify existing\n // ones just modify this list.\n this.palette = DEFAULT_PALETTE;\n\n this.ctx.lineCap = 'round';\n\n // Set the background to black\n this.background(0);\n\n // Set stroke style to white using the palette.\n this.penColor = '';\n this.color(WHITE);\n\n // Set the pen width to the default 1\n this.size(1);\n\n // Y axis on screen is rotated, so fix it\n this.fixAxis();\n\n this.clean();\n this.begin();\n }\n\n // Helper to set the origin at the center and axis\n // to increase towards top right.\n fixAxis() {\n this.ctx.setTransform(1, 0, 0, 1, 0, 0); // Reset Transform to Identity Matrix\n this.ctx.translate(this.ctx.canvas.width / 2, this.ctx.canvas.height / 2);\n this.ctx.scale(1, -1);\n }\n\n // Clean the current turtle drawing.\n clean() {\n const height = this.ctx.canvas.height;\n const width = this.ctx.canvas.width;\n // Origin is at the center, so start painting from bottom left.\n this.ctx.clearRect(width * -1 / 2, height * -1 / 2, width, height);\n }\n\n // Clear the current turtle drawing and reset turtle position.\n reset() {\n this.home();\n this.clean();\n this.begin();\n }\n\n // Usually shouldn't be used outside Tortuga, begins a new path.\n begin() {\n this.ctx.beginPath();\n this.ctx.moveTo(this.position[0], this.position[1]);\n }\n\n // Draw the current turtle path, and begin a new one.\n drawPath() {\n this.ctx.stroke();\n this.begin();\n }\n\n // Change the background color.\n // Accepts either rgb values, a color string or palette index.\n background(r, g, b) {\n this.ctx.canvas.style.backgroundColor = getColorString(this.palette, r, g, b);\n }\n\n\n // Change the pen color, draws the current path.\n // Accepts either rgb values, a color string or palette index.\n color(r, g, b) {\n this.penColor = getColorString(this.palette, r, g, b);\n this.ctx.strokeStyle = this.penColor;\n this.drawPath();\n }\n\n // Step the pen color through the rainbow.\n rainbow(_step, _totalSteps) {\n const step = toInt(_step);\n const totalSteps = toInt(_totalSteps);\n this.color(`hsl(${Math.ceil(step / totalSteps * 360)}, 100%, 50%)`);\n }\n\n // Set the pen size.\n size(_size) {\n this.penSize = parseFloat(_size);\n this.ctx.lineWidth = this.penSize;\n }\n\n // Lift the pen, draws the current path.\n penUp() {\n this.drawPath();\n this._penDown = false;\n }\n\n // Set the pen down.\n penDown() {\n this._penDown = true;\n }\n\n // Returns the pen status.\n isPenDown() {\n return this._penDown;\n }\n\n // Move the turtle to the specified absolute [`x`, `y`] position.\n setXY(x, y) {\n // Update position\n this.position = [toInt(x), toInt(y)];\n\n // If the pen is down, write. Otherwise just move\n if (this.isPenDown()) {\n this.ctx.lineTo(this.position[0], this.position[1]);\n } else {\n this.ctx.moveTo(this.position[0], this.position[1]);\n }\n }\n\n // Move the turtle horizontally to the new `x` coordinate.\n setX(x) {\n this.setXY(toInt(x), this.position[1]);\n }\n\n // Move the turtle vertically to the new `y` coordinate.\n setY(y) {\n this.setXY(this.position[0], toInt(y));\n }\n\n // Move the turtle to it's initial position at [0, 0] and heading 0.\n home() {\n this.setXY(0, 0);\n this.setHeading(0);\n }\n\n // Move forward the specified length, or use the default one.\n forward(length = this.length) {\n // `this.direction` is measured clockwise from the Y axis,\n // but the canvas measures angles counterclockwise from the X axis,\n // so we have to convert it first to something canvas understands.\n const _length = toInt(length);\n let x = this.position[0];\n let y = this.position[1];\n let angle = -1 * this.direction + 90;\n\n // And then convert the angle to radians\n angle = Math.PI * (angle) / 180;\n\n // And finally add the displacement\n x += Math.round(Math.cos(angle) * _length);\n y += Math.round(Math.sin(angle) * _length);\n\n this.setXY(x, y);\n }\n\n // A handy rename to move backwards.\n back(length = this.length) {\n // Change the direction momentarily\n this.direction -= 180;\n // Use forward to avoid repeating code\n this.forward(toInt(length));\n // Restore the direction as it was before\n this.direction += 180;\n }\n\n // Rotate the turtle by the desired angle in deg, clockwise.\n right(deg) {\n this.direction = (this.direction + toInt(deg)) % 360;\n }\n\n // Rotate the turtle by the desired angle in deg, counterclockwise.\n left(deg) {\n this.right(-1 * toInt(deg));\n }\n\n // Set the turtle absolute heading to the specified angle in deg.\n setHeading(heading) {\n this.direction = toInt(heading) % 360;\n }\n\n // Return the direction for the turtle to point directly to the destination.\n towards(x, y) {\n // Get the position vector (r) for this.position->(x,y)\n const r = [\n toInt(x) - this.position[0],\n toInt(y) - this.position[1],\n ];\n // Get the position vector angle\n const heading = Math.atan2(r[0], r[1]);\n // Return heading in degrees\n return heading * 180 / Math.PI;\n }\n}\n\nmodule.exports = Tortuga;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""}