zoukankan      html  css  js  c++  java
  • html5 canvas路径绘制2

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>基本文件配置</title>
    <script src="js/modernizr.js"></script>
    </head>
    
    <body>
    <p>lineCap定义上下文中线的端点:</p>
    
    <p>butt端点是垂直于线段边缘的平直边缘</p>
    
    <p>round端点是在线段边缘处以线宽为直径的半圆</p>
    
    <p>square:端点是在选段边缘处以线宽为长,以一般线宽为宽的矩形</p>
    
    <p>lineJoin定义了两条线相交产生的拐角</p>
    
    <p>miter 在连接外边缘盐城详解</p>
    
    <p>bevel。连接处是一个对角线斜角</p>
    
    <p>round。连接处是一个圆</p>
    
    <script type="text/javascript">
    window.addEventListener('load',eventWindowLoaded,false);
    function eventWindowLoaded(){
    	canvasApp();
    }
    function canvasSupport(){
    	return Modernizr.canvas;
    }
    function canvasApp(){
    	if(!canvasSupport()){
    		return;
    	}else{
    		var theCanvas = document.getElementById('canvas')
    		var context = theCanvas.getContext("2d")
    
    	}
    	drawScreen();
        function drawScreen(){
    		
    		//圆形端点,斜角连接
    		 context.strokeStyle="pink";
    		 context.lineWidth=10;
    		 context.lineJoin='bevel';
    		 context.lineCap='round';
    		 context.beginPath();
    		 context.moveTo(0,0);
    		 context.lineTo(25,0);
    		 context.lineTo(25,25);
    		 context.stroke();
    		 context.closePath();
    		 
    		 
    		 //round圆形端点,斜角链接
    		 context.beginPath();
    		 context.moveTo(10,50);
    		 context.lineTo(35,50);
    		 context.lineTo(35,75);
    		 context.stroke();
    		 context.closePath();
    		 
    		 
    		 //butt平直的端点,round圆形的链接
    		 context.lineJoin='round';
    		 context.lineCap='butt';
    		 context.beginPath();
    		 context.beginPath();
    		 context.moveTo(10,100);
    		 context.lineTo(35,100);
    		 context.lineTo(35,125);
    		 context.stroke();
    		 context.closePath();
       }
    }
    
    
    </script>
    <canvas id="canvas" width="500" height="500">
    你的浏览器无法使用canvas
    如有疑问加QQ:1035417613;小白童鞋;你的支持是我最大的快乐!!
    </canvas>
    </body>
    </html>
    

     效果如下

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>基本文件配置</title>
    <script src="js/modernizr.js"></script>
    </head>
    
    <body>
    
    
    <script type="text/javascript">
    window.addEventListener('load',eventWindowLoaded,false);
    function eventWindowLoaded(){
    	canvasApp();
    }
    function canvasSupport(){
    	return Modernizr.canvas;
    }
    function canvasApp(){
    	if(!canvasSupport()){
    		return;
    	}else{
    		var theCanvas = document.getElementById('canvas')
    		var context = theCanvas.getContext("2d")
    
    	}
    	drawScreen();
        function drawScreen(){
    		
    		//圆形端点,斜角连接
    		 context.strokeStyle="pink";
    		 context.lineWidth=10;
    		 context.lineJoin='bevel';
    		 context.lineCap='round';
    		 context.beginPath();
    		 context.moveTo(50,20);
    		 context.lineTo(35,100);
    		 context.lineTo(55,150);
    		 context.stroke();
    		 context.closePath();
    		 
    		 
    	     context.beginPath();
    		 context.moveTo(25,65);
    		 context.lineTo(80,65);
    		 context.stroke();
    		 context.closePath();
    		
    		
    		 context.beginPath();
    		 context.moveTo(75,40);
    		 context.lineTo(60,100);
    		 context.lineTo(30,150);
    		 context.stroke();
    		 context.closePath();
    		 
    		 context.beginPath();
    		 context.moveTo(120,20);
    		 context.lineTo(120,150);
    		 context.stroke();
    		 context.closePath();
    		 
    		 
    		 
    		 context.beginPath();
    		 context.moveTo(100,55);
    		 context.lineTo(120,70);
    		 context.stroke();
    		 context.closePath();
    		 
    		 context.beginPath();
    		 context.moveTo(100,105);
    		 context.lineTo(120,80);
    		 context.stroke();
    		 context.closePath();
    		 
    		 
    		 context.beginPath();
    		 context.moveTo(140,20);
    		 context.lineTo(140,150);
    		 context.lineTo(180,150);
    		 context.lineTo(180,120);
    		 context.stroke();
    		 context.closePath();
    		 
    		 context.beginPath();
    		 context.moveTo(140,70);
    		 context.lineTo(160,55);
    		 context.stroke();
    		 context.closePath();
    		 
    		 context.beginPath();
    		 context.moveTo(140,85);
    		 context.lineTo(160,105);
    		 context.stroke();
    		 context.closePath();
       }
    }
    
    
    </script>
    <canvas id="canvas" width="500" height="500">
    你的浏览器无法使用canvas
    如有疑问加QQ:1035417613;小白童鞋;你的支持是我最大的快乐!!
    </canvas>
    </body>
    </html>
    

     效果吐槽一下这字画的竟然和我写的一样丑T_T无语了

  • 相关阅读:
    浏览器兼容
    jquery 判断网络资源,网络文件是否存在
    [Maven] 变态问题收集
    maven project中,在main方法上右键Run as Java Application时,提示错误:找不到或无法加载主类XXX.XXXX.XXX
    maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang
    java 获取文件列表,并按照文件名称排序
    maven install时报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
    tar 命令基本使用(加密)
    八卦某 G 的前端开发方式及流程
    use mkisofs 重新打包beini,tinycore linux
  • 原文地址:https://www.cnblogs.com/LoveOrHate/p/4389260.html
Copyright © 2011-2022 走看看