当前位置:   article > 正文

使用html5编辑爱心树表白呈现效果_html爱心树

html爱心树

众所周知,在生活中为心爱的女孩子使用编程语言表白是一件很浪漫的事情

那我们今天就来看一下爱心树的编程撰写与实现效果

我们先来看一下实验效果

这就是我们的实验效果,接下来代码如下:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xml:lang="en" xmlns="" target="_blank">http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>《致亲爱的牛牛》</title>
  6. <link type="text/css" rel="stylesheet" href="./static/default.css">
  7. <script type="text/javascript" src="./static/jquery.min.js"></script>
  8. <script type="text/javascript" src="./static/jscex.min.js"></script>
  9. <script type="text/javascript" src="./static/jscex-parser.js"></script>
  10. <script type="text/javascript" src="./static/jscex-jit.js"></script>
  11. <script type="text/javascript" src="./static/jscex-builderbase.min.js"></script>
  12. <script type="text/javascript" src="./static/jscex-async.min.js"></script>
  13. <script type="text/javascript" src="./static/jscex-async-powerpack.min.js"></script>
  14. <script type="text/javascript" src="./static/functions.js" charset="utf-8"></script>
  15. <script type="text/javascript" src="./static/love.js" charset="utf-8"></script>
  16. <style type="text/css">
  17. <!--
  18. .STYLE1 {
  19. color: #666666
  20. }
  21. -->
  22. </style>
  23. </head>
  24. <body>
  25. <audio autoplay="autopaly">
  26. <source src="renxi.mp3" type="audio/mp3" />
  27. </audio>
  28. <div id="main">
  29. <div id="error">本页面采用HTML5编辑,目前您的浏览器无法显示,请换成谷歌(<a
  30. href="Chrome)" target="_blank">http://www.google.cn/chrome/intl/zh-CN/landing_chrome.html?hl=zh-CN&brand=CHMI">Chrome</a>)或者火狐(<a
  31. href="Firefox)" target="_blank">http://firefox.com.cn/download/">Firefox</a>)浏览器,或者其他游览器的最新版本。</div>
  32. <div id="wrap">
  33. <div id="text">
  34. <div id="code">
  35. <font color="#FF0000">
  36. <span class="say">我的心中充满了爱,</span><br>
  37. <span class="say">对你的情感无限真诚。</span><br>
  38. <span class="say">我希望你能感受到,</span><br>
  39. <span class="say">这份深深的爱情。</span><br>
  40. <span class="say"> </span><br>
  41. <span class="say">你是阳光中的一道亮丽,</span><br>
  42. <span class="say">是我生命中不可或缺的部分。</span><br>
  43. <span class="say">我想要陪伴你,</span><br>
  44. <span class="say">在你身边永远微笑。</span><br>
  45. <span class="say"> </span><br>
  46. <span class="say">我知道,我可能不是最完美的人,</span><br>
  47. <span class="say">但我会努力去爱你,</span><br>
  48. <span class="say">用一生去宠爱你,</span><br>
  49. <span class="say">用最真诚的心爱你。</span><br>
  50. <span class="say"> </span><br>
  51. <span class="say">亲爱的牛牛,我爱你,永远爱你,</span><br>
  52. <span class="say">愿你能接受我的爱,</span><br>
  53. <span class="say">和我一起走进幸福的未来。</span><br>
  54. <span class="say"> </span><br>
  55. <span class="say"><span class="space"></span> -- 爱你的展展--</span>
  56. </font>
  57. </div>
  58. </div>
  59. <div id="clock-box">
  60. <span class="STYLE1"></span>
  61. <font color="#33CC00">亲爱的牛牛,我喜欢你</font>
  62. <span class="STYLE1">已经是……</span>
  63. <div id="clock"></div>
  64. </div>
  65. <canvas id="canvas" width="1100" height="680"></canvas>
  66. </div>
  67. </div>
  68. <script>
  69. </script>
  70. <script>
  71. (function () {
  72. var canvas = $('#canvas');
  73. if (!canvas[0].getContext) {
  74. $("#error").show();
  75. return false;
  76. }
  77. var width = canvas.width();
  78. var height = canvas.height();
  79. canvas.attr("width", width);
  80. canvas.attr("height", height);
  81. var opts = {
  82. seed: {
  83. x: width / 2 - 20,
  84. color: "rgb(190, 26, 37)",
  85. scale: 2
  86. },
  87. branch: [
  88. [535, 680, 570, 250, 500, 200, 30, 100, [
  89. [540, 500, 455, 417, 340, 400, 13, 100, [
  90. [450, 435, 434, 430, 394, 395, 2, 40]
  91. ]],
  92. [550, 445, 600, 356, 680, 345, 12, 100, [
  93. [578, 400, 648, 409, 661, 426, 3, 80]
  94. ]],
  95. [539, 281, 537, 248, 534, 217, 3, 40],
  96. [546, 397, 413, 247, 328, 244, 9, 80, [
  97. [427, 286, 383, 253, 371, 205, 2, 40],
  98. [498, 345, 435, 315, 395, 330, 4, 60]
  99. ]],
  100. [546, 357, 608, 252, 678, 221, 6, 100, [
  101. [590, 293, 646, 277, 648, 271, 2, 80]
  102. ]]
  103. ]]
  104. ],
  105. bloom: {
  106. num: 700,
  107. width: 1080,
  108. height: 650,
  109. },
  110. footer: {
  111. width: 1200,
  112. height: 5,
  113. speed: 10,
  114. }
  115. }
  116. var tree = new Tree(canvas[0], width, height, opts);
  117. var seed = tree.seed;
  118. var foot = tree.footer;
  119. var hold = 1;
  120. canvas.click(function (e) {
  121. var offset = canvas.offset(),
  122. x, y;
  123. x = e.pageX - offset.left;
  124. y = e.pageY - offset.top;
  125. if (seed.hover(x, y)) {
  126. hold = 0;
  127. canvas.unbind("click");
  128. canvas.unbind("mousemove");
  129. canvas.removeClass('hand');
  130. }
  131. }).mousemove(function (e) {
  132. var offset = canvas.offset(),
  133. x, y;
  134. x = e.pageX - offset.left;
  135. y = e.pageY - offset.top;
  136. canvas.toggleClass('hand', seed.hover(x, y));
  137. });
  138. var seedAnimate = eval(Jscex.compile("async", function () {
  139. seed.draw();
  140. while (hold) {
  141. $await(Jscex.Async.sleep(10));
  142. }
  143. while (seed.canScale()) {
  144. seed.scale(0.95);
  145. $await(Jscex.Async.sleep(10));
  146. }
  147. while (seed.canMove()) {
  148. seed.move(0, 2);
  149. foot.draw();
  150. $await(Jscex.Async.sleep(10));
  151. }
  152. }));
  153. var growAnimate = eval(Jscex.compile("async", function () {
  154. do {
  155. tree.grow();
  156. $await(Jscex.Async.sleep(10));
  157. } while (tree.canGrow());
  158. }));
  159. var flowAnimate = eval(Jscex.compile("async", function () {
  160. do {
  161. tree.flower(2);
  162. $await(Jscex.Async.sleep(10));
  163. } while (tree.canFlower());
  164. }));
  165. var moveAnimate = eval(Jscex.compile("async", function () {
  166. tree.snapshot("p1", 240, 0, 610, 680);
  167. while (tree.move("p1", 500, 0)) {
  168. foot.draw();
  169. $await(Jscex.Async.sleep(10));
  170. }
  171. foot.draw();
  172. tree.snapshot("p2", 500, 0, 610, 680);
  173. // 会有闪烁不得意这样做, (>﹏<)
  174. canvas.parent().css("background", "url(" + tree.toDataURL('image/png') + ")");
  175. canvas.css("background", "#ffe");
  176. $await(Jscex.Async.sleep(300));
  177. canvas.css("background", "none");
  178. }));
  179. var jumpAnimate = eval(Jscex.compile("async", function () {
  180. var ctx = tree.ctx;
  181. while (true) {
  182. tree.ctx.clearRect(0, 0, width, height);
  183. tree.jump();
  184. foot.draw();
  185. $await(Jscex.Async.sleep(25));
  186. }
  187. }));
  188. var textAnimate = eval(Jscex.compile("async", function () {
  189. var together = new Date();
  190. together.setFullYear(2020, 1, 15); //时间年月日
  191. together.setHours(17); //小时
  192. together.setMinutes(53); //分钟
  193. together.setSeconds(30); //秒前一位
  194. together.setMilliseconds(0); //秒第二位
  195. $("#code").show().typewriter();
  196. $("#clock-box").fadeIn(500);
  197. while (true) {
  198. timeElapse(together);
  199. $await(Jscex.Async.sleep(1000));
  200. }
  201. }));
  202. var runAsync = eval(Jscex.compile("async", function () {
  203. $await(seedAnimate());
  204. $await(growAnimate());
  205. $await(flowAnimate());
  206. $await(moveAnimate());
  207. textAnimate().start();
  208. $await(jumpAnimate());
  209. }));
  210. runAsync().start();
  211. })();
  212. </script>
  213. </body>
  214. </html>
  215. 时间改写在最后一段中的
  216. var textAnimate = eval(Jscex.compile("async", function () {
  217. var together = new Date();
  218. together.setFullYear(2020, 1, 15); //时间年月日
  219. together.setHours(17); //小时
  220. together.setMinutes(53); //分钟
  221. together.setSeconds(30); //秒前一位
  222. together.setMilliseconds(0); //秒第二位
  223. 修改时间。

注:名字自己看着修改就好,另外,

时间可能有所差异,自己看着改写一下就好

看都看完了,留下个点赞关注呗

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/120653
推荐阅读
相关标签