情人节程序员用HTML网页表白【彩色酷炫的空间背景动画特效】 HTML5七夕情人节表白网页源码 HTML+CSS+JavaScript

这是程序员表白系列中的100款网站表白之一,旨在让任何人都能使用并创建自己的表白网站给心爱的人看。 此波共有100个表白网站,可以任意修改和使用,很多人会希望向心爱的男孩女孩告白,生性腼腆的人即使那个TA站在眼前都不敢向前表白。说不出口的话就用短视频告诉TA吧~制作一个表白网页告诉TA你的心意,演示如下。

一、网页介绍

1 网页简介:基于 HTML+CSS+JavaScript 制作七夕情人节表白网页、生日祝福、七夕告白、 求婚、浪漫爱情3D相册、炫酷代码 ,快来制作一款高端的表白网页送(他/她)浪漫的告白,制作修改简单,可自行更换背景音乐,文字和图片即可使用

2.网页编辑:任意HTML编辑软件(如:Dreamweaver、HBuilder、Vscode 、Sublime 、Webstorm、Text 、Notepad++ 等任意html编辑软件进行运行及修改编辑等操作)。


一、网页效果

在这里插入图片描述

二、代码展示

1.HTML代码

代码如下(示例):以下仅展示部分代码供参考~

<!--
 * @Author: your name
 * @Date: 2021-05-24 14:22:07
 * @LastEditTime: 2021-05-24 14:22:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \canvas彩色酷炫的空间背景动画特效\index.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Space scroller - No WebGL</title>
  </head>

  <body>
    <!-- html5基于canvas绘制彩色酷炫的空间粒子移动背景动画特效。 -->

    <script src="js/gameCanvas-3.0.js"></script>
    <script src="js/index.js"></script>
  </body>
</html>




2.js代码

var gc = new GameCanvas();

var stars = [];
var circles = [];
var lineStars = [];

for (var i = 0; i < 1000; i++) {
  stars.push({x: Math.random() * width, y: Math.random() * height, radius: Math.random() * 2});
}

for (var i = 0; i < 100; i++) {
  lineStars.push({x: Math.random() * width, y: Math.random() * height, lx: 0, ly: 0});
}

for (var i = 0; i < 250; i++) {
  circles.push({x: Math.random() * width, y: Math.random() * height, radius: 300, color: "rgba(255, 0, 0, 0.01)"});
  circles.push({x: Math.random() * width, y: Math.random() * height, radius: 300, color: "rgba(0, 0, 255, 0.01)"});
  if (!(i % 3))
    circles.push({x: Math.random() * width, y: Math.random() * height, radius: 300, color: "rgba(200, 255, 0, 0.01)"});
}

for (var i = 0; i < 100; i++) {
  circles.push({x: random_normal() / 6 * width + width / 2, y: random_normal() / 6 * height + height / 2, radius: 200, color: "rgba(255, 255, 255, 0.01)"});
}

var canvas2 = document.createElement("canvas");
canvas2.width = width;
canvas2.height = height;
var ctx2 = canvas2.getContext("2d");
ctx2.fillStyle = "rgb(20, 20, 20)";
ctx2.fillRect(0, 0, canvas2.width, canvas2.height);
ctx2.globalCompositeOperation = "lighter";
for (var i = 0; i < circles.length; i++) {
  var c = circles[i];
  ctx2.beginPath();
  ctx2.arc(c.x, c.y, c.radius, 0, Math.PI * 2);
  ctx2.fillStyle = c.color;
  ctx2.fill();
}

var img = new Image();
img.src = canvas2.toDataURL();

function loop() {
  background("rgb(20, 20, 20)");
  
  gc.ctx.drawImage(img, 0, 0);
  
  for (var i = 0; i < stars.length; i++) {
    var s = stars[i];
    rect(s.x, s.y, s.radius * 1.5, s.radius * 1.5, "white");
    
    s.x += s.radius / 2;
    
    if (s.x > width) s.x = 0;
    if (s.x < 0) s.x = width;
    if (s.y > height) s.y = 0;
    if (s.y < 0) s.y = height;
  }
  
  for (var i = 0; i < lineStars.length; i++) {
    var s = lineStars[i];
    s.x += 25;
    
    line(s.x, s.y, s.lx, s.ly, "white", "white");
    
    if (s.x > width) s.x = 0;
    if (s.x < 0) s.x = width;
    if (s.y > height) s.y = 0;
    if (s.y < 0) s.y = height;
    
    s.lx = s.x;
    s.ly = s.y;
    
  }
  
  /*var x = width / 2;
  var y = height / 2;
  var radius = 200;
  var grd = gc.ctx.createRadialGradient(x, y, radius, x, y, radius + 20);
  grd.addColorStop(0, "white");
  grd.addColorStop(1, "rgba(255, 255, 255, 0)");
  circle(x, y, radius + 20, grd);
  circle(x, y, radius, "black");*/
}

function random_normal() {
    var u = 0, v = 0;
    while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
    while(v === 0) v = Math.random();
    return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
}



三、精彩专栏

看到这里了就 【点赞,关注,收藏】 三连 支持下吧,你的支持是我创作的动力。

  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值