!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.CodeHS=t()}}(function(){var define,module,exports;return function t(e,o,n){function r(i,a){if(!o[i]){if(!e[i]){var u="function"==typeof require&&require;if(!a&&u)return u(i,!0);if(s)return s(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var c=o[i]={exports:{}};e[i][0].call(c.exports,function(t){var o=e[i][1][t];return r(o?o:t)},c,c.exports,t,e,o,n)}return o[i].exports}for(var s="function"==typeof require&&require,i=0;i<n.length;i++)r(n[i]);return r}({1:[function(require,module,exports){"use strict";var graphicsModule=require("codehs-graphics"),dataStructuresModule=require("codehs-datastructures"),consoleModule=require("codehs-console"),randomizerModule=graphicsModule.Randomizer,keyboardModule=require("codehs-keyboard"),CodeHSGraphics=graphicsModule.CodeHSGraphics,CodeHSConsole=consoleModule.CodeHSConsole,CodeHSDatastructures=dataStructuresModule,domready=require("domready"),PUBLIC_METHODS={},PUBLIC_CONSTRUCTORS={};PUBLIC_METHODS.__graphics__=graphicsModule.PUBLIC_METHODS,PUBLIC_METHODS.__console__=consoleModule.PUBLIC_METHODS,PUBLIC_CONSTRUCTORS.__graphics__=graphicsModule.PUBLIC_CONSTRUCTORS,PUBLIC_CONSTRUCTORS.__datastructs__=dataStructuresModule.PUBLIC_CONSTRUCTORS;var makeNamespaceWrap=function(){var t,e,o,n="";for(t in PUBLIC_METHODS)if(PUBLIC_METHODS.hasOwnProperty(t))for(o=0;o<PUBLIC_METHODS[t].length;o++)e=PUBLIC_METHODS[t][o],n+="window."+e+" = function(){\n	return "+t+"."+e+".apply("+t+", arguments);\n}\n";var r;for(t in PUBLIC_CONSTRUCTORS)if(PUBLIC_CONSTRUCTORS.hasOwnProperty(t))for(o=0;o<PUBLIC_CONSTRUCTORS[t].length;o++)r=PUBLIC_CONSTRUCTORS[t][o],n+="window."+r+" = "+t+"."+r+";\n";return n+="Text.giveDefaultContext(__graphics__);\n"},setup=function(){window.__graphics__=new CodeHSGraphics,window.__console__=new CodeHSConsole,window.__datastructs__=CodeHSDatastructures,window.CodeHSGraphics=CodeHSGraphics,window.Randomizer=randomizerModule,window.Color=graphicsModule.Color,window.Keyboard=keyboardModule;var wrap=makeNamespaceWrap();eval(wrap)};domready(function(){setup()}),module.exports={CodeHSGraphics:CodeHSGraphics,CodeHSConsole:CodeHSConsole,CodeHSDatastructures:CodeHSDatastructures}},{"codehs-console":2,"codehs-datastructures":3,"codehs-graphics":12,"codehs-keyboard":24,domready:25}],2:[function(t,e,o){"use strict";function n(){}var r=t("codehs-js-utils").safeEval,s=t("codehs-js-utils").testInfiniteLoops,i=[],a=null,u="#tester-message",l=[];n.registerPublicMethod=function(t){l.push(t)},n.getNamespaceModifcationString=function(){for(var t="",e=0;e<l.length;e++){var o=l[e];t+="function "+o+"(){\n	return __console__."+o+".apply(__console__, arguments);\n}\n"}return t},n.getStubString=function(){var t="";return _.each(l,function(e){t+="function "+e+"(){\n	return 0;\n}\n"}),t},n.setSolution=function(t){a=t},n.prototype.checkOutput=function(){if(a){var t={success:!0,message:"<strong>Nice job!</strong> You got it!"};if(0===$("#console").html().length)t.success=!1,t.message="You didn't print anything.";else if(i.length!=a.length)t.success=!1,t.message="<strong>Not quite.</strong> Take a look at the example output in the exercise tab.";else for(var e=0;e<i.length;e++){var o=i[e],n=a[e],r=new RegExp(n);0!==o.search(r)&&(t.success=!1,t.message="<strong>Not quite.</strong> Take a look at the example output in the exercise tab.")}return $(u).html(t.message),t.success?$(u).removeClass("gone").removeClass("alert-error").addClass("alert-info"):$(u).removeClass("gone").removeClass("alert-info").addClass("alert-error"),t}},n.getOutput=function(){return $("#console").text()},n.exists=function(){return $("#console").exists()},n.clear=function(){i=[],$("#console").html(""),$(u).addClass("gone")},n.prototype.readLinePrivate=function(t,e){"undefined"!=typeof e&&e||this.print(t),$("#console").css("margin-top","180px");var o=prompt(t);return $("#console").css("margin-top","0px"),"undefined"!=typeof e&&e||this.println(o),o},n.prototype.runCode=function(t,e){e=e||{};var o=n.getNamespaceModifcationString(),i=n.getStubString();if(!e.overrideInfiniteLoops)try{if(!this.hasUserinput()){var a=s(i+t);if(a)return window.CHS&&window.CHS.PubSub.trigger("editorError:handle","","infinite_loop"),{hasError:!0}}}catch(u){console.log("infinite loop checker did not run.")}var l=";var console = {}; console.log = println;\n",c="";return c+=o,c+=l,c+=t,c+="\n\nif(typeof start == 'function') {start();} ",c+="__console__.checkOutput();",r(c,this,"__console__")},n.prototype.hasUserinput=function(t){return t.match(new RegExp("readLine|readInt|readFloat|readBoolean|readNumber"))},n.prototype.print=function(t){if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to print");var e=$("#console");e.length?(e.html($("#console").html()+t),e.scrollTop($("#console")[0].scrollHeight),i=e.html().split("\n"),i.splice(i.length-1,1)):window.console.log(t)},n.registerPublicMethod("print"),n.prototype.println=function(t){if(0===arguments.length)t="";else{if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to println");this.print(t+"\n");$("#console").scrollTop()}},n.registerPublicMethod("println"),n.prototype.readNumber=function(t,e,o){for(var n=0,r=100,s=t,i=!1,a=0;;){var u=this.readLinePrivate(s,i);if(null===u)return null;if(u=e(u),!isNaN(u))return u;if(null===u)return n;if(a>r)return n;s="That was not "+o+". Please try again. "+t,i=!0,a++}},n.registerPublicMethod("readNumber"),n.prototype.readLine=function(t){if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to readLine");return this.readLinePrivate(t,!1)},n.registerPublicMethod("readLine"),n.prototype.readBoolean=function(t){if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to readBoolean");return this.readNumber(t,function(t){return null===t?NaN:(t=t.toLowerCase(),"true"==t||"yes"==t?!0:"false"==t||"no"==t?!1:NaN)},"a boolean (true/false)")},n.registerPublicMethod("readBoolean"),n.prototype.readInt=function(t){if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to readInt");return this.readNumber(t,function(t){var e=parseInt(t),o=parseFloat(t);return e==o?e:NaN},"an integer")},n.registerPublicMethod("readInt"),n.prototype.readFloat=function(t){if(1!==arguments.length)throw new Error("You should pass exactly 1 argument to readFloat");return this.readNumber(t,parseFloat,"a float")},n.registerPublicMethod("readFloat"),e.exports={CodeHSConsole:n,PUBLIC_METHODS:l}},{"codehs-js-utils":23}],3:[function(t,e,o){"use strict";var n=(t("./queue.js"),t("./set.js")),r=t("./stack.js"),s=["Queue","Set","Stack"];e.exports={PUBLIC_CONSTRUCTORS:s,Set:n,Stack:r}},{"./queue.js":4,"./set.js":5,"./stack.js":6}],4:[function(t,e,o){"use strict";function n(){this.q=[]}n.prototype.size=function(){return this.q.length},n.prototype.clear=function(){this.q=[]},n.prototype.enqueue=function(t){this.q.push(t)},n.prototype.dequeue=function(){var t=this.q[0];return this.q.splice(0,1),t},n.prototype.peek=function(){var t=this.q[0];return t},n.prototype.hasNext=function(){return 0!==this.q.length},n.prototype.isEmpty=function(){return 0===this.q.length},e.exports=n},{}],5:[function(t,e,o){"use strict";function n(){this.set={},this.numElems=0}n.prototype.size=function(){return this.numElems},n.prototype.isEmpty=function(){return 0===this.numElems},n.prototype.clear=function(){this.set={},this.numElems=0},n.prototype.getKey=function(t){var e=t;return"object"==typeof t&&(e=t.toString()),e},n.prototype.add=function(t){if(null===t)throw new TypeError("Cannot add a null to a set.");var e=this.getKey(t);this.containsKey(e)||this.numElems++,this.set[e]=t},n.prototype.remove=function(t){if(null===t)throw new TypeError("Cannot remove null from a set.");var e=this.getKey(t);if(!this.containsKey(e))throw new Error("Set does not contain "+e);delete this.set[e],this.numElems--},n.prototype.containsKey=function(t){return"undefined"!=typeof this.set[t]},n.prototype.contains=function(t){return"undefined"!=typeof this.find(t)},n.prototype.elems=function(){return this.set},n.prototype.find=function(t){var e=this.getKey(t);return this.set[e]},n.prototype.union=function(t){for(var e in t.elems())this.add(t.find(e))},n.prototype.intersect=function(t){var e={},o=0;for(var n in t.elems())this.containsKey(n)&&(o++,e[n]=this.find(n));this.set=e,this.numElems=o},n.prototype.toString=function(){var t="Set: {",e=0;for(var o in this.set){var n=this.set[o];t+=n,e<this.size()-1&&(t+=", "),e++}return t+="}"},e.exports=n},{}],6:[function(t,e,o){"use strict";function n(){this.stack=[]}n.prototype.size=function(){return this.stack.length},n.prototype.clear=function(){this.stack=[]},n.prototype.push=function(t){this.stack.push(t)},n.prototype.pop=function(){var t=this.stack.length,e=this.stack[t-1];return this.stack.splice(t-1,1),e},n.prototype.peek=function(){var t=this.stack.length,e=this.stack[t-1];return e},n.prototype.hasNext=function(){return 0!==this.stack.length},n.prototype.isEmpty=function(){return 0===this.stack.length},e.exports=n},{}],7:[function(t,e,o){"use strict";function n(t,e,o,s){if(4!==arguments.length)throw new Error('You should pass exactly 4 arguments to <span class="code">new Arc(raduis, startAngle, endAngle, angleUnit)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">radius</span>. Make sure you are passing finite numbers to <span class="code">new Arc(raduis, startAngle, endAngle, angleUnit)</span>');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">startAngle</span>. Make sure you are passing finite numbers to <span class="code">new Arc(raduis, startAngle, endAngle, angleUnit)</span>');if("number"!=typeof o||!isFinite(o))throw new TypeError('Invalid value for <span class="code">endAngle</span>. Make sure you are passing finite numbers to <span class="code">new Arc(raduis, startAngle, endAngle, angleUnit)</span>');if("number"!=typeof s||!isFinite(s))throw new TypeError('Invalid value for <span class="code">angleUnit</span>. Make sure you are passing finite numbers to <span class="code">new Arc(raduis, startAngle, endAngle, angleUnit)</span>');r.call(this),this.radius=t,this.angleUnit=s==n.DEGREES?n.DEGREES:n.RADIANS,this.counterclockwise=n.COUNTER_CLOCKWISE,this.type="Arc",this.angleUnit==n.DEGREES&&(e=a(e),o=a(o)),this.startAngle=e,this.endAngle=o}var r=t("./thing.js"),s=t("./graphics-utils.js");n.prototype=new r,n.prototype.constructor=n,n.COUNTER_CLOCKWISE=!0,n.CLOCKWISE=!1,n.DEGREES=0,n.RADIANS=1,n.prototype.draw=function(t){var e=t.getContext();e.save(),e.beginPath(),e.translate(this.x,this.y),e.rotate(this.rotation),e.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),this.counterclockwise),e.lineTo(0,0),this.hasBorder&&(e.lineWidth=this.lineWidth,e.strokeStyle=this.stroke.toString(),e.stroke()),e.fillStyle=this.color.toString(),e.fill(),e.restore()},n.prototype.setStartAngle=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setStartAngle</span>');if("number"!=typeof t||!isFinite(t))throw new Error('Invalid value passed to <span class="code">setStartAngle</span>. Make sure you are passing a finite number.');this.angleUnit==n.DEGREES&&(t=a(t)),this.startAngle=t},n.prototype.setEndAngle=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setEndAngle</span>');if("number"!=typeof t||!isFinite(t))throw new Error('Invalid value passed to <span class="code">setEndAngle</span>. Make sure you are passing a finite number.');this.angleUnit==n.DEGREES&&(t=a(t)),this.endAngle=t},n.prototype.getStartAngle=function(){var t=this.startAngle;return this.angleUnit==n.DEGREES&&(t=u(this.startAngle)),Math.round(t)},n.prototype.getEndAngle=function(){var t=this.endAngle;return this.angleUnit==n.DEGREES&&(t=u(this.endAngle)),Math.round(t)},n.prototype.setDirection=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setDirection</span>');if("boolean"!=typeof t)throw new Error('Invalid value passed to <span class="code">setDirection</span>. Make sure you are passing a boolean value. true for counterclockwise, false for clockwise.');this.counterclockwise=t},n.prototype.containsPoint=function(t,e){var o=s.getDistance(this.x,this.y,t,e);if(o>this.radius)return!1;var n=t-this.x,r=this.y-e,i=Math.atan(r/n);0>n?i+=Math.PI:0>r&&(i+=2*Math.PI);var a=i>=this.startAngle&&i<=this.endAngle;return this.counterclockwise?a:!a};var i=function(t){return t=u(t),t=Math.round(t),t=(360-t)%360,t=a(t)},a=function(t){return t/180*Math.PI},u=function(t){return t/Math.PI*180};e.exports=n},{"./graphics-utils.js":10,"./thing.js":21}],8:[function(t,e,o){"use strict";function n(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">new Circle(radius)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('You must pass a finite number to <span class="code">new Circle(radius)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');r.call(this),this.radius=Math.max(0,t),this.color=s.black,this.lineWidth=3,this.type="Circle"}var r=t("./thing.js"),s=t("./color.js"),i=t("./graphics-utils.js");n.prototype=new r,n.prototype.constructor=n,n.prototype.draw=function(t){var e=t.getContext();e.beginPath(),this.hasBorder&&(e.strokeStyle=this.stroke.toString(),e.lineWidth=this.lineWidth),e.fillStyle=this.color.toString(),e.arc(this.x,this.y,this.radius,0,2*Math.PI,!0),e.closePath(),this.hasBorder&&e.stroke(),e.fill()},n.prototype.getRadius=function(){return this.radius},n.prototype.getHeight=function(){return 2*this.radius},n.prototype.getWidth=function(){return 2*this.radius},n.prototype.setRadius=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setRadius(radius)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('You must pass a finite number to <span class="code">setRadius(radius)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.radius=Math.max(0,t)},n.prototype.containsPoint=function(t,e){var o=this.radius;this.hasBorder&&(o+=this.lineWidth);var n=i.getDistance(this.x,this.y,t,e);return o>n},e.exports=n},{"./color.js":9,"./graphics-utils.js":10,"./thing.js":21}],9:[function(t,e,o){"use strict";function n(t,e,o){this.r=t,this.g=e,this.b=o}function r(t,e,o){if(t=Math.floor(t),e=Math.floor(e),o=Math.floor(o),t>255||e>255||o>255)throw"Invalid color component";return(t<<16|e<<8|o).toString(16)}function s(t,e,o){return"#"+("000000"+r(t,e,o)).slice(-6)}function i(t,e,o){return 0>o&&(o+=1),o>1&&(o-=1),1/6>o?t+6*(e-t)*o:.5>o?e:2/3>o?t+(e-t)*(2/3-o)*6:t}var a=t("./randomizer.js");n.prototype.toString=function(){return n.createFromRGB(this.r,this.g,this.b)},n.random=a.nextColor,n.constants={red:"#FF0000",RED:"#FF0000",green:"#00FF00",GREEN:"#00FF00",blue:"#0000FF",BLUE:"#0000FF",yellow:"#FFFF00",YELLOW:"#FFFF00",cyan:"#00FFFF",CYAN:"#00FFFF",orange:"#FFA500",ORANGE:"#FFA500",white:"#FFFFFF",WHITE:"#FFFFFF",black:"#000000",BLACK:"#000000",gray:"#cccccc",GRAY:"#CCCCCC",grey:"#cccccc",GREY:"#CCCCCC",purple:"#9B30FF",PURPLE:"#9B30FF"};var u;for(u in n.constants)n[u]=n.constants[u];n.createFromRGB=function(t,e,o){return s(t,e,o)},n.randomRed=function(){var t=a.nextInt(50,255);return n.createFromRGB(t,0,0)},n.randomGreen=function(){var t=a.nextInt(50,255);return n.createFromRGB(0,t,0)},n.randomBlue=function(){var t=a.nextInt(50,255);return n.createFromRGB(0,0,t)},n.createFromRGBL=function(t,e,o,r){var s=n.rgbToHsl(t,e,o);0>r&&(r=0),r>1&&(r=1);var i=n.hslToRgb(s[0],s[1],r);return n.createFromRGB(i[0],i[1],i[2])},n.rgbToHsl=function(t,e,o){t/=255,e/=255,o/=255;var n,r,s=Math.max(t,e,o),i=Math.min(t,e,o),a=(s+i)/2;if(s==i)n=r=0;else{var u=s-i;switch(r=a>.5?u/(2-s-i):u/(s+i),s){case t:n=(e-o)/u+(o>e?6:0);break;case e:n=(o-t)/u+2;break;case o:n=(t-e)/u+4}n/=6}return[n,r,a]},n.hslToRgb=function(t,e,o){var n,r,s;if(0===e)n=r=s=o;else{var a=.5>o?o*(1+e):o+e-o*e,u=2*o-a;n=i(u,a,t+1/3),r=i(u,a,t),s=i(u,a,t-1/3)}return[255*n,255*r,255*s]},n.average=function(t,e){function o(t){return t.toString(16)}function n(t){return parseInt(t,16)}for(var r,s,i,a,u=/[\da-z]{2}/gi,l=t.match(u),c=e.match(u),h="#",p=0;p<l.length;p++)r=n(l[p]),s=n(c[p]),i=Math.floor(r+s>>1),a=o(i),1==a.length&&(a="0"+a),h+=a;return h},n.getColor=function(t){return n.constants[t]},n.getHexColor=function(t){return t},e.exports=n},{"./randomizer.js":18}],10:[function(t,e,o){"use strict";var n=function(t,e,o,n){return Math.sqrt(Math.pow(t-o,2)+Math.pow(e-n,2))};e.exports={getDistance:n}},{}],11:[function(t,e,o){"use strict";function n(t){t=t||{},this.resetAllState(),this.globalTimer=!0,this.currentCanvas=null,this.setCurrentCanvas(t.canvas),this.debugMode=t.debug||!1,this.instanceId=g,g++;var e=this.canvasHasInstance(t.canvas);if(null!==e){var o=f[e];o.stopTimer("MAIN_TIMER"),f[e]=this}else f.push(this)}Array.prototype.remove=function(t){return this.splice(t,1)[0]};var r,s,i,a,u=t("codehs-js-utils"),l=t("./graphics-utils.js"),c=40,h=[],p=[],d=[],f=[],g=0;n.registerPublicMethod=function(t){h.push(t)},n.registerConstructorMethod=function(t){p.push(t)},n.getNamespaceModifcationString=function(){for(var t="\n",e=0;e<h.length;e++){var o=h[e];t+="function "+o+"(){\n	return __graphics__."+o+".apply(__graphics__, arguments);\n}\n"}return t},n.getConstructorModificationString=function(){for(var t="",e=0;e<p.length;e++){var o=p[e];t+="var "+o+" = __graphics__."+o+";\n"}return t},n.prototype.add=function(t){this.elements.push(t)},n.registerPublicMethod("add"),window.oldAudio=window.Audio,n.prototype.Audio=function(t){var e=new oldAudio(t);return this.audioElements.push(e),e},n.prototype.Audio.constructor=window.oldAudio,n.registerPublicMethod("Audio"),n.prototype.waitForClick=function(){this.clickCount++},n.registerPublicMethod("waitForClick"),n.prototype.mouseClickMethod=function(t){this.clickCallback=u.safeCallback(t)},n.registerPublicMethod("mouseClickMethod"),n.prototype.mouseMoveMethod=function(t){this.moveCallback=u.safeCallback(t)},n.registerPublicMethod("mouseMoveMethod"),n.prototype.mouseDownMethod=function(t){this.mouseDownCallback=u.safeCallback(t)},n.registerPublicMethod("mouseDownMethod"),n.prototype.mouseUpMethod=function(t){this.mouseUpCallback=u.safeCallback(t)},n.registerPublicMethod("mouseUpMethod"),n.prototype.mouseDragMethod=function(t){this.dragCallback=u.safeCallback(t)},n.registerPublicMethod("mouseDragMethod"),n.prototype.keyDownMethod=function(t){this.keyDownCallback=u.safeCallback(t)},n.registerPublicMethod("keyDownMethod"),n.prototype.keyUpMethod=function(t){this.keyUpCallback=u.safeCallback(t)},n.registerPublicMethod("keyUpMethod"),n.prototype.deviceOrientationMethod=function(t){this.deviceOrientationCallback=u.safeCallback(t)},n.registerPublicMethod("deviceOrientationMethod"),n.prototype.deviceMotionMethod=function(t){this.deviceMotionCallback=u.safeCallback(t)},n.registerPublicMethod("deviceMotionMethod"),n.prototype.audioChangeMethod=function(t,e){a=new window.AudioContext,r=a.createAnalyser(),r.fftSize=128;var o=r.frequencyBinCount;s=new Uint8Array(o),i=a.createMediaElementSource(t),i.crossOrigin="anonymous",i.connect(r);var n=a.createGain();i.connect(n),n.connect(a.destination),this.audioChangeCallback=u.safeCallback(e),this.setGraphicsTimer(this.updateAudio.bind(this),c,null,"updateAudio")},n.registerPublicMethod("audioChangeMethod"),n.prototype.isKeyPressed=function(t){return-1!=d.indexOf(t)},n.registerPublicMethod("isKeyPressed"),n.prototype.getWidth=function(){var t=this.getCanvas();return parseFloat(t.getAttribute("width"))},n.registerPublicMethod("getWidth"),n.prototype.getHeight=function(){var t=this.getCanvas();return parseFloat(t.getAttribute("height"))},n.registerPublicMethod("getHeight"),n.prototype.stopTimer=function(t){var e="function"==typeof t?t.name:t;clearInterval(this.timers[e])},n.registerPublicMethod("stopTimer"),n.prototype.stopAllTimers=function(){for(var t=1;99999>t;t++)window.clearInterval(t);this.setMainTimer()},n.registerPublicMethod("stopAllTimers"),n.prototype.setTimer=function(t,e,o,n){if(arguments.length<2)throw new Error('2 parameters required for <span class="code">setTimer</span>, '+arguments.length+' found. You must provide a callback function and a number representing the time delay to <span class="code">setTimer</span>');if("function"!=typeof t)throw new TypeError('Invalid callback function. Make sure you are passing an actual function to <span class="code">setTimer</span>.');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for time delay. Make sure you are passing a finite number to <span class="code">setTimer</span> for the delay.');var r=this;(isNaN(e)||15>e)&&(e=15),this.waitingForClick()?this.delayedTimers.push({fn:t,time:e,data:o,clicks:r.clickCount,name:n}):this.setGraphicsTimer(t,e,o,n)},n.registerPublicMethod("setTimer"),n.prototype.setBackgroundColor=function(t){this.backgroundColor=t},n.registerPublicMethod("setBackgroundColor"),n.prototype.clear=function(t){var e=t||this.getContext();e.clearRect(0,0,this.getWidth(),this.getHeight())},n.registerPublicMethod("clear"),n.prototype.getElementAt=function(t,e){for(var o=this.elements.length-1;o>=0;o--)if(this.elements[o].containsPoint(t,e,this))return this.elements[o];return null},n.registerPublicMethod("getElementAt"),n.prototype.elementExistsWithParameters=function(t){for(var e=this.elements.length-1;e>=0;e--){var o=this.elements[e];try{if(void 0!==t.x&&this.runCode("return "+t.x).result.toFixed(0)!=o.getX().toFixed(0))continue;if(void 0!==t.y&&this.runCode("return "+t.y).result.toFixed(0)!=o.getY().toFixed(0))continue;if(void 0!==t.width&&this.runCode("return "+t.width).result.toFixed(0)!=o.getWidth().toFixed(0))continue;if(void 0!==t.height&&this.runCode("return "+t.height).result.toFixed(0)!=o.getHeight().toFixed(0))continue;if(void 0!==t.radius&&this.runCode("return "+t.radius).result.toFixed(0)!=o.getRadius().toFixed(0))continue;if(void 0!==t.color&&this.runCode("return "+t.color).result!=o.getColor())continue;if(void 0!==t.label&&t.label!=o.getLabel())continue;if(void 0!==t.type&&t.type!=o.getType())continue}catch(n){continue}return!0}return!1},n.registerPublicMethod("elementExistsWithParameters"),n.prototype.removeAll=function(){this.elements=[]},n.registerPublicMethod("removeAll"),n.prototype.remove=function(t){for(var e=0;e<this.elements.length;e++)this.elements[e]==t&&this.elements.splice(e,1)},n.registerPublicMethod("remove"),n.prototype.setSize=function(t,e){var o=this.getCanvas();o.width=t,o.height=e},n.registerPublicMethod("setSize"),n.prototype.Rectangle=t("./rectangle.js"),n.registerConstructorMethod("Rectangle"),n.prototype.Circle=t("./circle.js"),n.registerConstructorMethod("Circle"),n.prototype.Line=t("./line.js"),n.registerConstructorMethod("Line"),n.prototype.Grid=t("./grid.js"),n.registerConstructorMethod("Grid"),n.prototype.Line=t("./line.js"),n.registerConstructorMethod("Line"),n.prototype.Polygon=t("./polygon.js"),n.registerConstructorMethod("Polygon"),n.prototype.Text=t("./text.js"),n.registerConstructorMethod("Text"),n.prototype.Oval=t("./oval.js"),n.registerConstructorMethod("Oval"),n.prototype.Arc=t("./arc.js"),n.registerConstructorMethod("Arc"),n.prototype.Color=t("./color.js"),n.registerConstructorMethod("Color"),n.prototype.WebImage=t("./webimage.js"),n.registerConstructorMethod("WebImage"),n.prototype.ImageLibrary=t("./imagelibrary.js"),n.registerConstructorMethod("ImageLibrary"),n.prototype.runCode=function(t){var e=n.getNamespaceModifcationString(),o=n.getConstructorModificationString(),r="";return r+=e,r+=o,r+="\nText.giveDefaultContext(__graphics__);\n",r+=t,r+="\n\nif(typeof start == 'function') {start();} ",u.safeEval(r,this,"__graphics__")},n.prototype.resetAllTimers=function(){for(var t in this.timers)clearInterval(this.timers[t])},n.prototype.stopAllAudio=function(){this.audioElements.forEach(function(t){t.pause()})},n.prototype.resetAllState=function(){this.backgroundColor=null,this.elements=[],this.audioElements=[],this.clickCallback=null,this.moveCallback=null,this.mouseDownCallback=null,this.mouseUpCallback=null,this.dragCallback=null,this.keyDownCallback=null,this.keyUpCallback=null,this.deviceOrientationCallback=null,this.deviceMotionCallback=null,this.audioChangeCallback=null,a&&a.close(),i&&i.disconnect(),this.timers={},this.timersList=[],this.clickCount=0,this.delayedTimers=[]},n.prototype.fullReset=function(){this.stopAllAudio(),this.resetAllTimers(),this.resetAllState(),this.setMainTimer()},n.prototype.canvasExists=function(){return null!==this.getCanvas()},n.prototype.getCanvas=function(){return this.currentCanvas},n.prototype.setCurrentCanvas=function(t){t?this.currentCanvas=$(t)[0]:this.currentCanvas=document.getElementsByTagName("canvas")[0],this.currentCanvas||(this.currentCanvas=null),this.fullReset(),this.setup()},n.prototype.stopGlobalTimer=function(){this.globalTimer=!1},n.prototype.drawBackground=function(){if(this.backgroundColor){var t=this.getContext();t.fillStyle=this.backgroundColor,t.beginPath(),t.rect(0,0,this.getWidth(),this.getHeight()),t.closePath(),t.fill()}},n.prototype.getContext=function(){var t=this.getCanvas();if(t&&t.getContext){var e=t.getContext("2d");return e}return null},n.prototype.redraw=function(){this.clear(),this.drawBackground();for(var t=0;t<this.elements.length;t++)this.elements[t].draw(this)},n.prototype.setMainTimer=function(){var t=this;this.globalTimer&&this.setTimer(function(){t.redraw()},c,null,"MAIN_TIMER")},n.prototype.waitingForClick=function(){return 0!==this.clickCount},n.prototype.canvasHasInstance=function(t){for(var e,o=0;o<f.length;o++)if(e=f[o],e.instanceId!==this.instanceId&&e.getCanvas()===t)return e.instanceId;return null},n.prototype.getDistance=function(t,e,o,n){return l.getDistance(t,e,o,n)},n.prototype.setup=function(){var t=this,e=this.getCanvas();e.onclick=function(e){if(t.waitingForClick()){t.clickCount--;for(var o=0;o<t.delayedTimers.length;o++){var n=t.delayedTimers[o];n.clicks--,0===n.clicks&&t.setGraphicsTimer(n.fn,n.time,n.data)}}else t.clickCallback&&t.clickCallback(e)};var o=!1;e.onmousemove=function(e){t.moveCallback&&t.moveCallback(e),o&&t.dragCallback&&t.dragCallback(e)},e.onmousedown=function(e){o=!0,t.mouseDownCallback&&t.mouseDownCallback(e)},e.onmouseup=function(e){o=!1,t.mouseUpCallback&&t.mouseUpCallback(e)},e.ontouchmove=function(e){e.preventDefault(),t.dragCallback?t.dragCallback(e):t.moveCallback&&t.moveCallback(e)},e.ontouchstart=function(e){if(e.preventDefault(),t.mouseDownCallback?t.mouseDownCallback(e):t.clickCallback&&t.clickCallback(e),t.waitingForClick()){t.clickCount--;for(var o=0;o<t.delayedTimers.length;o++){var n=t.delayedTimers[o];n.clicks--,0===n.clicks&&t.setGraphicsTimer(n.fn,n.time,n.data)}}else;},e.ontouchend=function(e){e.preventDefault(),t.mouseUpCallback&&t.mouseUpCallback(e)}},n.prototype.setGraphicsTimer=function(t,e,o,n){"undefined"==typeof n&&(n=t.name),this.timers[n]=u.safeSetInterval(t,o,e),this.timersList.push({name:n,fn:t,data:o,time:e})},n.prototype.updateAudio=function(){if(r.getByteFrequencyData(s),this.audioChangeCallback){var t=46;this.audioChangeCallback(s.slice(0,t))}},window.onkeydown=function(t){var e=d.indexOf(t.keyCode);-1===e&&d.push(t.keyCode);for(var o,n=0;n<f.length;n++){var r=f[n];r.keyDownCallback&&(r.keyDownCallback(t),o=!0,t.keyCode==Keyboard.SPACE&&(o=!1),t.keyCode>=Keyboard.LEFT&&t.keyCode<=Keyboard.DOWN&&(o=!1))}return o},window.onkeyup=function(t){var e=d.indexOf(t.keyCode);-1!==e&&d.splice(e,1);for(var o=0;o<f.length;o++){var n=f[o];n.keyUpCallback&&n.keyUpCallback(t)}},window.DeviceOrientationEvent&&(window.ondeviceorientation=function(t){for(var e=0;e<f.length;e++){var o=f[e];o.deviceOrientationCallback&&o.deviceOrientationCallback(t)}}),window.DeviceMotionEvent&&(window.ondevicemotion=function(t){for(var e=0;e<f.length;e++){var o=f[e];o.deviceMotionCallback&&o.deviceMotionCallback(t)}}),n.getBaseCoordinates=function(t,e){var o,n;t.pageX||t.pageY?(o=t.pageX,n=t.pageY):(o=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,n=t.clientY+document.body.scrollTop+document.documentElement.scrollTop);var r=e.offset();return o-=r.left,n-=r.top,{x:o,y:n}},n.getMouseCoordinates=function(t){var e=n.getBaseCoordinates(t,$(t.currentTarget)),o=e.x,r=e.y;return o=Math.round(o),r=Math.round(r),{x:o,y:r}},n.getTouchCoordinates=function(t){var e=n.getBaseCoordinates(t,$(t.target)),o=e.x,r=e.y,s=$("#game").width(),i=$("#game").attr("width"),a=i/s;return o*=a,r*=a,o=Math.round(o),r=Math.round(r),{x:o,y:r}},MouseEvent.prototype.getX=function(){return n.getMouseCoordinates(this).x},MouseEvent.prototype.getY=function(){return n.getMouseCoordinates(this).y},"undefined"!=typeof TouchEvent&&(TouchEvent.prototype.getX=function(){return n.getTouchCoordinates(this.touches[0]).x},TouchEvent.prototype.getY=function(){return n.getTouchCoordinates(this.touches[0]).y}),e.exports={CodeHSGraphics:n,PUBLIC_METHODS:h,PUBLIC_CONSTRUCTORS:p}},{"./arc.js":7,"./circle.js":8,"./color.js":9,"./graphics-utils.js":10,"./grid.js":13,"./imagelibrary.js":14,"./line.js":15,"./oval.js":16,"./polygon.js":17,"./rectangle.js":19,"./text.js":20,"./webimage.js":22,"codehs-js-utils":23}],12:[function(t,e,o){"use strict";var n=t("./graphics.js"),r=n.CodeHSGraphics,s=n.PUBLIC_CONSTRUCTORS,i=n.PUBLIC_METHODS,a=t("./webimage.js"),u=t("./polygon.js"),l=t("./color.js"),c=t("./randomizer.js"),h=t("./text.js"),p=t("./grid.js"),d=t("./circle.js"),f=t("./line.js"),g=t("./rectangle.js"),y=t("./imagelibrary.js");e.exports={CodeHSGraphics:r,PUBLIC_METHODS:i,PUBLIC_CONSTRUCTORS:s,WebImage:a,ImageLibrary:y,Polygon:u,Color:l,Randomizer:c,Text:h,Grid:p,Circle:d,Line:f,Rectangle:g}},{"./circle.js":8,"./color.js":9,"./graphics.js":11,"./grid.js":13,"./imagelibrary.js":14,"./line.js":15,"./polygon.js":17,"./randomizer.js":18,"./rectangle.js":19,"./text.js":20,"./webimage.js":22}],13:[function(t,e,o){"use strict";function n(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">new Grid(rows, cols)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">rows</span>. Make sure you are passing finite numbers to <span class="code">new Grid(rows, cols)</span>.');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">cols</span>. Make sure you are passing finite numbers to <span class="code">new Grid(rows, cols)</span>.');t=Math.max(0,t),e=Math.max(0,e),this.grid=new Array(t);for(var o=0;t>o;o++)this.grid[o]=new Array(e)}n.prototype.initFromArray=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">initFromArray</span>');if(!Array.isArray(t))throw new Error('Invalid value passed to <span class="code">initFromArray</span>. Make sure you are passing an array.');for(var e=0;e<t.length;e++)for(var o=0;o<t[0].length;o++)this.inBounds(e,o)&&this.set(e,o,t[e][o])},n.prototype.init=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">init</span>');if("boolean"!=typeof t&&"number"!=typeof t&&"string"!=typeof t&&"object"!=typeof t)throw new TypeError('Invalid value passed to <span class="code">init</span>. You passed a value of type '+typeof t+". Make sure you are passing a number, string, object, or boolean value.");if("number"==typeof t&&!isFinite(t))throw new TypeError('Non finite number passed to <span class="code">init</span>. If you are passing a number, make sure it is a finite number.');
for(var e=0;e<this.numRows();e++)for(var o=0;o<this.numCols();o++)this.grid[e][o]=t},n.prototype.get=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">get(row, col)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">row</span>. Make sure you are passing finite numbers to <span class="code">get(row, col)</span>.');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">col</span>. Make sure you are passing finite numbers to <span class="code">get(row, col)</span>.');return this.grid[t][e]},n.prototype.set=function(t,e,o){if(3!==arguments.length)throw new Error('You should pass exactly 3 arguments to <span class="code">set(row, col, value)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">row</span>. You passed a value of type '+typeof t+". Make sure you are passing a number.");if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">col</span>. You passed a value of type '+typeof e+". Make sure you are passing a number.");if("boolean"!=typeof o&&"number"!=typeof o&&"string"!=typeof o&&"object"!=typeof o)throw new TypeError('Invalid value passed to <span class="code">set</span>. You passed a value of type '+typeof o+". Make sure you are passing a number, string, object, or boolean value.");if("number"==typeof o&&!isFinite(o))throw new TypeError('Non finite value passed to <span class="code">set</span>. If you are passing a number, make sure it is a finite number.');this.grid[t][e]=o},n.prototype.numRows=function(){return this.grid.length},n.prototype.numCols=function(){return this.grid[0].length},n.prototype.inBounds=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">inBounds(row, col)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">row</span>. Make sure you are passing finite numbers to <span class="code">inBounds(row, col)</span>.');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">col</span>. Make sure you are passing finite numbers to <span class="code">inBounds(row, col)</span>.');return 0>t||0>e?!1:t>=this.numRows()||e>=this.numCols()?!1:!0},n.prototype.toList=function(){for(var t=[],e=0;e<this.grid.length;e++)for(var o=0;o<this.grid[0].length;o++){var n=this.grid[e][o];n&&0!==n&&t.push([e,o,n])}return t},n.prototype.toString=function(){for(var t="",e=0;e<this.numRows();e++){for(var o=0;o<this.numCols();o++)t+=this.get(e,o)+" ";t+="<br/>"}return t},e.exports=n},{}],14:[function(t,e,o){e.exports={Characters:{penguin:"https://codehs.com/static/img/library/characters/penguin.png",monkey:"https://codehs.com/static/img/library/characters/monkey.jpg",leopard:"https://codehs.com/static/img/library/characters/leopard.jpg",chameleon:"https://codehs.com/static/img/library/characters/chameleon.jpg",lizard:"https://codehs.com/static/img/library/characters/lizard.jpg",butterfly:"https://codehs.com/static/img/library/characters/butterfly.jpg",secretMessage:"https://codehs.com/static/img/library/characters/secretMessage.png"},Objects:{icicle:"https://codehs.com/static/img/library/objects/icicle.png",helicopter:"https://codehs.com/static/img/library/objects/helicopter.png",asteroid:"https://codehs.com/static/img/library/objects/asteroid.png",soccerBall:"https://codehs.com/static/img/library/objects/soccerBall.png"},Landscapes:{flowers:"https://codehs.com/static/img/library/landscapes/flowers.jpg"}}},{}],15:[function(t,e,o){"use strict";function n(t,e,o,n){if(4!==arguments.length)throw new Error('You should pass exactly 4 argument to <span class="code">new Line(x1, y1, x2, y2)</span>');if("number"!=typeof t||"number"!=typeof e||"number"!=typeof o||"number"!=typeof n)throw new TypeError('You must pass 4 numbers to <span class="code">new Line(x1, y1, x2, y2)</span>. Make sure each parameter youare passing is a number.');if(!(isFinite(t)&&isFinite(e)&&isFinite(o)&&isFinite(n)))throw new TypeError('One or more of the values you passed to <span class="code">new Line(x1, y1, x2, y2)</span> is an illegal number. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');r.call(this),this.x1=t,this.y1=e,this.x2=o,this.y2=n,this.lineWidth=2,this.type="Line"}var r=t("./thing.js");n.prototype=new r,n.prototype.constructor=n,n.prototype.setColor=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setColor(color)</span>.');if(void 0===t)throw new TypeError("Invalid color");this.stroke=t},n.prototype.getColor=function(){return this.stroke},n.prototype.draw=function(t){var e=t.getContext();e.save(),e.fillStyle=this.color.toString(),e.beginPath(),e.strokeStyle=this.stroke.toString(),e.lineWidth=this.lineWidth;var o=s(this.x1,this.y1,this.x2,this.y2,this.rotation);e.moveTo(o[0],o[1]),e.lineTo(o[2],o[3]),e.closePath(),e.stroke(),e.restore()};var s=function(t,e,o,n,r){var s,i,a=(t+o)/2,u=(e+n)/2,l=Math.sin(r),c=Math.cos(r);return t-=a,e-=u,s=t*c-e*l,i=t*l+e*c,t=s+a,e=i+u,o-=a,n-=u,s=o*c-n*l,i=o*l+n*c,o=s+a,n=i+u,[t,e,o,n]};n.prototype.containsPoint=function(t,e){return!1},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.setLineWidth=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setLineWidth</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('You must pass a finite number to <span class="code">setLineWidth(width)</span>. Did you perform a calculation on a variable that is not a number?');this.lineWidth=t},n.prototype.setStartpoint=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">setStartpoint(x, y)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for x-coordinate. Make sure you are passing finite numbers to <span class="code">setStartpoint(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for y-coordinate. Make sure you are passing finite numbers to <span class="code">setStartpoint(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.setPosition(t,e)},n.prototype.setPosition=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">setPosition(x, y)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for x-coordinate. Make sure you are passing finite numbers to <span class="code">setPosition(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for y-coordinate. Make sure you are passing finite numbers to <span class="code">setPosition(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.x1=t,this.y1=e},n.prototype.setEndpoint=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">setEndpoint(x, y)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for x-coordinate. Make sure you are passing finite numbers to <span class="code">setEndpoint(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for y-coordinate. Make sure you are passing finite numbers to <span class="code">setEndpoint(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.x2=t,this.y2=e},n.prototype.move=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">move</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid number passed for <span class="code">dx</span>. Make sure you are passing finite numbers to <span class="code">move(dx, dy)</span>');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid number passed for <span class="code">dy</span>. Make sure you are passing finite numbers to <span class="code">move(dx, dy)</span>');this.x1+=t,this.y1+=e,this.x2+=t,this.y2+=e},n.prototype.getX=function(){return this.x1},n.prototype.getY=function(){return this.y1},n.prototype.getStartX=function(){return this.x1},n.prototype.getStartY=function(){return this.y1},n.prototype.getEndX=function(){return this.x2},n.prototype.getEndY=function(){return this.y2},e.exports=n},{"./thing.js":21}],16:[function(t,e,o){"use strict";function n(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">new Oval(width, height)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">width</span>. Make sure you are passing finite numbers to <span class="code">new Oval(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">height</span>. Make sure you are passing finite numbers to <span class="code">new Oval(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');r.call(this),this.width=Math.max(0,t),this.height=Math.max(0,e),this.type="Oval"}var r=t("./thing.js");n.prototype=new r,n.prototype.constructor=n,n.prototype.draw=function(t){var e=t.getContext();e.save(),e.translate(this.x,this.y),e.rotate(this.rotation);var o=this.width,n=this.height,r=-o/2,s=-n/2,i=.5522848,a=o/2*i,u=n/2*i,l=r+o,c=s+n,h=r+o/2,p=s+n/2;e.beginPath(),e.moveTo(r,p),e.bezierCurveTo(r,p-u,h-a,s,h,s),e.bezierCurveTo(h+a,s,l,p-u,l,p),e.bezierCurveTo(l,p+u,h+a,c,h,c),e.bezierCurveTo(h-a,c,r,p+u,r,p),e.fillStyle=this.color.toString(),e.fill(),this.hasBorder&&(e.strokeStyle=this.stroke.toString(),e.lineWidth=this.lineWidth,e.stroke()),e.closePath(),e.restore()},n.prototype.getHeight=function(){return this.height},n.prototype.getWidth=function(){return this.width},n.prototype.setWidth=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setWidth(width)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('You must pass a finite number to <span class="code">setWidth(width)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.width=Math.max(0,t)},n.prototype.setHeight=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setHeight(height)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('You must pass a finite number to <span class="code">setHeight(height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.height=Math.max(0,t)},n.prototype.containsPoint=function(t,e){var o=Math.pow(this.width/2,2),n=Math.pow(this.height/2,2),r=Math.pow(t-this.x,2),s=Math.pow(e-this.y,2),i=r/o+s/n;return 1>=i},e.exports=n},{"./thing.js":21}],17:[function(t,e,o){"use strict";function n(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">new Polygon(width, height)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">width</span>. Make sure you are passing finite numbers to <span class="code">new Polygon(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">height</span>. Make sure you are passing finite numbers to <span class="code">new Polygon(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');r.call(this),this.points=[],this.width=Math.max(0,t),this.height=Math.max(0,e),this.type="Polygon"}var r=t("./thing.js");n.prototype=new r,n.prototype.constructor=n,n.prototype.draw=function(t){if(0!==this.points.length){var e=t.getContext();e.fillStyle=this.color.toString(),e.beginPath();var o=this.points[0];e.moveTo(o.x,o.y);for(var n=1;n<this.points.length;n++){var r=this.points[n];e.lineTo(r.x,r.y)}e.closePath(),e.fill()}},n.prototype.containsPoint=function(t,e){return t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.addPoint=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">addPoint(x, y)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for x-coordinate. Make sure you are passing finite numbers to <span class="code">addPoint(x, y)</span>.');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for y-coordinate. Make sure you are passing finite numbers to <span class="code">addPoint(x, y)</span>.');this.points.push({x:t,y:e})},e.exports=n},{"./thing.js":21}],18:[function(t,e,o){"use strict";var n=function(t,e){"undefined"==typeof e&&(e=t-1,t=0),t=Math.floor(t);var o=Math.random();return t+Math.floor(o*(e-t+1))},r=function(t,e){return"undefined"==typeof e&&(e=t,t=0),t+(e-t)*Math.random()},s=function(){var t=n(0,255);return 16>t?"0"+t.toString(16):t.toString(16)},i=function(){var t=s(),e=s(),o=s();return"#"+t+e+o},a=function(t){return"undefined"==typeof t&&(t=.5),Math.random()<t};e.exports={nextInt:n,nextFloat:r,nextHex:s,nextColor:i,nextBoolean:a}},{}],19:[function(t,e,o){"use strict";function n(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">new Rectange(width, height)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for <span class="code">width</span>. Make sure you are passing finite numbers to <span class="code">new Rectangle(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">height</span>. Make sure you are passing finite numbers to <span class="code">new Rectangle(width, height)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');r.call(this),this.width=Math.max(0,t),this.height=Math.max(0,e),this.type="Rectangle"}var r=t("./thing.js");n.prototype=new r,n.prototype.constructor=n,n.prototype.draw=function(t){var e=t.getContext();e.save(),e.fillStyle=this.color.toString(),this.hasBorder&&(e.lineWidth=this.lineWidth,e.strokeStyle=this.stroke.toString()),e.beginPath(),e.translate(this.x+this.width/2,this.y+this.height/2),e.rotate(this.rotation),e.rect(-this.width/2,-this.height/2,this.width,this.height),e.closePath(),this.hasBorder&&e.stroke(),e.fill(),e.restore()},n.prototype.containsPoint=function(t,e){return t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},e.exports=n},{"./thing.js":21}],20:[function(t,e,o){"use strict";function n(t,e){if(arguments.length<1)throw new Error('You should pass at least one argument to <span class="code">new Text(label, font)</span>. <span class="code">label</span> is a required parameter.');if("string"!=typeof t&&"number"!=typeof t)throw new TypeError('Invalid value for <span class="code">label</span>. You passed a value of type '+typeof t+" but a string or number is required.");if(e=void 0===e?"20pt Arial":e,"string"!=typeof e)throw new TypeError('Invalid value for <span class="code">font</span>. You passed a value of type '+typeof t+" but a string is required.");r.call(this),this.label=t,this.type="Text",this.font=e,this.context=null,this.resetDimensions()}var r=t("./thing.js");n.prototype=new r,n.prototype.constructor=n,n.defaultContext=null,n.giveDefaultContext=function(t){n.defaultContext=t.getContext()},n.prototype.resetDimensions=function(){var t=this.context||n.defaultContext;t.font=this.font,this.width=t.measureText(this.label).width,this.height=1.2*t.measureText("m").width},n.prototype.draw=function(t){var e=t.getContext();this.context=e,e.save(),e.fillStyle=this.color.toString(),e.beginPath(),e.font=this.font,this.resetDimensions(),e.translate(this.x,this.y),e.rotate(this.rotation),e.fillText(this.label,0,0),e.closePath(),e.fill(),e.restore()},n.prototype.setFont=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setFont</span>');if("string"!=typeof t)throw new TypeError('Invalid value passed to <span class="code">setFont</span>. You passed a value of type '+typeof label+", but a string is required.");this.font=t,this.resetDimensions()},n.prototype.setLabel=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setLabel</span>');if("string"!=typeof t&&"number"!=typeof t)throw new TypeError('Invalid value passed to <span class="code">setLabel</span>. You passed a value of type '+typeof t+", but a string or number is required.");this.label=t,this.resetDimensions()},n.prototype.setText=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setText</span>');if("string"!=typeof t&&"number"!=typeof t)throw new TypeError('Invalid value passed to <span class="code">setText</span>. You passed a value of type '+typeof t+", but a string or number is required.");this.label=t,this.resetDimensions()},n.prototype.getLabel=function(){return this.label},n.prototype.getText=function(){return this.label},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.containsPoint=function(t,e){return t>=this.x&&t<=this.x+this.width&&e<=this.y&&e>=this.y-this.height},e.exports=n},{"./thing.js":21}],21:[function(t,e,o){"use strict";function n(){this.x=0,this.y=0,this.color="#000000",this.stroke="#000000",this.type="Thing",this.lineWidth=1,this.filled=!0,this.hasBorder=!1,this.rotation=0}n.DEGREES=0,n.RADIANS=1,n.prototype.setFilled=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setFilled</span>');if("boolean"!=typeof t)throw new Error('Invalid value passed to <span class="code">setFilled</span>. Make sure you are passing a boolean value.');this.filled=t},n.prototype.isFilled=function(){return this.filled},n.prototype.setBorder=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setBorder</span>');if("boolean"!=typeof t)throw new Error('Invalid value passed to <span class="code">setBorder</span>. Make sure you are passing a boolean value.');this.hasBorder=t},n.prototype.hasBorder=function(){return this.hasBorder},n.prototype.setType=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setType</span>');this.type=t},n.prototype.getType=function(){return this.type},n.prototype.setPosition=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">setPosition(x, y)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for x-coordinate. Make sure you are passing finite numbers to <span class="code">setPosition(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for y-coordinate. Make sure you are passing finite numbers to <span class="code">setPosition(x, y)</span>. Did you forget the parentheses in <span class="code">getWidth()</span> or <span class="code">getHeight()</span>? Or did you perform a calculation on a variable that is not a number?');this.x=t,this.y=e},n.prototype.setRotation=function(t,e){if(arguments.length<1||arguments.length>2)throw new Error('You should pass 1 or 2 arguments to <span class="code">setRotation(degrees, angleUnit)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for degrees. Make sure you are passing finite numbers to <span class="code">setRotation(degrees, angleUnit)</span>. Did you perform a calculation on a variable that is not a number?');if(e||(e=n.DEGREES),"number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">angleUnit</span>. Make sure you are passing finite numbers to <span class="code">setRotation(degrees, angleUnit)</span>');e==n.DEGREES?this.rotation=t*Math.PI/180:this.rotation=t},n.prototype.rotate=function(t,e){if(arguments.length<1||arguments.length>2)throw new Error('You should pass exactly 1 argument to <span class="code">rotate(degrees, angleUnit)</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid value for degrees. Make sure you are passing finite numbers to <span class="code">rotate(degrees, angleUnit)</span>. Did you perform a calculation on a variable that is not a number?');if(e||(e=n.DEGREES),"number"!=typeof e||!isFinite(e))throw new TypeError('Invalid value for <span class="code">angleUnit</span>. Make sure you are passing finite numbers to <span class="code">rotate(degrees, angleUnit)</span>');e==n.DEGREES?this.rotation+=t*Math.PI/180:this.rotation+=t},n.prototype.setColor=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setColor</span>');if(void 0===t)throw new TypeError("Invalid color");this.color=t},n.prototype.getColor=function(){return this.color},n.prototype.setBorderColor=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setBorderColor</span>');if(void 0===t)throw new TypeError("Invalid color.");this.stroke=t,this.hasBorder=!0},n.prototype.getBorderColor=function(){return this.stroke},n.prototype.setBorderWidth=function(t){if(1!==arguments.length)throw new Error('You should pass exactly 1 argument to <span class="code">setBorderWidth</span>');if("number"!=typeof t||!isFinite(t))throw new Error('Invalid value for border width. Make sure you are passing a finite number to <span class="code">setBorderWidth</span>');this.lineWidth=t,this.hasBorder=!0},n.prototype.getBorderWidth=function(){return this.lineWidth},n.prototype.move=function(t,e){if(2!==arguments.length)throw new Error('You should pass exactly 2 arguments to <span class="code">move</span>');if("number"!=typeof t||!isFinite(t))throw new TypeError('Invalid number passed for <span class="code">dx</span>. Make sure you are passing finite numbers to <span class="code">move(dx, dy)</span>');if("number"!=typeof e||!isFinite(e))throw new TypeError('Invalid number passed for <span class="code">dy</span>. Make sure you are passing finite numbers to <span class="code">move(dx, dy)</span>');this.x+=t,this.y+=e},n.prototype.getX=function(){return this.x},n.prototype.getY=function(){return this.y},n.prototype.draw=function(){},n.prototype.containsPoint=function(t,e){return!1},e.exports=n},{}],22:[function(t,e,o){"use strict";function n(t){if("string"!=typeof t)throw new TypeError('You must pass a string to <span class="code">new WebImage(filename)</span> that has the image\'s location.');r.call(this);var e=this;this.image=new Image,this.image.src=t,this.filename=t,this.width=i,this.height=i,this.image.onload=function(){e.checkDimensions(),e.loadfn&&e.loadfn()},this.set=0,this.type="WebImage",this.displayFromData=!1,this.isCrossOrigin=!1,this.data=i}var r=t("./thing.js"),s=-1,i=1,a=4,u=0,l=1,c=2,h=3;n.prototype=new r,n.prototype.constructor=n,n.prototype.loaded=function(t){this.loadfn=t},n.prototype.setImage=function(t){var e=this;this.image=new Image,this.image.src=t,this.filename=t,this.width=i,this.height=i,this.image.onload=function(){e.checkDimensions(),e.loadfn&&e.loadfn()},this.set=0,this.displayFromData=!1,this.isCrossOrigin=!1,this.data=i},n.prototype.checkDimensions=function(){this.width==i&&(this.width=this.image.width,this.height=this.image.height)},n.prototype.draw=function(t){this.checkDimensions();var e=t.getContext("2d");e.save(),e.beginPath(),e.translate(this.x+this.width/2,this.y+this.height/2),e.rotate(this.rotation),this.displayFromData&&this.data!==i?e.putImageData(this.data,this.x,this.y):e.drawImage(this.image,-this.width/2,-this.height/2,this.width,this.height);try{this.data!==i||this.isCrossOrigin||(this.data=e.getImageData(this.x,this.y,this.width,this.height))}catch(o){this.data=i,this.isCrossOrigin=!0}e.closePath(),e.restore()},n.prototype.getData=function(t){var e=t.getContext();this.data=e.getImageData(this.x,this.y,this.width,this.height)},n.prototype.containsPoint=function(t,e){return t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.setSize=function(t,e){this.width=t,this.height=e},n.prototype.getPixel=function(t,e){if(this.data===i||t>this.width||0>t||e>this.height||0>e){var o=[s,s,s,s];return o}var n=a*(e*this.width+t),r=[this.data.data[n+u],this.data.data[n+l],this.data.data[n+c],this.data.data[n+h]];return r},n.prototype.getRed=function(t,e){return this.getPixel(t,e)[u]},n.prototype.getGreen=function(t,e){return this.getPixel(t,e)[l]},n.prototype.getBlue=function(t,e){return this.getPixel(t,e)[c]},n.prototype.getAlpha=function(t,e){return this.getPixel(t,e)[h]},n.prototype.setPixel=function(t,e,o,n){if(this.data!==i&&!(0>t||0>e||t>this.width||e>this.height)){var r=a*(e*this.width+t);this.data.data[r+o]=n,this.displayFromData=!0}},n.prototype.setRed=function(t,e,o){this.setPixel(t,e,u,o)},n.prototype.setGreen=function(t,e,o){this.setPixel(t,e,l,o)},n.prototype.setBlue=function(t,e,o){this.setPixel(t,e,c,o)},n.prototype.setAlpha=function(t,e,o){this.setPixel(t,e,h,o)},e.exports=n},{"./thing.js":21}],23:[function(require,module,exports){"use strict";function linesWithoutSemicolons(t){var e=window.jslint(t),o=e.warnings,n=[];return o&&o.length&&_.each(o,function(t){t&&"expected_a_b"==t.code&&";"==t.a&&n.push(t.line+1)}),n}function removeComments(t){t=t.split("");for(var e={singleQuote:!1,doubleQuote:!1,blockComment:!1,lineComment:!1,condComp:!1},o=0,n=t.length;n>o;o++)if(e.singleQuote)"'"===t[o]&&"\\"!==t[o-1]&&(e.singleQuote=!1);else if(e.doubleQuote)'"'===t[o]&&"\\"!==t[o-1]&&(e.doubleQuote=!1);else if(e.blockComment)"*"===t[o]&&"/"===t[o+1]&&("\n"!==t[o+1]&&(t[o+1]=""),e.blockComment=!1),"\n"!==t[o]&&(t[o]="");else if(e.lineComment)("\n"===t[o+1]||"\r"===t[o+1])&&(e.lineComment=!1),"\n"!==t[o]&&(t[o]="");else if(e.condComp)"@"===t[o-2]&&"*"===t[o-1]&&"/"===t[o]&&(e.condComp=!1);else if(e.doubleQuote='"'===t[o],e.singleQuote="'"===t[o],"/"===t[o]){if("*"===t[o+1]&&"@"===t[o+2]){e.condComp=!0;continue}if("*"===t[o+1]){"\n"!==t[o]&&(t[o]=""),e.blockComment=!0;continue}if("/"===t[o+1]){"\n"!==t[o]&&(t[o]=""),e.lineComment=!0;continue}}return t.join("")}function lineNumberFromError(t){var e=-1;t.stack.replace(/<anonymous>:(.*):/gm,function(t,o,n,r){-1==e&&(e=parseInt(o))});return e}function generateCodeArray(t){var e=t.split("\n");return e}function safeEditorCode(t,e){e=e||{};var o=e.fnOnError||function(){},n=e.toTryArgs||[],r=e.errorType||"eval";try{return t.apply(null,n)}catch(s){return window.CHS&&window.CHS.PubSub.trigger("editorError:handle",s,r),o()}}function safeEval(code,context,contextName){var __context__=context;code="(function("+contextName+"){"+code,code+="})(__context__);";var fnToTry=function(){return{result:eval(code),hasError:!1}},fnOnError=function(){return{hasError:!0}};return safeEditorCode(fnToTry,{fnOnError:fnOnError,errorType:"eval"})}function testInfiniteLoops(t){try{t="function start(){}\n"+t,t+="\nstart();";for(var e=new Interpreter(t),o=2e4,n=0;!e.paused_&&e.step()&&o>=n;)n++;if(n>=o)return!0}catch(r){return!1}}function safeSkulpt(){safeEditorCode(window.Sk.importMainWithBody,{errorType:"skulpt",toTryArgs:arguments})}function safeCallback(t,e){return function(){var o={};return o.fnOnError=e,o.toTryArgs=arguments,safeEditorCode(t,o)}}function safeSetInterval(t,e,o){var n=function(){clearInterval(s)},r=safeCallback(t,n),s=setInterval(r,o,e);return s}module.exports={linesWithoutSemicolons:linesWithoutSemicolons,removeComments:removeComments,lineNumberFromError:lineNumberFromError,generateCodeArray:generateCodeArray,safeSkulpt:safeSkulpt,safeEval:safeEval,safeCallback:safeCallback,safeSetInterval:safeSetInterval,testInfiniteLoops:testInfiniteLoops}},{}],24:[function(t,e,o){"use strict";var n={};n={LEFT:37,UP:38,RIGHT:39,DOWN:40,ENTER:13,SHIFT:16,SPACE:32,BACKSPACE:8,TAB:9,CTRL:17,ALT:18,CAPS_LOCK:20,LEFT_COMMAND:91,LEFT_WINDOW:91,RIGHT_WINDOW:92,RIGHT_COMMAND:93,SELECT:93},n.digit=function(t){return t%=10,t+48},n.letter=function(t){return 0===t.length?null:t.toUpperCase().charCodeAt(0)},n.nonEditingKeys=[n.LEFT,n.RIGHT,n.UP,n.DOWN,n.CTRL,n.SHIFT,n.ALT,n.CAPS_LOCK,n.LEFT_COMMAND,n.RIGHT_COMMAND,n.SELECT,n.LEFT_WINDOW,n.RIGHT_WINDOW],n.isEditingKey=function(t){return-1===n.nonEditingKeys.indexOf(t)},e.exports=n},{}],25:[function(t,e,o){!function(t,o){"undefined"!=typeof e?e.exports=o():"function"==typeof define&&"object"==typeof define.amd?define(o):this[t]=o()}("domready",function(){var t,e=[],o=document,n=o.documentElement.doScroll,r="DOMContentLoaded",s=(n?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);return s||o.addEventListener(r,t=function(){for(o.removeEventListener(r,t),s=1;t=e.shift();)t()}),function(t){s?setTimeout(t,0):e.push(t)}})},{}]},{},[1])(1)});