remove submoduel
This commit is contained in:
38
jsam.codersquack.nl/compiler/css/style.css
Normal file
38
jsam.codersquack.nl/compiler/css/style.css
Normal file
@@ -0,0 +1,38 @@
|
||||
html, body {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex !important;
|
||||
margin: 0 !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
#editor {
|
||||
flex: 1 !important;
|
||||
padding: 8px !important;
|
||||
background-color: #d8d8d8;
|
||||
}
|
||||
|
||||
#preview {
|
||||
padding: 8px !important;
|
||||
}
|
||||
|
||||
#input {
|
||||
width: 100% !important;
|
||||
height: 300px !important;
|
||||
margin-bottom: 8px !important;
|
||||
}
|
||||
|
||||
#output {
|
||||
height: 100px !important;
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
margin-bottom: 8px !important;
|
||||
resize: none !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
canvas {
|
||||
image-rendering: pixelated !important;
|
||||
}
|
||||
31
jsam.codersquack.nl/compiler/index.html
Normal file
31
jsam.codersquack.nl/compiler/index.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html><html><head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSArt Compiler</title>
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<link href="/css/style.css" rel="stylesheet">
|
||||
<script src="js/ace.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
<script src="/js/theme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor">
|
||||
<div id="input">var xor = `(x^y)`;
|
||||
|
||||
var xpos = `(x-128)`;
|
||||
var ypos = `(y-128)`;
|
||||
|
||||
var circleCheck = `((${xpos}*${xpos} + ${ypos}*${ypos}) > 10000)`;
|
||||
|
||||
var spinX = `((Math.cos(t/1000)*${xpos})+(Math.sin(t/1000)*${ypos}))`;
|
||||
var spinY = `((Math.cos(t/1000)*${ypos})+(-Math.sin(t/1000)*${xpos}))`;
|
||||
|
||||
var spinningXor = `(${spinX} ^ ${spinY})`;
|
||||
|
||||
return `${circleCheck} ? ${xor} : ${spinningXor}`;</div>
|
||||
<textarea id="output" readonly></textarea>
|
||||
</div>
|
||||
<div id="preview">
|
||||
<canvas id="canvas"></canvas>
|
||||
</div>
|
||||
|
||||
</body></html>
|
||||
1
jsam.codersquack.nl/compiler/js/ace.js
Normal file
1
jsam.codersquack.nl/compiler/js/ace.js
Normal file
File diff suppressed because one or more lines are too long
1
jsam.codersquack.nl/compiler/js/main.js
Normal file
1
jsam.codersquack.nl/compiler/js/main.js
Normal file
@@ -0,0 +1 @@
|
||||
var canvas,ctx,pixels,editor,width=256,height=256,mouseX=0,mouseY=0,funct=function(){};function parse(){var t=document.getElementById("output").value;try{funct=new Function("i","t","x","y","mx","my","return "+t)}catch(t){console.log(t)}}function genImg(){try{for(var t=Date.now(),e=0;e<width*height;e++){var n=funct(e,t,e%width,Math.floor(e/width),mouseX,mouseY);Math.floor(Math.floor(n)/16777216);pixels.data[4*e+0]=n>>16&255,pixels.data[4*e+1]=n>>8&255,pixels.data[4*e+2]=255&n,pixels.data[4*e+3]=256}ctx.putImageData(pixels,0,0)}catch(t){console.log(t)}window.requestAnimationFrame(genImg)}window.addEventListener("load",(function(){(editor=ace.edit("input")).setTheme("ace/theme/xcode"),editor.session.setMode("ace/mode/javascript"),(canvas=document.getElementById("canvas")).width=width,canvas.height=height,canvas.style.zoom=2,ctx=canvas.getContext("2d"),pixels=ctx.createImageData(width,height),compile(),window.addEventListener("mousemove",(function(t){var e=canvas.getBoundingClientRect();mouseX=(t.pageX-2*e.x)/2,mouseY=(t.pageY-2*e.y)/2})),editor.session.on("change",compile),genImg()}));var lib={};function compile(){var t=editor.getValue();try{var e=new Function("i","t","x","y","mx","my",t);document.getElementById("output").value=e("i","t","x","y","mx","my"),parse()}catch(t){document.getElementById("output").value=t}}lib.mod=function(t,e){return`((((${t})%(${e}))+(${e}))%(${e}))`},lib.shortFloor=function(t){return`(${t}|0)`},lib.floor=function(t){return`(${t}-${lib.mod(t,1)})`},lib.ceil=function(t){return`((${t}+1)|0)`},lib.round=function(t){return`((${t}+0.5)|0)`},lib.negative=function(t){return`((${t})>>>31)`},lib.isZero=function(t){return`((${t})/(${t})^1)`},lib.lt=function(t,e){return lib.negative(lib.floor(`((${t})-(${e}))`))},lib.shortLt=function(t,e){return lib.negative(`(${t})-(${e})`)},lib.lte=function(t,e){return`(${lib.lt(t,e)}|${lib.eq(t,e)})`},lib.gt=function(t,e){return lib.negative(lib.floor(`((${e})-(${t}))`))},lib.shortGt=function(t,e){return lib.negative(`(${e})-(${t})`)},lib.gte=function(t,e){return`(${lib.gt(t,e)}|${lib.eq(t,e)})`},lib.eq=function(t,e){return lib.isZero(`(${t})-(${e})`)},lib.lerp=function(t,e,n){return`((1-${n})*(${t})+(${n})*(${e}))`},lib.checkerboard=function(t,e,n){return`((${lib.floor(`${t}/${n}`)}+(${lib.floor(`${e}/${n}`)}))%2)`},lib.triangle=function(t,e,n,i){var o=[`(${i[0]}-${e[0]})`,`(${i[1]}-${e[1]})`],$=[`(${n[0]}-${e[0]})`,`(${n[1]}-${e[1]})`],r=[`(${t[0]}-${e[0]})`,`(${t[1]}-${e[1]})`],l=`((${o[0]}**2)+(${o[1]}**2))`,u=`((${o[0]}*${$[0]})+(${o[1]}*${$[1]}))`,a=`((${o[0]}*${r[0]})+(${o[1]}*${r[1]}))`,c=`((${$[0]}**2)+(${$[1]}**2))`,s=`((${$[0]}*${r[0]})+(${$[1]}*${r[1]}))`,d=`(${l}*${c}-${u}**2)`,b=`((${c}*${a}-${u}*${s})/${d})`,m=`((${l}*${s}-${u}*${a})/${d})`;return`(${lib.gte(b,0)} & ${lib.gte(m,0)} & ${lib.lt(`${b}+${m}`,1)})`},lib.circle=function(t,e,n){return`(${lib.lt(`(x-${t})**2+(y-${e})**2`,`(${n})**2`)})`},lib.fromRgb=function(t,e,n){return`(((${t}<<16)+(${e}<<8))+${n})`};
|
||||
Reference in New Issue
Block a user