Last active
March 1, 2020 05:20
-
-
Save 143mailliw/d6bd26a52a585cf3a03d18e84cb083a6 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/qubanun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <body onload="start()"> | |
| <canvas id="canvas" width="800" height="800"></canvas> | |
| <script id="jsbin-javascript"> | |
| //stupid | |
| let codeString = ` | |
| x' = (if(index == 0,-9.5,if(index == 1,-6.5,if(index == 2,-8.5,if(index == 3,-6.5,if(index == 4,-7.5,if(index == 5,-6.5,if(index == 6,-9.5,if(index == 7,-8.5,if(index == 8,-7.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,7.5,if(index == 12,8.5,if(index == 13,9.5,if(index == 14,6.5,if(index == 15,7.5,if(index == 16,6.5,if(index == 17,8.5,if(index == 18,6.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| y' = (-if(index == 0,-9.5,if(index == 1,-9.5,if(index == 2,-8.5,if(index == 3,-8.5,if(index == 4,-7.5,if(index == 5,-7.5,if(index == 6,-6.5,if(index == 7,-6.5,if(index == 8,-6.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,6.5,if(index == 12,6.5,if(index == 13,6.5,if(index == 14,7.5,if(index == 15,7.5,if(index == 16,8.5,if(index == 17,8.5,if(index == 18,9.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| h = 0; | |
| s = 1; | |
| v = if(index < 22,1,0); | |
| # Graphical Editor code will be placed before your Text Editor code upon export. | |
| y' = y' | |
| x' = x' | |
| h = h | |
| s = s | |
| v = v | |
| # Effects code will be placed after your Text Editor code upon export. | |
| xf = x' | |
| yf = y' | |
| xr = projectionTime; | |
| yr = projectionTime; | |
| zr = projectionTime; | |
| xz = xf*cos(zr)-yf*sin(zr); | |
| yz = xf*sin(zr)+yf*cos(zr); | |
| x' = xz*cos(yr)+sin(yr)*yz*sin(xr); | |
| y' = yz*cos(xr); | |
| ` | |
| let canvas = null | |
| let ctx = null | |
| function drawDot(x, y) { | |
| ctx.beginPath(); | |
| ctx.arc(x, y, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| } | |
| function min(a, b) { | |
| } | |
| function max(a, b) { | |
| } | |
| function towerIf(float, a, b) { | |
| } | |
| function lerp(frac, a, b) { | |
| //can you do this ples | |
| return (a*frac + b*(1-frac)); | |
| } | |
| function log(inText) { | |
| console.log(inText) | |
| } | |
| function drawFrame() { | |
| console.log("a") | |
| } | |
| function drawIndex(index) { | |
| let variableObject = {} | |
| let replacedCode = codeString | |
| replacedCode = replacedCode.replace(/x(?![a-zA-Z1-90_\-'])/g, "in_x") | |
| replacedCode = replacedCode.replace(/y(?![a-zA-Z1-90_\-'])/g, "in_y") | |
| replacedCode = replacedCode.replace(/index(?![a-zA-Z1-90_\-'])/g, "in_index") | |
| replacedCode = replacedCode.replace(/count(?![a-zA-Z1-90_\-'])/g, "in_count") | |
| replacedCode = replacedCode.replace(/fraction(?![a-zA-Z1-90_\-'])/g, "in_fraction") | |
| replacedCode = replacedCode.replace(/pi(?![a-zA-Z1-90_\-'])/g, "in_pi") | |
| replacedCode = replacedCode.replace(/tau(?![a-zA-Z1-90_\-'])/g, "in_tau") | |
| replacedCode = replacedCode.replace(/time(?![a-zA-Z1-90_\-'])/g, "in_time") | |
| replacedCode = replacedCode.replace(/projectionTime(?![a-zA-Z1-90_\-'])/g, "in_projectionTime") | |
| replacedCode = replacedCode.replace(/projectionStartTime(?![a-zA-Z1-90_\-'])/g, "in_projectionStartTime") | |
| replacedCode = replacedCode.replace(/x'(?![a-zA-Z1-90_\-'])/g, "out_x_prime") | |
| replacedCode = replacedCode.replace(/y'(?![a-zA-Z1-90_\-'])/g, "out_y_prime") | |
| replacedCode = replacedCode.replace(/h(?![a-zA-Z1-90_\-'])/g, "out_h") | |
| replacedCode = replacedCode.replace(/s(?![a-zA-Z1-90_\-'])/g, "out_s") | |
| replacedCode = replacedCode.replace(/v(?![a-zA-Z1-90_\-'])/g, "out_v") | |
| console.log(replacedCode) | |
| } | |
| function start() { | |
| canvas = document.getElementById("canvas"); | |
| ctx = canvas.getContext("2d"); | |
| ctx.fillStyle = "#FF0000"; | |
| ctx.strokeStyle = "#FF0000"; | |
| ctx.beginPath(); | |
| ctx.arc(10, 25, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| drawDot(50, 10) | |
| //ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| } | |
| drawIndex() | |
| </script> | |
| <script id="jsbin-source-html" type="text/html"><body onload="start()"> | |
| <canvas id="canvas" width="800" height="800"></canvas> | |
| </body> | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">//stupid | |
| let codeString = ` | |
| x' = (if(index == 0,-9.5,if(index == 1,-6.5,if(index == 2,-8.5,if(index == 3,-6.5,if(index == 4,-7.5,if(index == 5,-6.5,if(index == 6,-9.5,if(index == 7,-8.5,if(index == 8,-7.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,7.5,if(index == 12,8.5,if(index == 13,9.5,if(index == 14,6.5,if(index == 15,7.5,if(index == 16,6.5,if(index == 17,8.5,if(index == 18,6.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| y' = (-if(index == 0,-9.5,if(index == 1,-9.5,if(index == 2,-8.5,if(index == 3,-8.5,if(index == 4,-7.5,if(index == 5,-7.5,if(index == 6,-6.5,if(index == 7,-6.5,if(index == 8,-6.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,6.5,if(index == 12,6.5,if(index == 13,6.5,if(index == 14,7.5,if(index == 15,7.5,if(index == 16,8.5,if(index == 17,8.5,if(index == 18,9.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| h = 0; | |
| s = 1; | |
| v = if(index < 22,1,0); | |
| # Graphical Editor code will be placed before your Text Editor code upon export. | |
| y' = y' | |
| x' = x' | |
| h = h | |
| s = s | |
| v = v | |
| # Effects code will be placed after your Text Editor code upon export. | |
| xf = x' | |
| yf = y' | |
| xr = projectionTime; | |
| yr = projectionTime; | |
| zr = projectionTime; | |
| xz = xf*cos(zr)-yf*sin(zr); | |
| yz = xf*sin(zr)+yf*cos(zr); | |
| x' = xz*cos(yr)+sin(yr)*yz*sin(xr); | |
| y' = yz*cos(xr); | |
| ` | |
| let canvas = null | |
| let ctx = null | |
| function drawDot(x, y) { | |
| ctx.beginPath(); | |
| ctx.arc(x, y, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| } | |
| function min(a, b) { | |
| } | |
| function max(a, b) { | |
| } | |
| function towerIf(float, a, b) { | |
| } | |
| function lerp(frac, a, b) { | |
| //can you do this ples | |
| return (a*frac + b*(1-frac)); | |
| } | |
| function log(inText) { | |
| console.log(inText) | |
| } | |
| function drawFrame() { | |
| console.log("a") | |
| } | |
| function drawIndex(index) { | |
| let variableObject = {} | |
| let replacedCode = codeString | |
| replacedCode = replacedCode.replace(/(?<![^a-zA-Z_\-']|\s|^)x(?![a-zA-Z1-90_\-'])/g, "in_x") | |
| replacedCode = replacedCode.replace(/y(?![a-zA-Z1-90_\-'])/g, "in_y") | |
| replacedCode = replacedCode.replace(/index(?![a-zA-Z1-90_\-'])/g, "in_index") | |
| replacedCode = replacedCode.replace(/count(?![a-zA-Z1-90_\-'])/g, "in_count") | |
| replacedCode = replacedCode.replace(/fraction(?![a-zA-Z1-90_\-'])/g, "in_fraction") | |
| replacedCode = replacedCode.replace(/pi(?![a-zA-Z1-90_\-'])/g, "in_pi") | |
| replacedCode = replacedCode.replace(/tau(?![a-zA-Z1-90_\-'])/g, "in_tau") | |
| replacedCode = replacedCode.replace(/time(?![a-zA-Z1-90_\-'])/g, "in_time") | |
| replacedCode = replacedCode.replace(/projectionTime(?![a-zA-Z1-90_\-'])/g, "in_projectionTime") | |
| replacedCode = replacedCode.replace(/projectionStartTime(?![a-zA-Z1-90_\-'])/g, "in_projectionStartTime") | |
| replacedCode = replacedCode.replace(/x'(?![a-zA-Z1-90_\-'])/g, "out_x_prime") | |
| replacedCode = replacedCode.replace(/y'(?![a-zA-Z1-90_\-'])/g, "out_y_prime") | |
| replacedCode = replacedCode.replace(/h(?![a-zA-Z1-90_\-'])/g, "out_h") | |
| replacedCode = replacedCode.replace(/s(?![a-zA-Z1-90_\-'])/g, "out_s") | |
| replacedCode = replacedCode.replace(/v(?![a-zA-Z1-90_\-'])/g, "out_v") | |
| console.log(replacedCode) | |
| } | |
| function start() { | |
| canvas = document.getElementById("canvas"); | |
| ctx = canvas.getContext("2d"); | |
| ctx.fillStyle = "#FF0000"; | |
| ctx.strokeStyle = "#FF0000"; | |
| ctx.beginPath(); | |
| ctx.arc(10, 25, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| drawDot(50, 10) | |
| //ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| } | |
| drawIndex()</script></body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //stupid | |
| let codeString = ` | |
| x' = (if(index == 0,-9.5,if(index == 1,-6.5,if(index == 2,-8.5,if(index == 3,-6.5,if(index == 4,-7.5,if(index == 5,-6.5,if(index == 6,-9.5,if(index == 7,-8.5,if(index == 8,-7.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,7.5,if(index == 12,8.5,if(index == 13,9.5,if(index == 14,6.5,if(index == 15,7.5,if(index == 16,6.5,if(index == 17,8.5,if(index == 18,6.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| y' = (-if(index == 0,-9.5,if(index == 1,-9.5,if(index == 2,-8.5,if(index == 3,-8.5,if(index == 4,-7.5,if(index == 5,-7.5,if(index == 6,-6.5,if(index == 7,-6.5,if(index == 8,-6.5,if(index == 9,-6.5,if(index == 10,6.5,if(index == 11,6.5,if(index == 12,6.5,if(index == 13,6.5,if(index == 14,7.5,if(index == 15,7.5,if(index == 16,8.5,if(index == 17,8.5,if(index == 18,9.5,if(index == 19,9.5,0))))))))))))))))))))); | |
| h = 0; | |
| s = 1; | |
| v = if(index < 22,1,0); | |
| # Graphical Editor code will be placed before your Text Editor code upon export. | |
| y' = y' | |
| x' = x' | |
| h = h | |
| s = s | |
| v = v | |
| # Effects code will be placed after your Text Editor code upon export. | |
| xf = x' | |
| yf = y' | |
| xr = projectionTime; | |
| yr = projectionTime; | |
| zr = projectionTime; | |
| xz = xf*cos(zr)-yf*sin(zr); | |
| yz = xf*sin(zr)+yf*cos(zr); | |
| x' = xz*cos(yr)+sin(yr)*yz*sin(xr); | |
| y' = yz*cos(xr); | |
| ` | |
| let canvas = null | |
| let ctx = null | |
| function drawDot(x, y) { | |
| ctx.beginPath(); | |
| ctx.arc(x, y, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| } | |
| function min(a, b) { | |
| } | |
| function max(a, b) { | |
| } | |
| function towerIf(float, a, b) { | |
| } | |
| function lerp(frac, a, b) { | |
| //can you do this ples | |
| return (a*frac + b*(1-frac)); | |
| } | |
| function log(inText) { | |
| console.log(inText) | |
| } | |
| function drawFrame() { | |
| console.log("a") | |
| } | |
| function drawIndex(index) { | |
| let variableObject = {} | |
| let replacedCode = codeString | |
| replacedCode = replacedCode.replace(/(?<![^a-zA-Z_\-']|\s|^)x(?![a-zA-Z1-90_\-'])/g, "in_x") | |
| replacedCode = replacedCode.replace(/y(?![a-zA-Z1-90_\-'])/g, "in_y") | |
| replacedCode = replacedCode.replace(/index(?![a-zA-Z1-90_\-'])/g, "in_index") | |
| replacedCode = replacedCode.replace(/count(?![a-zA-Z1-90_\-'])/g, "in_count") | |
| replacedCode = replacedCode.replace(/fraction(?![a-zA-Z1-90_\-'])/g, "in_fraction") | |
| replacedCode = replacedCode.replace(/pi(?![a-zA-Z1-90_\-'])/g, "in_pi") | |
| replacedCode = replacedCode.replace(/tau(?![a-zA-Z1-90_\-'])/g, "in_tau") | |
| replacedCode = replacedCode.replace(/time(?![a-zA-Z1-90_\-'])/g, "in_time") | |
| replacedCode = replacedCode.replace(/projectionTime(?![a-zA-Z1-90_\-'])/g, "in_projectionTime") | |
| replacedCode = replacedCode.replace(/projectionStartTime(?![a-zA-Z1-90_\-'])/g, "in_projectionStartTime") | |
| replacedCode = replacedCode.replace(/x'(?![a-zA-Z1-90_\-'])/g, "out_x_prime") | |
| replacedCode = replacedCode.replace(/y'(?![a-zA-Z1-90_\-'])/g, "out_y_prime") | |
| replacedCode = replacedCode.replace(/h(?![a-zA-Z1-90_\-'])/g, "out_h") | |
| replacedCode = replacedCode.replace(/s(?![a-zA-Z1-90_\-'])/g, "out_s") | |
| replacedCode = replacedCode.replace(/v(?![a-zA-Z1-90_\-'])/g, "out_v") | |
| console.log(replacedCode) | |
| } | |
| function start() { | |
| canvas = document.getElementById("canvas"); | |
| ctx = canvas.getContext("2d"); | |
| ctx.fillStyle = "#FF0000"; | |
| ctx.strokeStyle = "#FF0000"; | |
| ctx.beginPath(); | |
| ctx.arc(10, 25, 2.5, 0, 2 * Math.PI); | |
| ctx.stroke(); | |
| ctx.fill(); | |
| drawDot(50, 10) | |
| //ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| } | |
| drawIndex() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment