定制开发Python or html爱心代码(听说最近很火)

定制开发下面第四个

 定制开发最近抖音莫名很火的一个爱心❤️

定制开发实现的方法不尽相同,定制开发重要的是心意而不是代码本身

前三种用Python来实现,最后一种较为复杂,是用HTML来实现,是笔者搜集而来

 1.

  1. from turtle import *
  2. from time import sleep
  3. def go_to(x, y):
  4. up()
  5. goto(x, y)
  6. down()
  7. def big_Circle(size): #函数用于绘制心的大圆
  8. speed(9)
  9. for i in range(150):
  10. forward(size)
  11. right(0.3)
  12. def small_Circle(size): #函数用于绘制心的小圆
  13. speed(1)
  14. for i in range(210):
  15. forward(size)
  16. right(0.786)
  17. def line(size):
  18. speed(1)
  19. forward(51*size)
  20. def heart( x, y, size):
  21. go_to(x, y)
  22. left(150)
  23. begin_fill()
  24. line(size)
  25. big_Circle(size)
  26. small_Circle(size)
  27. left(120)
  28. small_Circle(size)
  29. big_Circle(size)
  30. line(size)
  31. end_fill()
  32. def arrow():
  33. pensize(10)
  34. setheading(0)
  35. go_to(-400, 0)
  36. left(15)
  37. forward(150)
  38. go_to(339, 178)
  39. forward(150)
  40. def arrowHead():
  41. pensize(1)
  42. speed(1)
  43. color('red', 'red')
  44. begin_fill()
  45. left(120)
  46. forward(20)
  47. right(150)
  48. forward(35)
  49. right(120)
  50. forward(35)
  51. right(150)
  52. forward(20)
  53. end_fill()
  54. def main():
  55. pensize(2)
  56. color('red', 'pink')
  57. #getscreen().tracer(30, 0) #取消注释后,快速显示图案
  58. heart(200, 0, 1) #画出第一颗心,前面两个参数控制心的位置,函数最后一个参数可控制心的大小
  59. setheading(0) #使画笔的方向朝向x轴正方向
  60. heart(-80, -100, 1.5) #画出第二颗心
  61. arrow() #画出穿过两颗心的直线
  62. arrowHead() #画出箭的箭头
  63. go_to(400, -300)
  64. write("author:py.cn", move=True, align="left", font=("宋体", 30, "normal"))
  65. done()
  66. main()

2. 

  1. import turtle as t
  2. def init():
  3. t.speed(2)
  4. t.pensize(2)
  5. t.screensize(480, 360)
  6. t.color('red', 'red')
  7. def draw_heart_right():
  8. t.up()
  9. t.goto(50, 50)
  10. t.pendown()
  11. t.right(45)
  12. t.goto(100, 0)
  13. t.seth(45)
  14. t.fd(120)
  15. t.circle(50, 225)
  16. def draw_heart_left():
  17. t.up()
  18. t.goto(0, 0)
  19. t.down()
  20. t.seth(45)
  21. t.fd(120)
  22. t.circle(50, 225)
  23. t.seth(90)
  24. t.circle(50, 225)
  25. t.fd(120)
  26. def draw_arrow():
  27. t.up()
  28. t.seth(0)
  29. # 羽毛
  30. t.goto(-210, 40)
  31. t.pendown()
  32. t.goto(-215, 44)
  33. t.goto(-190, 49)
  34. t.goto(-175, 46)
  35. t.up()
  36. t.goto(-210, 40)
  37. t.pendown()
  38. t.goto(-213, 34)
  39. t.goto(-185, 39)
  40. t.goto(-175, 46)
  41. t.up()
  42. # 箭杆
  43. t.pendown()
  44. t.goto(0, 80)
  45. t.penup()
  46. t.goto(160, 110)
  47. t.pendown()
  48. t.goto(320, 140)
  49. # 箭羽
  50. t.left(160)
  51. t.begin_fill()
  52. t.fd(10)
  53. t.left(120)
  54. t.fd(10)
  55. t.left(120)
  56. t.fd(10)
  57. t.end_fill()
  58. if __name__ == '__main__':
  59. init()
  60. draw_heart_right()
  61. draw_heart_left()
  62. draw_arrow()
  63. t.hideturtle()
  64. t.done()

3. 

  1. import turtle
  2. import math
  3. turtle.pen()
  4. t=turtle
  5. t.up()
  6. t.goto(0,150)
  7. t.down()
  8. t.color('red')
  9. t.begin_fill()
  10. t.fillcolor('red')
  11. t.speed(1)
  12. t.left(45)
  13. t.forward(150)
  14. t.right(45)
  15. t.forward(100)
  16. t.right(45)
  17. t.forward(100)
  18. t.right(45)
  19. t.forward(100)
  20. t.right(45)
  21. t.forward(250+math.sqrt(2)*100)
  22. t.right (90)
  23. t.speed(2)
  24. t.forward(250+100*math.sqrt(2))
  25. t.right(45)
  26. t.forward(100)
  27. t.right(45)
  28. t.forward(100)
  29. t.right(45)
  30. t.forward(100)
  31. t.right(45)
  32. t.forward(150)
  33. t.end_fill()
  34. t.goto(-10,0)
  35. t.pencolor('white')
  36. #L
  37. t.pensize(10)
  38. t.goto(-50,0)
  39. t.goto(-50,80)
  40. t.up ()
  41. #I
  42. t.goto(-100,0)
  43. t.down()
  44. t.goto(-160,0)
  45. t.goto(-130,0)
  46. t.goto(-130,80)
  47. t.goto(-160,80)
  48. t.goto(-100,80)
  49. t.up()
  50. #O
  51. t.goto(10,25)
  52. t.down()
  53. t.right(45)
  54. t.circle(25,extent=180)
  55. t.goto(60,55)
  56. t.circle(25,extent=180)
  57. t.goto(10,25)
  58. t.up()
  59. t.goto(75,80)
  60. t.down()
  61. t.goto(100,0)
  62. t.goto(125,80)
  63. t.up()
  64. t.goto(180,80)
  65. t.down()
  66. t.goto(140,80)
  67. t.goto(140,0)
  68. t.goto(180,0)
  69. t.up()
  70. t.goto(180,40)
  71. t.down()
  72. t.goto(140,40)
  73. #U
  74. t.up()
  75. t.goto(-40,-30)
  76. t.down()
  77. t.goto(-40,-80)
  78. t.circle(40,extent=180)
  79. t.goto(40,-30)
  80. t.hideturtle()

4. 

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>HTML5 Canvas爱心表白动画特效DEMO演示</title>
  6. <style>
  7. html, body {
  8. height: 100%;
  9. padding: 0;
  10. margin: 0;
  11. background: #000;
  12. }
  13. canvas {
  14. width: 100%;
  15. height: 100%;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div style="text-align:center;clear:both;">
  21. <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
  22. <script src="/follow.js" type="text/javascript"></script>
  23. </div>
  24. <canvas id="pinkboard"></canvas>
  25. <script>
  26. var settings = {
  27. particles: {
  28. length: 500,
  29. duration: 2,
  30. velocity: 100,
  31. effect: -0.75,
  32. size: 30,
  33. },
  34. };
  35. (function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());
  36. var Point = (function() {
  37. function Point(x, y) {
  38. this.x = (typeof x !== 'undefined') ? x : 0;
  39. this.y = (typeof y !== 'undefined') ? y : 0;
  40. }
  41. Point.prototype.clone = function() {
  42. return new Point(this.x, this.y);
  43. };
  44. Point.prototype.length = function(length) {
  45. if (typeof length == 'undefined')
  46. return Math.sqrt(this.x * this.x + this.y * this.y);
  47. this.normalize();
  48. this.x *= length;
  49. this.y *= length;
  50. return this;
  51. };
  52. Point.prototype.normalize = function() {
  53. var length = this.length();
  54. this.x /= length;
  55. this.y /= length;
  56. return this;
  57. };
  58. return Point;
  59. })();
  60. var Particle = (function() {
  61. function Particle() {
  62. this.position = new Point();
  63. this.velocity = new Point();
  64. this.acceleration = new Point();
  65. this.age = 0;
  66. }
  67. Particle.prototype.initialize = function(x, y, dx, dy) {
  68. this.position.x = x;
  69. this.position.y = y;
  70. this.velocity.x = dx;
  71. this.velocity.y = dy;
  72. this.acceleration.x = dx * settings.particles.effect;
  73. this.acceleration.y = dy * settings.particles.effect;
  74. this.age = 0;
  75. };
  76. Particle.prototype.update = function(deltaTime) {
  77. this.position.x += this.velocity.x * deltaTime;
  78. this.position.y += this.velocity.y * deltaTime;
  79. this.velocity.x += this.acceleration.x * deltaTime;
  80. this.velocity.y += this.acceleration.y * deltaTime;
  81. this.age += deltaTime;
  82. };
  83. Particle.prototype.draw = function(context, image) {
  84. function ease(t) {
  85. return (--t) * t * t + 1;
  86. }
  87. var size = image.width * ease(this.age / settings.particles.duration);
  88. context.globalAlpha = 1 - this.age / settings.particles.duration;
  89. context.drawImage(image, this.position.x - size / 2, this.position.y - size / 2, size, size);
  90. };
  91. return Particle;
  92. })();
  93. var ParticlePool = (function() {
  94. var particles,
  95. firstActive = 0,
  96. firstFree = 0,
  97. duration = settings.particles.duration;
  98. function ParticlePool(length) {
  99. particles = new Array(length);
  100. for (var i = 0; i < particles.length; i++)
  101. particles[i] = new Particle();
  102. }
  103. ParticlePool.prototype.add = function(x, y, dx, dy) {
  104. particles[firstFree].initialize(x, y, dx, dy);
  105. firstFree++;
  106. if (firstFree == particles.length) firstFree = 0;
  107. if (firstActive == firstFree ) firstActive++;
  108. if (firstActive == particles.length) firstActive = 0;
  109. };
  110. ParticlePool.prototype.update = function(deltaTime) {
  111. var i;
  112. if (firstActive < firstFree) {
  113. for (i = firstActive; i < firstFree; i++)
  114. particles[i].update(deltaTime);
  115. }
  116. if (firstFree < firstActive) {
  117. for (i = firstActive; i < particles.length; i++)
  118. particles[i].update(deltaTime);
  119. for (i = 0; i < firstFree; i++)
  120. particles[i].update(deltaTime);
  121. }
  122. while (particles[firstActive].age >= duration && firstActive != firstFree) {
  123. firstActive++;
  124. if (firstActive == particles.length) firstActive = 0;
  125. }
  126. };
  127. ParticlePool.prototype.draw = function(context, image) {
  128. if (firstActive < firstFree) {
  129. for (i = firstActive; i < firstFree; i++)
  130. particles[i].draw(context, image);
  131. }
  132. if (firstFree < firstActive) {
  133. for (i = firstActive; i < particles.length; i++)
  134. particles[i].draw(context, image);
  135. for (i = 0; i < firstFree; i++)
  136. particles[i].draw(context, image);
  137. }
  138. };
  139. return ParticlePool;
  140. })();
  141. (function(canvas) {
  142. var context = canvas.getContext('2d'),
  143. particles = new ParticlePool(settings.particles.length),
  144. particleRate = settings.particles.length / settings.particles.duration, // particles/sec
  145. time;
  146. function pointOnHeart(t) {
  147. return new Point(
  148. 160 * Math.pow(Math.sin(t), 3),
  149. 130 * Math.cos(t) - 50 * Math.cos(2 * t) - 20 * Math.cos(3 * t) - 10 * Math.cos(4 * t) + 25
  150. );
  151. }
  152. var image = (function() {
  153. var canvas = document.createElement('canvas'),
  154. context = canvas.getContext('2d');
  155. canvas.width = settings.particles.size;
  156. canvas.height = settings.particles.size;
  157. function to(t) {
  158. var point = pointOnHeart(t);
  159. point.x = settings.particles.size / 2 + point.x * settings.particles.size / 350;
  160. point.y = settings.particles.size / 2 - point.y * settings.particles.size / 350;
  161. return point;
  162. }
  163. context.beginPath();
  164. var t = -Math.PI;
  165. var point = to(t);
  166. context.moveTo(point.x, point.y);
  167. while (t < Math.PI) {
  168. t += 0.01;
  169. point = to(t);
  170. context.lineTo(point.x, point.y);
  171. }
  172. context.closePath();
  173. context.fillStyle = '#ea80b0';
  174. context.fill();
  175. var image = new Image();
  176. image.src = canvas.toDataURL();
  177. return image;
  178. })();
  179. function render() {
  180. requestAnimationFrame(render);
  181. var newTime = new Date().getTime() / 1000,
  182. deltaTime = newTime - (time || newTime);
  183. time = newTime;
  184. context.clearRect(0, 0, canvas.width, canvas.height);
  185. var amount = particleRate * deltaTime;
  186. for (var i = 0; i < amount; i++) {
  187. var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());
  188. var dir = pos.clone().length(settings.particles.velocity);
  189. particles.add(canvas.width / 2 + pos.x, canvas.height / 2 - pos.y, dir.x, -dir.y);
  190. }
  191. particles.update(deltaTime);
  192. particles.draw(context, image);
  193. }
  194. function onResize() {
  195. canvas.width = canvas.clientWidth;
  196. canvas.height = canvas.clientHeight;
  197. }
  198. window.onresize = onResize;
  199. setTimeout(function() {
  200. onResize();
  201. render();
  202. }, 10);
  203. })(document.getElementById('pinkboard'));
  204. </script>
  205. </body>
  206. </html>
  207. <!doctype html>
  208. <html>
  209. <head>
  210. <meta charset="utf-8">
  211. <title>HTML5 Canvas爱心表白动画特效DEMO演示</title>
  212. <style>
  213. html, body {
  214. height: 100%;
  215. padding: 0;
  216. margin: 0;
  217. background: #000;
  218. }
  219. canvas {
  220. width: 100%;
  221. height: 100%;
  222. }
  223. </style>
  224. </head>
  225. <body>
  226. <div style="text-align:center;clear:both;">
  227. <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
  228. <script src="/follow.js" type="text/javascript"></script>
  229. </div>
  230. <canvas id="pinkboard"></canvas>
  231. <script>
  232. var settings = {
  233. particles: {
  234. length: 500,
  235. duration: 2,
  236. velocity: 100,
  237. effect: -0.75,
  238. size: 30,
  239. },
  240. };
  241. (function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());
  242. var Point = (function() {
  243. function Point(x, y) {
  244. this.x = (typeof x !== 'undefined') ? x : 0;
  245. this.y = (typeof y !== 'undefined') ? y : 0;
  246. }
  247. Point.prototype.clone = function() {
  248. return new Point(this.x, this.y);
  249. };
  250. Point.prototype.length = function(length) {
  251. if (typeof length == 'undefined')
  252. return Math.sqrt(this.x * this.x + this.y * this.y);
  253. this.normalize();
  254. this.x *= length;
  255. this.y *= length;
  256. return this;
  257. };
  258. Point.prototype.normalize = function() {
  259. var length = this.length();
  260. this.x /= length;
  261. this.y /= length;
  262. return this;
  263. };
  264. return Point;
  265. })();
  266. var Particle = (function() {
  267. function Particle() {
  268. this.position = new Point();
  269. this.velocity = new Point();
  270. this.acceleration = new Point();
  271. this.age = 0;
  272. }
  273. Particle.prototype.initialize = function(x, y, dx, dy) {
  274. this.position.x = x;
  275. this.position.y = y;
  276. this.velocity.x = dx;
  277. this.velocity.y = dy;
  278. this.acceleration.x = dx * settings.particles.effect;
  279. this.acceleration.y = dy * settings.particles.effect;
  280. this.age = 0;
  281. };
  282. Particle.prototype.update = function(deltaTime) {
  283. this.position.x += this.velocity.x * deltaTime;
  284. this.position.y += this.velocity.y * deltaTime;
  285. this.velocity.x += this.acceleration.x * deltaTime;
  286. this.velocity.y += this.acceleration.y * deltaTime;
  287. this.age += deltaTime;
  288. };
  289. Particle.prototype.draw = function(context, image) {
  290. function ease(t) {
  291. return (--t) * t * t + 1;
  292. }
  293. var size = image.width * ease(this.age / settings.particles.duration);
  294. context.globalAlpha = 1 - this.age / settings.particles.duration;
  295. context.drawImage(image, this.position.x - size / 2, this.position.y - size / 2, size, size);
  296. };
  297. return Particle;
  298. })();
  299. var ParticlePool = (function() {
  300. var particles,
  301. firstActive = 0,
  302. firstFree = 0,
  303. duration = settings.particles.duration;
  304. function ParticlePool(length) {
  305. particles = new Array(length);
  306. for (var i = 0; i < particles.length; i++)
  307. particles[i] = new Particle();
  308. }
  309. ParticlePool.prototype.add = function(x, y, dx, dy) {
  310. particles[firstFree].initialize(x, y, dx, dy);
  311. firstFree++;
  312. if (firstFree == particles.length) firstFree = 0;
  313. if (firstActive == firstFree ) firstActive++;
  314. if (firstActive == particles.length) firstActive = 0;
  315. };
  316. ParticlePool.prototype.update = function(deltaTime) {
  317. var i;
  318. if (firstActive < firstFree) {
  319. for (i = firstActive; i < firstFree; i++)
  320. particles[i].update(deltaTime);
  321. }
  322. if (firstFree < firstActive) {
  323. for (i = firstActive; i < particles.length; i++)
  324. particles[i].update(deltaTime);
  325. for (i = 0; i < firstFree; i++)
  326. particles[i].update(deltaTime);
  327. }
  328. while (particles[firstActive].age >= duration && firstActive != firstFree) {
  329. firstActive++;
  330. if (firstActive == particles.length) firstActive = 0;
  331. }
  332. };
  333. ParticlePool.prototype.draw = function(context, image) {
  334. if (firstActive < firstFree) {
  335. for (i = firstActive; i < firstFree; i++)
  336. particles[i].draw(context, image);
  337. }
  338. if (firstFree < firstActive) {
  339. for (i = firstActive; i < particles.length; i++)
  340. particles[i].draw(context, image);
  341. for (i = 0; i < firstFree; i++)
  342. particles[i].draw(context, image);
  343. }
  344. };
  345. return ParticlePool;
  346. })();
  347. (function(canvas) {
  348. var context = canvas.getContext('2d'),
  349. particles = new ParticlePool(settings.particles.length),
  350. particleRate = settings.particles.length / settings.particles.duration, // particles/sec
  351. time;
  352. function pointOnHeart(t) {
  353. return new Point(
  354. 160 * Math.pow(Math.sin(t), 3),
  355. 130 * Math.cos(t) - 50 * Math.cos(2 * t) - 20 * Math.cos(3 * t) - 10 * Math.cos(4 * t) + 25
  356. );
  357. }
  358. var image = (function() {
  359. var canvas = document.createElement('canvas'),
  360. context = canvas.getContext('2d');
  361. canvas.width = settings.particles.size;
  362. canvas.height = settings.particles.size;
  363. function to(t) {
  364. var point = pointOnHeart(t);
  365. point.x = settings.particles.size / 2 + point.x * settings.particles.size / 350;
  366. point.y = settings.particles.size / 2 - point.y * settings.particles.size / 350;
  367. return point;
  368. }
  369. context.beginPath();
  370. var t = -Math.PI;
  371. var point = to(t);
  372. context.moveTo(point.x, point.y);
  373. while (t < Math.PI) {
  374. t += 0.01;
  375. point = to(t);
  376. context.lineTo(point.x, point.y);
  377. }
  378. context.closePath();
  379. context.fillStyle = '#ea80b0';
  380. context.fill();
  381. var image = new Image();
  382. image.src = canvas.toDataURL();
  383. return image;
  384. })();
  385. function render() {
  386. requestAnimationFrame(render);
  387. var newTime = new Date().getTime() / 1000,
  388. deltaTime = newTime - (time || newTime);
  389. time = newTime;
  390. context.clearRect(0, 0, canvas.width, canvas.height);
  391. var amount = particleRate * deltaTime;
  392. for (var i = 0; i < amount; i++) {
  393. var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());
  394. var dir = pos.clone().length(settings.particles.velocity);
  395. particles.add(canvas.width / 2 + pos.x, canvas.height / 2 - pos.y, dir.x, -dir.y);
  396. }
  397. particles.update(deltaTime);
  398. particles.draw(context, image);
  399. }
  400. function onResize() {
  401. canvas.width = canvas.clientWidth;
  402. canvas.height = canvas.clientHeight;
  403. }
  404. window.onresize = onResize;
  405. setTimeout(function() {
  406. onResize();
  407. render();
  408. }, 10);
  409. })(document.getElementById('pinkboard'));
  410. </script>
  411. </body>
  412. </html>

 最后一种文件要以文件名.html的形式命名

 点击即可跳转至默认浏览器

祝有缘人终成眷属~

笔者能力有限,文章不免疏漏,还请博友们及时指正



哎非说我文章质量不行没法发出来,我下面复制点东西(大家直接忽略)

下面也是Mkdocs的Blog相关的问题,感兴趣可以去看我主页关于Mkdocs的介绍

Hey there! You're looking at our new blog, built with the brand new . With this plugin, you can easily build a blog alongside your documentation or standalone.

Proper support for blogging, as requested by many users over the past few years, was something that was desperately missing from Material for MkDocs' feature set. While everybody agreed that blogging support was a blind spot, it was not obvious whether MkDocs could be extended in a way to allow for blogging as we know it from  and friends. The  proves that it is, after all, possible to build a blogging engine on top of MkDocs, in order to create a technical blog alongside your documentation, or as the main thing.

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发