이 글의 예시에서는 JS 드로잉을 통해 꽃잎 효과를 생성하는 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 세부 내용은 다음과 같습니다.
여기에서는 JS 드로잉을 사용하여 꽃잎 효과를 생성합니다. 그래픽 드로잉 효과는 순수 JS에서 생성됩니다. JavaScript 그래픽 드로잉에 대한 지식을 공부하고 싶다면 이 작은 프로그램을 참고하면 좋을 것 같습니다. 꽤 좋아.
작동 효과는 아래와 같습니다.

구체적인 코드는 다음과 같습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <html >
<head>
<meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" />
<title>Js绘制生成花瓣效果</title>
</head>
<body>
<script Language= "javascript" >
function a(x,y,color)
{document.write( "<img border='0' style='position: absolute; left: " +(x+300)+ "; top: " +(y+200)+ ";background-color: " +color+ "' src='px.gif' width=1 height=1>" )}
</script>
<script>
for (t=1;t<=360;t++){
lo=200 * Math.sin(2 * (Math.PI / 180) * t);
x = lo * Math. cos ((Math.PI / 180) * t);
y = lo * Math.sin((Math.PI / 180) * t);
a(x,y, "#000000" );
lo=200 * Math. cos (2 * (Math.PI / 180) * t);
x = lo * Math. cos ((Math.PI / 180) * t);
y = lo * Math.sin((Math.PI / 180) * t);
a(x,y, "#ff0000" );
}
</script>
</body>
</html>
|
로그인 후 복사
이 기사가 모든 사람의 JavaScript 프로그래밍 설계에 도움이 되기를 바랍니다.