If you need to introduce external Js, you need to refresh to execute <script>
function a(x,y,color)
{document.write("<img border='0' style="max-width:90%"+x+"; top: "+y+";background-color: "+color+"' src='px.gif' style="max-width:90%"js determines whether a point is within a triangle_javascript skills" >")}
</script>]<script>
function line(x1,y1,x2,y2,color)
{
var tmp;
if(x1>=x2)
{
tmp=x1;
x1=x2;
x2=tmp;
tmp=y1;
y1=y2;
y2=tmp;
}
for(var i=x1;i<=x2;i++)
{
x = i;
y = (y2 - y1) / (x2 - x1) * (x - x1) + y1;
a(x,y,color);
}
}
function rule(x,y)
{
x = x;
y = y;
r1 = y - 100 - (300-100)/(500-400)*(x-400);
r2 = y - 300;
r3 = y - 300 - (100-300)/(400-300)*(x-300);
if (r1>0&&r2<0&&r3>0)
{
return "在三角形内!";
}
else
{return "不在三角形内!";}
}
line(400,100,500,300,"ff0000");
line(500,300,300,300,"ff0000");
line(300,300,400,100,"ff0000");
</script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn