Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creat张临军的第七周作业 #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 1510300144/C88_)ZSII[~ELJCVS1}$M3Y.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1510300144/V7@QRHJ9NDE6EYUE6RQN~]V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1510300144/V]VG28FG(IMW_F31)3MHU%L.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions 1510300144/六芒星.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>绘制六芒星</title>
</head>
7 <body>
8 <div id="canvas-warp">
<canvas id="canvas" style="border: 1px solid #aaaaaa; display: block; margin: 50px auto;">
你的浏览器竟然不支持Canvas?!赶快换一个吧!!
</canvas>
</div>

<script>
window.onload=function() {
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
canvas.width =200;
canvas.height =250;
drawstar(context,0,200,173,56);
}
function drawstar(cxt,x1,x2,y1,z) {
cxt.beginPath();
cxt.moveTo((x1 + x2) / 2, y1 - (Math.sqrt(3) * (x2 - x1) / 2));
cxt.lineTo(x1, y1);
cxt.lineTo(x2, y1);
cxt.closePath();
cxt.fill();
cxt.stroke();

cxt.beginPath();
cxt.moveTo((x1 + x2) / 2, (y1 - (Math.sqrt(3) * (x2 - x1) / 2)) + y1 * 4 / 3);
cxt.lineTo(x1, y1 / 3);
cxt.lineTo(x2, y1 / 3);
cxt.closePath();
cxt.fill();
cxt.stroke();
cxt.fillStyle = "black";
cxt.lineWidth = 5;
cxt.strokeStyle = "black";



}

</script>

</body>
</html>
40 changes: 40 additions & 0 deletions 1510300144/六边形.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>绘制正六边形</title>
</head>
<body>
<canvas id = "myCanvas" width = '500' height = '500'></canvas>
<script>

var myCanvas = document.getElementById("myCanvas");
var context = myCanvas.getContext("2d");

function drawPath(x, y, n, r)
{
var i,ang;
ang = Math.PI*2/n

context.fillStyle ="black";
context.strokeStyle ="black";
context.lineWidth = 2;
context.translate(x, y);
context.moveTo(0, -r);
context.beginPath();
for(i = 0;i < n; i ++)
{
context.rotate(ang)
context.lineTo(0, -r);
}
context.closePath();
context.stroke();
context.fill();

}
drawPath(400,200,6,100)


</script>
</body>
</html>
56 changes: 56 additions & 0 deletions 1510300144/魔性图像.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head lang="zh">
<meta charset="UTF-8">
<title>绘制魔性图形</title>
</head>
<body>
<div id="canvas-warp">
<canvas id="canvas" style="border:1px solid #aaaaaa;display:block;margin:50px auto;">
你的浏览器居然不支持Canvas?!赶快换一个吧!!
</canvas>
<script>
window.onload=function(){
var canvas=document.getElementById("canvas");
canvas.width=800;
canvas.height=600;
var context=canvas.getContext("2d");

context.beginPath();
context.rect(0,0,800,600);
context.fillstyle="#AA9033"
context.fill();
context.beginPath();
for(var i=0;i<=20;i++){
drawWhiteRect(context,200+10*i,100+10*i,400-20*i,400-20*i);
drawBlackRect(context,205+10*i,105+10*i,390-20*i,390-20*i);
}
context.beginPath();
context.rect(395,295,5,5);
context.fillStyle="black";
context.lineWidth=5;
context.fill();
context.stroke();
}
function drawBlackRect(cxt,x,y,width,height){
cxt.beginPath();
cxt.rect(x,y,width,height);
cxt.lineWidth=5;
cxt.strokeStyle="black";
cxt.stroke();
}
function drawWhiteRect(cxt,x,y,width,height){
cxt.beginPath();
cxt.rect(x,y,width,height);
cxt.lineWidth=5;
cxt.strokeStyle="white";
cxt.stroke();
}
</script>



</body>
</html>
</body>
</html>