[JavaScript] javascript绘制心型线 →→→→→进入此内容的聊天室

来自 , 2019-09-16, 写在 JavaScript, 查看 158 次.
URL http://www.code666.cn/view/98311ab4
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JS心型线</title>
  6. <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Tangerine">
  7. <style>
  8. div{
  9.         position:absolute;
  10. }
  11. .xx-box{
  12.         left:50%;
  13.         top:50%;
  14.         margin-left:-250px;
  15.         margin-top:-250px;
  16.         width:500px;
  17.         height:500px;
  18.         background-color:#000;
  19. }
  20. .xx-box .text{
  21.         top:30%;
  22.         height:48px;
  23.         line-height:48px;
  24.         color:#f00;
  25.         text-shadow: 3px 3px 4px #f00;
  26.         font-size:36px;
  27.         font-weight:bold;
  28.         width:100%;
  29.         text-align:center;
  30.         font-family:Tangerine,Tahoma,Arial,"\65f6\5c1a\4e2d\9ed1\7b80\4f53","\5b8b\4f53";
  31. }
  32. .xx-box .item{
  33.         width:2px;
  34.         height:20px;
  35.         overflow:hidden;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class="xx-box" id="xx-box">
  41.         <div class="text">I Love You</div>
  42. </div>
  43. <script>
  44. function createPoint(x,y,c){
  45.         var div = document.createElement("div");
  46.         div.className = "item";
  47.         div.style.left = x + "px";
  48.         div.style.top = y + "px";
  49.         div.style.backgroundColor = c;
  50.         document.getElementById("xx-box").appendChild(div);
  51. }
  52. function heartShape(r,dx,dy,c){//r:大小;dx:水平偏移;dy:垂直偏移;c:颜色
  53.         var m,n,x,y,i;
  54.         for(i = 0; i <= 200; i += 0.04){
  55.                 m = i;
  56.                 n = -r * (((Math.sin(i) * Math.sqrt(Math.abs(Math.cos(i)))) / (Math.sin(i) + 1.4)) - 2 * Math.sin(i) + 2);
  57.                 x = n * Math.cos(m) + dx;
  58.                 y = n * Math.sin(m) + dy;
  59.                 createPoint(x,y,c);
  60.         }
  61. }
  62. heartShape(80,250,100,"#f00");
  63. </script>
  64. </body>
  65. </html>
  66. //javascript/243

回复 "javascript绘制心型线"

这儿你可以回复上面这条便签

captcha