function t(AXA){document.write(AXA)}
function canv(ee,an,al){t('<canvas id="'+ee+'" width="'+an+'" height="'+al+'"></canvas>')}
function can(p,XBX){
ah=eval(p)*200+2
t('<canvas id="'+XBX+'" width="'+ah+'" height="'+ah+'"><!--[if lt IE 9]><p><b><i>Internet Explorer 8 does not support <code>canvas</code> graphics.</i></b></p><![endif]-->') 
t('</canvas>')
}


function initi(an,colo,XBX){
var canvas = document.getElementById(XBX);  
var ctx = canvas.getContext("2d");  
ctx.strokeStyle = colo;
ctx.lineWidth = an;}

function initi2(colo,XBX){
var canvas = document.getElementById(XBX);  
var ctx = canvas.getContext("2d");  
ctx.fillStyle= colo;
}

function arco(XX,YY,rr,a1,a2,XBX) {
var canvas = document.getElementById(XBX);  
var ctx = canvas.getContext("2d");  
; 
ctx.beginPath();
ctx.moveTo(XX,YY);

    ctx.arc(XX,YY,rr,-a1,-a2,true);

ctx.fill();
}

function wri(XX,YY,textoo,XBX) {
var canvas = document.getElementById(XBX);  
var ctx = canvas.getContext("2d");  
ctx.font = '11pt Calibri';
ctx.fillStyle = '#000000';
ctx.fillText(textoo, XX, YY);
      }

function wri_2(teet,coolo,tama,xx,yy,ex){
var canvas = document.getElementById(ex);
		if (canvas && canvas.getContext) {
		var ctx = canvas.getContext("2d");
			if (ctx) {
						var centerX = canvas.width/2;
						ctx.textAlign="left";
						
						ctx.font=tama+"pt Verdana";
						ctx.fillStyle = coolo;
						ctx.fillText(teet,xx,yy);
      
					}
		}
}

function ine(A,B,C,XBX) {  
A=-A;B=-B
var canvas = document.getElementById(XBX);  
var ctx = canvas.getContext("2d");  
ctx.fillStyle = "rgba(60, 60, 190, 0.3)"; 
ctx.beginPath();
ctx.strokeStyle="red";
    ctx.beginPath();
    ctx.moveTo(0,0);
    ctx.moveTo(101-10*20,101+(-A*10+B)*20);
    ctx.lineTo(101+10*20,101+(A*10+B)*20);
if(C>=0){
    ctx.lineTo(101+10*20,101-10*20);
    ctx.lineTo(101-10*20,101+-10*20);
}
else{
    ctx.lineTo(101+10*20,101+10*20);
    ctx.lineTo(101-10*20,101+10*20);
}
    ctx.lineTo(101-10*20,101+(-A*10+B)*20);

    ctx.stroke();
    ctx.fill();
} 


function tri(A,AA,B,BB,C,CC,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
 ctx.fillStyle = "rgba(60, 60, 190, 0.5)";  
 ctx.lineWidth = 0.5;  

    ctx.beginPath();
 ctx.fillStyle = "rgba(0, 0, 200)";  
 ctx.lineWidth = 3;
    ctx.moveTo(1+A*20,1+AA*20);
    ctx.lineTo(1+B*20,1+BB*20);
    ctx.lineTo(1+C*20,1+CC*20);
    ctx.lineTo(1+A*20,1+AA*20);
    ctx.stroke();
} 


function seg(A,AA,B,BB,p,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  

ph=eval(p);
     ctx.beginPath();
    ctx.moveTo(ph*100+1+A*20,ph*100+1-AA*20);
    ctx.lineTo(ph*100+1+B*20,ph*100+1-BB*20);
    ctx.stroke();

}  

function seg_(A,AA,B,BB,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();
    ctx.moveTo(A,AA);
    ctx.lineTo(B,BB);
    ctx.stroke();

}  

function polig(AAA,p,XBX) {
AB=AAA.split(",")
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();ph=eval(p);
 
    ctx.moveTo(ph*100+1+AB[0]*20,ph*100+1-AB[1]*20);

for (i=0;i<AB.length;i=i+2){
    ctx.lineTo(ph*100+1+AB[i+2]*20,ph*100+1-AB[i+3]*20);
}
   ctx.stroke();ctx.fill();
} 


function poli(AAA,p,XBX) {
AB=AAA.split(",")
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();ph=eval(p);
 
    ctx.moveTo(ph*100+1+AB[0]*20,ph*100+1-AB[1]*20);

for (i=0;i<AB.length;i=i+2){
    ctx.lineTo(ph*100+1+AB[i+2]*20,ph*100+1-AB[i+3]*20);
}
 ctx.stroke();
} 


function vect(A,AA,B,BB,p,XBX) {  
pun(B,BB,3,p,XBX)
seg(A,AA,B,BB,p,XBX)
}  

function fun(Ax,Bx,EXP,p,XBX){
for(it=Ax;it<Bx;it=it+0.1){
x=it;yya=eval(EXP)
x=it+0.1;yyya=eval(EXP)
if(Math.abs(yyya-yya)<10){
seg(it,yya,it+0.1,yyya,p,XBX)
}
}}





function red(pxp,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
 ctx.strokeStyle = "#000000";    
 ctx.lineWidth = 0.5;
for (i=0;i<80;i++){
    ctx.beginPath();
    ctx.moveTo(1+20*i,0);
    ctx.lineTo(1+20*i,1200);
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(1,20*i);
    ctx.lineTo(1201,20*i);
    ctx.stroke();
}
}

function eje(p,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
 ctx.strokeStyle = "#000000";  
 ctx.lineWidth = 2;
p=eval(p)
    ctx.moveTo(p*100+1,0);
    ctx.lineTo(p*100+1,p*200+1);
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(0,p*100+1);
    ctx.lineTo(p*200+1,p*100+1);
 ctx.stroke();
  
}  


function red2(pxp,XBX) {  
ah=202;ahh=602
t('<canvas id="'+XBX+'" width="'+ahh+'" height="'+ah+'"><!--[if lt IE 9]><p><b><i>Internet Explorer 8 does not support <code>canvas</code> graphics.</i></b></p><![endif]-->') 

var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
 ctx.srokeStyle = "rgba(60, 60, 190)";  
 ctx.lineWidth = 0.5;
for (i=0;i<102;i++){
    ctx.beginPath();
    ctx.moveTo(1+20*i,0);
    ctx.lineTo(1+20*i,1200);
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(1,20*i);
    ctx.lineTo(1201,20*i);
    ctx.stroke();
}
 ctx.lineWidth = 2;

    ctx.moveTo(100+1,0);
    ctx.lineTo(100+1,200+1);
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(0,100+1);
    ctx.lineTo(1200+1,100+1);
 ctx.stroke()

t('</canvas>')
}



function poligo(AAA,XBX) {
AB=AAA.split(",")
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();
 
    ctx.moveTo(AB[0],AB[1]);

for (i=0;i<AB.length;i=i+2){
    ctx.lineTo(AB[i+2],AB[i+3]);
}
   ctx.stroke();
} 

function poligore(AAA,XBX) {
AB=AAA.split(",")
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();
 
    ctx.moveTo(AB[0],AB[1]);

for (i=0;i<AB.length;i=i+2){
    ctx.lineTo(AB[i+2],AB[i+3]);
}
   ctx.stroke();ctx.fill();
} 


function poligo2(AAA,XBX,rrx) {
AB=AAA.split(",")
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
     ctx.beginPath();
 
    ctx.moveTo(AB[0]*rrx,AB[1]*rrx);

for (i=0;i<AB.length;i=i+2){
    ctx.lineTo(AB[i+2]*rrx,AB[i+3]*rrx);
}
   ctx.stroke();
} 




function pun2(A,AA,B,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
    ctx.beginPath();
    ctx.arc(A+1,AA+1,B,0,Math.PI*2,true);
    ctx.stroke();
} 

function pun(A,AA,B,p,XBX) {  
var canvas = document.getElementById(XBX);  
  var ctx = canvas.getContext("2d");  
ph=eval(p);
    ctx.beginPath();
    ctx.arc(A*20+1+ph*100,ph*100-AA*20,B,0,Math.PI*2,true);
    ctx.stroke();
}  

