Advertisement
Creepinson

CODENATURALLY CODER SCRIPT

Aug 3rd, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var btn = document.createElement("button");
  2. btn.setAttribute("id", "coolrandombtn");
  3. var t = document.createTextNode("CLICK ME IF YOU WANT TO GET A LOT OF 'CODE'. (WARNING: DO NOT TRY THIS ON ONE OF YOUR IMPORTANT SKETCHES!!");
  4. btn.appendChild(t);
  5. document.body.appendChild(btn);
  6. var finished = document.createElement("button");
  7. finished.setAttribute("id", "coolrandombtn-finished");
  8. var t2 = document.createTextNode("Click me to finish writing random code.");
  9. finished.appendChild(t2);
  10. document.body.appendChild(finished);   
  11. var editorelement = document.getElementsByClassName("code-input ace_editor ace-chrome")[0];
  12. var editor = ace.edit(editorelement);
  13. var text = "function draw() { \n";
  14.  
  15.  
  16. var codepossible = {};
  17. codepossible.shapes = [
  18.   "ellipse","rect"
  19. ]; 
  20. var myInterval;
  21. var stopped = true;
  22.  
  23. finished.addEventListener("click", function(){
  24.   text += "}\n";
  25.   editor.setValue(text);
  26. });
  27. btn.addEventListener("click", function(){
  28.   if(stopped){
  29.   myInterval = setInterval(function(){
  30.      var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  31.      for(var d = 0; d < 1; d++){
  32.        for (var i = 0; i < Math.floor(1); i++)
  33.              text += "fill(" + Math.floor(Math.random()*255) + ", " + Math.floor(Math.random()*255) + ", " + Math.floor(Math.random()*255) + ", " + Math.floor(Math.random()*255) + ");\n";
  34.          text += codepossible.shapes[Math.floor(Math.random()*codepossible.shapes.length)] + "(" + Math.floor(Math.random()*900) + ", " + Math.floor(Math.random()*950) + ", " + Math.floor(Math.random()*950) + ", " + Math.floor(Math.random()*900) + ");\n";
  35.        editor.setValue(text);
  36.      }
  37.   }, 1500);
  38.   stopped = false;
  39.   } else {
  40.     stopped = true;
  41.     clearInterval(myInterval);
  42.   }
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement