哪位高手懂javascript编程啊,能不能帮我把空心直角三角形和等边三角形...
发布网友
发布时间:2024-10-03 14:03
我来回答
共3个回答
热心网友
时间:2024-10-12 04:11
<!-- HTML -->
<canvas id="mycanvas"></canvas>//JavaScript
(function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('mycanvas');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Filled triangle
ctx.beginPath();
ctx.moveTo(25,25);
ctx.lineTo(105,25);
ctx.lineTo(25,105);
ctx.fill();
// Stroked triangle
ctx.beginPath();
ctx.moveTo(125,125);
ctx.lineTo(125,45);
ctx.lineTo(45,125);
ctx.closePath();
ctx.stroke();
} else {
alert('You need Safari or Firefox 1.5+ to see this demo.');
}
})()// 给你一个演示网址: http://jsfiddle.net/vaenow/Y9rpr/1/
热心网友
时间:2024-10-12 04:12
div旋转 可构建三角形
热心网友
时间:2024-10-12 04:06
没明白什么意思
你是要画图还是要计算?
热心网友
时间:2024-10-12 04:05
<!-- HTML -->
<canvas id="mycanvas"></canvas>//JavaScript
(function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('mycanvas');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Filled triangle
ctx.beginPath();
ctx.moveTo(25,25);
ctx.lineTo(105,25);
ctx.lineTo(25,105);
ctx.fill();
// Stroked triangle
ctx.beginPath();
ctx.moveTo(125,125);
ctx.lineTo(125,45);
ctx.lineTo(45,125);
ctx.closePath();
ctx.stroke();
} else {
alert('You need Safari or Firefox 1.5+ to see this demo.');
}
})()// 给你一个演示网址: http://jsfiddle.net/vaenow/Y9rpr/1/
热心网友
时间:2024-10-12 04:11
div旋转 可构建三角形
热心网友
时间:2024-10-12 04:08
没明白什么意思
你是要画图还是要计算?