欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript繪制漂亮的心型線效果完整實(shí)例

 更新時(shí)間:2016年02月02日 11:50:16   作者:皮蛋  
這篇文章主要介紹了javascript繪制漂亮的心型線效果實(shí)現(xiàn)方法,結(jié)合完整實(shí)例形式分析了JavaScript圖形繪制的具體步驟與相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了javascript繪制漂亮的心型線效果實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:

運(yùn)行效果截圖如下:

具體代碼如下:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>JS心型線</title>
<style>
div{
  position:absolute;
}
.xx-box{
  left:50%;
  top:50%;
  margin-left:-250px;
  margin-top:-250px;
  width:500px;
  height:500px;
  background-color:#000;
}
.xx-box .text{
  top:30%;
  height:48px;
  line-height:48px;
  color:#f00;
  text-shadow: 3px 3px 4px #f00;
  font-size:36px;
  font-weight:bold;
  width:100%;
  text-align:center;
  font-family:Tangerine,Tahoma,Arial,"\65f6\5c1a\4e2d\9ed1\7b80\4f53","\5b8b\4f53";
}
.xx-box .item{
  width:2px;
  height:20px;
  overflow:hidden;
}
</style>
</head>
<body>
<div class="xx-box" id="xx-box">
  <div class="text">I Love You</div>
</div>
<script>
function createPoint(x,y,c){
  var div = document.createElement("div");
  div.className = "item";
  div.style.left = x + "px";
  div.style.top = y + "px";
  div.style.backgroundColor = c;
  document.getElementById("xx-box").appendChild(div);
}
function heartShape(r,dx,dy,c){//r:大小;dx:水平偏移;dy:垂直偏移;c:顏色
  var m,n,x,y,i;
  for(i = 0; i <= 200; i += 0.04){
    m = i;
    n = -r * (((Math.sin(i) * Math.sqrt(Math.abs(Math.cos(i)))) / (Math.sin(i) + 1.4)) - 2 * Math.sin(i) + 2);
    x = n * Math.cos(m) + dx;
    y = n * Math.sin(m) + dy;
    createPoint(x,y,c);
  }
}
heartShape(80,250,100,"#f00");
</script>
</body>
</html>

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《JavaScript動(dòng)畫(huà)特效與技巧匯總》、《javascript面向?qū)ο笕腴T(mén)教程》及《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論