Canvas - GoldemMIL/Golden-Codes GitHub Wiki

<title>Normal astroid</title> <script>

var x,y,X,Y,R=300, i=0;

function main() { var d=document.getElementById("canvas"); H=d.height; W=d.width; window.c=d.getContext("2d"); //Можно начинать Канвасить------------------------------

c.fillStyle='rgba(0,0,0, 1)';
c.fillRect(0,0,W,H);
c.strokeStyle="#FFFF00";

setInterval("drawLine();",20);

// for (var i=0;i<2Math.PI;i=i+4Math.PI/180){}//End for------------------------------------------

}//End main------------------------------------------------------------------

function drawLine(){

//console.log("Работает drawLine");
console.log("i=="+i+", а i%(2*Math.PI)=="+i%(2*Math.PI));
if (i%(2*Math.PI)==0)
{
	changeColor(); 
	//c.clearRect(0,0,W,H);	/*c.strokeStyle="#FF0D00";*/
	console.log("Сработал иф");
}

x=W/2-R*Math.cos(i+Math.PI);
//alert(i*180/Math.PI);
y=H/2;//const

X=W/2;//const
Y=H/2+R*Math.sin(i);
c.beginPath();
c.moveTo(x,y);	
c.lineTo(X,Y);
//c.lineWidth=2;

c.stroke();

if(i/(2*Math.PI)>1)
{
	i=0;
}
else i+=4*Math.PI/180;

}

function changeColor() { var rc= Math.floor(Math.random() * (255 - 0 + 1)) + 0; var gc= Math.floor(Math.random() * (255 - 0 + 1)) + 0; var bc= Math.floor(Math.random() * (255 - 0 + 1)) + 0; console.log(" выбран цвет ("+rc+","+gc+","+bc+")"); c.strokeStyle="rgb("+rc+","+gc+","+bc+")";

} </script>

asfjs
Ваш браузер не поддерживает canvas
⚠️ **GitHub.com Fallback** ⚠️