【表白】html表白代码

news2025/7/19 11:12:41

目录

  • 一.引言
  • 二.表白效果展示
    • 1.惊喜表白
    • 2.烟花表白
    • 3.玫瑰花表白
    • 4.心形表白
    • 5.心加文字
    • 6.炫酷的特效

一.引言

我们可以用一下好看的网页来表白,下面就有我觉得很有趣的表白代码

下载整套表白文件

二.表白效果展示

1.惊喜表白

在这里插入图片描述

在这里插入图片描述

2.烟花表白

在这里插入图片描述

源码:新建一个文本文档,改后缀名为html,直接双击就行了。(修改中间的字,在代码里有注释,是汉字注释),如果你的有问题,那就直接下载我的源码文件就行。

<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>surprised</title>
<link rel="stylesheet" href="css/style.css">
<style>
body {
  margin: 0;
  background: black;
}
canvas {
  position: absolute;
}
</style>
</head>
<body>
<canvas></canvas>
<canvas></canvas>
<canvas></canvas>
<script type="text/javascript">

// CLASSES
class Shard {
  constructor(x, y, hue) {
    this.x = x;
    this.y = y;
    this.hue = hue;
    this.lightness = 50;
    this.size = 15 + Math.random() * 10;
    const angle = Math.random() * 2 * Math.PI;
    const blastSpeed = 1 + Math.random() * 6;
    this.xSpeed = Math.cos(angle) * blastSpeed;
    this.ySpeed = Math.sin(angle) * blastSpeed;
    this.target = getTarget();
    this.ttl = 100;
    this.timer = 0;
  }
  draw() {
    ctx2.fillStyle = `hsl(${this.hue}, 100%, ${this.lightness}%)`;
    ctx2.beginPath();
    ctx2.arc(this.x, this.y, this.size, 0, 2 * Math.PI);
    ctx2.closePath();
    ctx2.fill();
  }
  update() {
    if (this.target) {
      const dx = this.target.x - this.x;
      const dy = this.target.y - this.y;
      const dist = Math.sqrt(dx * dx + dy * dy);
      const a = Math.atan2(dy, dx);
      const tx = Math.cos(a) * 5;
      const ty = Math.sin(a) * 5;
      this.size = lerp(this.size, 1.5, 0.05);

      if (dist < 5) {
        this.lightness = lerp(this.lightness, 100, 0.01);
        this.xSpeed = this.ySpeed = 0;
        this.x = lerp(this.x, this.target.x + fidelity / 2, 0.05);
        this.y = lerp(this.y, this.target.y + fidelity / 2, 0.05);
        this.timer += 1;
      } else
      if (dist < 10) {
        this.lightness = lerp(this.lightness, 100, 0.01);
        this.xSpeed = lerp(this.xSpeed, tx, 0.1);
        this.ySpeed = lerp(this.ySpeed, ty, 0.1);
        this.timer += 1;
      } else
      {
        this.xSpeed = lerp(this.xSpeed, tx, 0.02);
        this.ySpeed = lerp(this.ySpeed, ty, 0.02);
      }
    } else
    {
      this.ySpeed += 0.05;
      //this.xSpeed = lerp(this.xSpeed, 0, 0.1);
      this.size = lerp(this.size, 1, 0.05);

      if (this.y > c2.height) {
        shards.forEach((shard, idx) => {
          if (shard === this) {
            shards.splice(idx, 1);
          }
        });
      }
    }
    this.x = this.x + this.xSpeed;
    this.y = this.y + this.ySpeed;
  }}


class Rocket {
  constructor() {
    const quarterW = c2.width / 4;
    this.x = quarterW + Math.random() * (c2.width - quarterW);
    this.y = c2.height - 15;
    this.angle = Math.random() * Math.PI / 4 - Math.PI / 6;
    this.blastSpeed = 6 + Math.random() * 7;
    this.shardCount = 15 + Math.floor(Math.random() * 15);
    this.xSpeed = Math.sin(this.angle) * this.blastSpeed;
    this.ySpeed = -Math.cos(this.angle) * this.blastSpeed;
    this.hue = Math.floor(Math.random() * 360);
    this.trail = [];
  }
  draw() {
    ctx2.save();
    ctx2.translate(this.x, this.y);
    ctx2.rotate(Math.atan2(this.ySpeed, this.xSpeed) + Math.PI / 2);
    ctx2.fillStyle = `hsl(${this.hue}, 100%, 50%)`;
    ctx2.fillRect(0, 0, 5, 15);
    ctx2.restore();
  }
  update() {
    this.x = this.x + this.xSpeed;
    this.y = this.y + this.ySpeed;
    this.ySpeed += 0.1;
  }

  explode() {
    for (let i = 0; i < 70; i++) {
      shards.push(new Shard(this.x, this.y, this.hue));
    }
  }}


// INITIALIZATION
const [c1, c2, c3] = document.querySelectorAll('canvas');
const [ctx1, ctx2, ctx3] = [c1, c2, c3].map(c => c.getContext('2d'));
let fontSize = 200;
const rockets = [];
const shards = [];
const targets = [];
const fidelity = 3;
let counter = 0;
c2.width = c3.width = window.innerWidth;
c2.height = c3.height = window.innerHeight;
ctx1.fillStyle = '#000';


//中间的字改这里
const text = '鸡你太美';   
     
let textWidth = 99999999;

while (textWidth > window.innerWidth) {
  ctx1.font = `900 ${fontSize--}px Arial`;
  textWidth = ctx1.measureText(text).width;
}

c1.width = textWidth;
c1.height = fontSize * 1.5;
ctx1.font = `900 ${fontSize}px Arial`;
ctx1.fillText(text, 0, fontSize);
const imgData = ctx1.getImageData(0, 0, c1.width, c1.height);
for (let i = 0, max = imgData.data.length; i < max; i += 4) {
  const alpha = imgData.data[i + 3];
  const x = Math.floor(i / 4) % imgData.width;
  const y = Math.floor(i / 4 / imgData.width);

  if (alpha && x % fidelity === 0 && y % fidelity === 0) {
    targets.push({ x, y });
  }
}

//这里是修改字的颜色
ctx3.fillStyle = '#FFF';

ctx3.shadowColor = '#FFF';
ctx3.shadowBlur = 25;

// ANIMATION LOOP
(function loop() {
  ctx2.fillStyle = "rgba(0, 0, 0, .1)";
  ctx2.fillRect(0, 0, c2.width, c2.height);
  //ctx2.clearRect(0, 0, c2.width, c2.height);
  counter += 1;

  if (counter % 15 === 0) {
    rockets.push(new Rocket());
  }
  rockets.forEach((r, i) => {
    r.draw();
    r.update();
    if (r.ySpeed > 0) {
      r.explode();
      rockets.splice(i, 1);
    }
  });

  shards.forEach((s, i) => {
    s.draw();
    s.update();

    if (s.timer >= s.ttl || s.lightness >= 99) {
      ctx3.fillRect(s.target.x, s.target.y, fidelity + 1, fidelity + 1);
      shards.splice(i, 1);
    }
  });

  requestAnimationFrame(loop);
})();

// HELPER FUNCTIONS
const lerp = (a, b, t) => Math.abs(b - a) > 0.1 ? a + t * (b - a) : b;

function getTarget() {
  if (targets.length > 0) {
    const idx = Math.floor(Math.random() * targets.length);
    let { x, y } = targets[idx];
    targets.splice(idx, 1);

    x += c2.width / 2 - textWidth / 2;
    y += c2.height / 2 - fontSize / 2;

    return { x, y };
  }
}
</script>
</body>
</html>

3.玫瑰花表白

右侧的空地,点击鼠标就会放烟花,下面的都不放源码了,都在在我的 。下载整套表白文件

在这里插入图片描述

4.心形表白

每一次刷新颜色都会不一样,包括中间的字在这里插入图片描述

在这里插入图片描述

5.心加文字

在这里插入图片描述

在这里插入图片描述

6.炫酷的特效

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/37849.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于51单片机的温度控制系统数码管显示蜂鸣器报警proteus仿真原理图PCB

功能&#xff1a; 0.本系统采用STC89C52作为单片机 1.系统实时监测并显示当前温度&#xff0c;并通过四位数码管显示 2.超过设定阈值&#xff0c;蜂鸣器将报警&#xff0c;同时控制相应继电器实现降温或者加热 3.系统具备三个功能按键&#xff0c;可更改温度上限和下限 4.采用D…

SpringBoot+Mybatis-Plus+Thymeleaf 实现增删改查+登录/注册

SQL -- student_info create table if not exists student_info ( sid int not null auto_increment comment 学生表主键 primary key, sname varchar(20) not null comment 学生账号登录名、姓名, pwd varchar(32) not null comment 密码, sex varchar(20) not null comment …

AQS源码解析 7.共享模式_CyclicBarrier重复屏障

AQS源码解析 —共享模式_CyclicBarrier重复屏障 简介 CyclicBarrier&#xff1a;循环屏障、循环栅栏&#xff0c;用来进行线程协作&#xff0c;等待线程满足某个计数。构造时设置『计数个数』&#xff0c;每个线程执行到某个需要“同步”的时刻调用 await() 方法进行等待&…

【多目标进化优化】多目标进化群体的分布性

0 前言 \quad\quad进化算法是模拟生物自然进化的人工方法&#xff0c;与大自然生态环境一样&#xff0c;进化的物种也需要平衡发展。因此&#xff0c;设计者必须制定合适的生存规则来维持种群的多样性和分布性。在多目标进化算法中&#xff0c;对于某些问题&#xff0c;Pareto最…

微机-------可编程并行接口8255A

目录 8255A的内部结构8255A控制信息和传输动作的对应关系⭐8255A的控制字一、方式选择控制字①方式0(基本输入输出工作方式)二、端口C置1/置0控制字8255A的工作方式②方式1(选通的输入输出工作方式)③方式2(双向传输方式)⭐⭐8255的编程及应用8255A的内部结构 ①数据总线…

Steam项目推进(二)—— 在项目中使用FairyGUI

一、遇到的问题 昨天把代码大致清理了一遍之后&#xff0c;发现代码中存在很大的一个问题是数据和表现耦合在一起了&#xff0c;如下&#xff1a; using UnityEngine; using UnityEngine.UI;public enum CardStateType {InDeck, InHand, InBattle, InSave, InAbandon }//卡牌…

Cisco简单配置(十八)—OSPF

开放式最短路径优先&#xff08;Open Shortest Path First&#xff0c;OSPF&#xff09;是广泛使用的一种动态路由协议&#xff0c;它属于链路状态路由协议&#xff0c;具有路由变化收敛速度快、无路由环路、支持变长子网掩码&#xff08;VLSM&#xff09;和汇总、层次区域划分…

设计模式-组合模式(决策树)

一、只如初见 组合模式也许大家第一联想到的就是把两个模块组合起来使用&#xff0c;其实好像是这样也其实不是这样&#xff0c;废话不多说&#xff0c;学习一件新的事物总要先了解一下他的概念&#xff0c;老规矩先上概念&#xff08;摘自百度百科&#xff09;&#xff1a; 组…

【活动预告】金融大数据治理实践分享(12/03)

原创 DAMA数据管理 # 本期主题 金融大数据治理实践分享 数字化时代&#xff0c;数据的价值受到越来越多的关注&#xff0c;有人将其比作黄金&#xff0c;也有人将其比作石油&#xff0c;成为组织中的最重要资产之一。针对数据这种有特殊属性的资产&#xff0c;也存在着采集…

[论文阅读] 颜色迁移-N维pdf迁移

[论文阅读] 颜色迁移-N维pdf迁移 文章: N-Dimensional Probability Density Function Transfer and its Application to Colour Transfer, [paper ][code] 1-算法原理 简单来说, 本文将图像看作是随机变量的一组样本, 图像之间的颜色迁移可以看作是样本之间分布的迁移. 因而…

G1D23-RAGA报名蓝桥Attackg安装cudatorch

昨天太摸鱼啦~不过蛮开心的哈哈 今天主要是把积累的ddl都清理一下&#xff01;&#xff01;&#xff01;第一项就是我和舍友一起读的论文嘿嘿&#xff01;&#xff01; 一、RAGA &#xff08;零&#xff09;总结&#xff08;仅模型&#xff09; 作为数据挖掘顶会2021年的论文…

【MATLAB教程案例46】三维数据的插值和滤波处理matlab仿真

欢迎订阅《FPGA学习入门100例教程》、《MATLAB学习入门100例教程》 本课程学习成果预览: 目录 1.软件版本 2.三维数据插值

openFeign夺命连环9问,这谁受得了?

1、前言 前面介绍了Spring Cloud 中的灵魂摆渡者Nacos&#xff0c;和它的前辈们相比不仅仅功能强大&#xff0c;而且部署非常简单。 今天介绍一款服务调用的组件&#xff1a;OpenFeign&#xff0c;同样是一款超越先辈&#xff08;Ribbon、Feign&#xff09;的狠角色。 文章目…

linux 安装新版傻妞+TG+青龙

一键安装命令 #国内服务器要先设置网络代理set sillyGirl download_prefix https://yanyu.ltd/#一键安装命令ssillyGirl;aarm64;if [[ $(uname -a | grep "x86_64") ! "" ]];then aamd64;fi ;if [ ! -d $s ];then mkdir $s;fi ;cd $s;wget https://yanyu.…

git回滚指定版本相关操作

当提交推送到远程仓库之后&#xff0c;需要回退到特定版本,去修改该代码,然后在推送到远程仓库; 1.查看目前版本状态: git status 2.查看提交日志&#xff0c;找到需要回滚的git版本号 git log 3.将当前分支回滚到id9c45732c5701fc84164bebe3c05760a72a4ece12 #这个是软回滚&am…

一个基于容斥原理的概率模型

为论述概率模型的思想&#xff0c;本部分以下图所描述的情况作为例子讲述&#xff0c;为简化图省略线路开关。 不同于单供网络&#xff0c;双供网络由于多条联络线&#xff0c;存在多个扩展供电方案。设供电路径P(p1,p2,..,pn)P(p_1,p_2,..,p_n)P(p1​,p2​,..,pn​)&#xff…

wodFtpDLX ActiveX 组件--Crack

wodFtpDLX ActiveX 组件 FTP 组件&#xff0c;安全&#xff08;SSL、SSH&#xff09;FTP ActiveX 客户端 FtpDLX 组件是 FTP&#xff08;或者更确切地说&#xff0c;文件传输&#xff09;客户端组件。它不仅提供老式的 FTP 协议&#xff0c;还允许您使用安全的 SFTP&#xff08…

短视频怎么在平台规则之内更快更好的吸引用户粉丝的关注

短视频怎么在平台规则之内更快更好的吸引用户粉丝的关注 每天一组短视频运营小技巧&#xff0c;碎片化学习优化自己的账号&#xff0c;今天来学习内容发布技巧&#xff1a; 内容上: 关心用户喜欢看什么 &#xff0c;在视频中埋下泪点笑点吐槽点以及所有你能想到的可以激发观众…

浅谈Linux系统信息与资源

大家将来应用开发Linux程序&#xff0c;无论是ARM架构的板子&#xff0c;还是在Linux上开发应用程序&#xff0c;相信大家都会用到到一些系统相关的信息&#xff0c;譬如时间、日期、以及其它一些系统相关信息&#xff0c;今天带大家了解一下如何通过 Linux 系统调用或 C 库函数…

springMVC参数绑定源码分析

一、遇到的问题 1. 在请求时get方法路径传参&#xff0c;接收时&#xff0c;用枚举接收&#xff0c;出现参数绑定错误 请求路径&#xff1a;http://localhost:9104/api/sent/test2?type0 后端代码&#xff1a; GetMapping("/test2")public String openNewFile2(…