I am making a programming language involving Javascript. However, it doesn't seem to work. My language is a js file called 'antimin'. The script looks like a one line code version of this:
function (){
var ctx;
function setupCanvas(setupVariable){
ctx=setupVariable;
};
function circ(x,y,lps,wps,fill,outline){
if(outline===true){
ctx.beginPath();ctx.arc(x,y,lps, wps,6.28);ctx.stroke();
};
if (fill===true){
ctx.beginPath();ctx.arc(x,y,lps,wps,6.28);
ctx.stroke();
};
}
}
However, when I pass it through the following HTML file, it doesn't work (note I deleted all </>):
<!doctype html>
<canvas length="100" width="100" id="minoun">
</canvas>
<script src="antimin.js">
</script>
<script>
setupCanvas(minoun.getContext("2d"))
circ(50,50,50,50,true,true)
</script>
function (){, function name is ?setupCanvasin your script tag because the function is inside another function which means it's local to that scope. You will either have to get rid of the outside function or call thesetupCanvasfunction inside that outer function. If you choose to keep the outer function, you will have to invoke it immediately. I would look up how to use an IIFE.