今天复习两个知识点:
<!doctype html>
<html lang="en">
<head>
<title>Just Canvas Demo</title>
<meta charset="utf-8">
<!--<style>-->
<!--canvas{-->
<!--border:1px solid orangered;-->
<!--}-->
<!--</style>-->
<script src="D:/myweb/jquery-1.9.1.js"></script>
<script>
$(document).ready(function(){
var canvas = $("#myCanvas");
var context = canvas.get(0).getContext("2d");
context.strokeStyle = "rgb(255,0,0)";
context.strokeStyle = "rgb(0,0,255)"; //(1)
context.save();
context.strokeRect(10,10,100,100);
//
context.strokeStyle = "rgb(0,255,0)";
context.beginPath();
context.arc(120,120,60,0,Math.PI,false);
context.closePath();
context.stroke();
//
context.restore(); //(2)
// 注释上面这句和不注释这一句的两种结果对比很明显
context.strokeRect(160,160,100,100);
});
</script>
</head>
<body>
<canvas id="myCanvas" width="1000px" height="500px">