• Canvas之太极图


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8">
    		<title></title>
    		<style type="text/css">
    			canvas{
    				border: 1px solid red;
    			}
    		</style>
    	</head>
    	<body style="background-color: blanchedalmond;">
    		<canvas id="canvas" width="500px" height="500px"></canvas>
    	</body>
    	<script type="text/javascript">
    		var canvas=document.getElementById("canvas");
    		var context=canvas.getContext('2d');		 
    		var x=canvas.width/2;
    		var y=canvas.height/2;
    		var r=200;
    		//右边的黑圆
    		context.beginPath();
    		context.arc(x,y,r,-0.5*Math.PI,0.5*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="black";
    		context.fill();	
    		context.closePath();
    		//左边的白圆
    		context.beginPath();
    		context.arc(x,y,r,0.5*Math.PI,1.5*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="white";
    		context.fill();	
    		context.closePath();
    		//上方的白球 
    		context.beginPath();
    		context.arc(x,y-(r/2),r/2,0,2*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="white";
    		context.fill();	
    		context.closePath();
    		//下方的黑球
    		context.beginPath();
    		context.arc(x,y+(r/2),r/2,0,2*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="black";
    		context.fill();	
    		context.closePath();
    		//上方的黑球
    		context.beginPath();
    		context.arc(x,y-(r/2),r/6,0,2*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="black";
    		context.fill();	
    		context.closePath();
    		//下方白球
    		context.beginPath();
    		context.arc(x,y+(r/2),r/6,0,2*Math.PI,false)
    		context.lineTo(x,y)
    		context.fillStyle="white";
    		context.fill();	
    		context.closePath();
    	</script>
    </html>
    

    每个人都是在努力的路上,别因为别人的误解而放弃,,术业有专攻,如是而已。
  • 相关阅读:
    jdk silent install test
    jdk silent install
    PS_note_01
    string.split('',-1)的作用
    dos下静默安装
    dos命令中rem 与::的区别
    barcode4j用法
    查看tomcat的版本
    eclipse里启动rabbitmq报错 java.net.SocketException: Connection reset
    Mysql性能调优
  • 原文地址:https://www.cnblogs.com/16699qq/p/13159921.html
Copyright © 2020-2023  润新知