当前位置:网站首页>Generate verification code
Generate verification code
2022-07-21 12:52:00 【orange_?】
Front end generation
Write your thoughts in two days when you are free , Optimize
<html>
<head></head>
<style> </style>
<body>
<canvas id="code" width="110" height="40" onclick="draw()"></canvas>
</body>
<script> // Randomly generate colors function rgb (l, r) {
const choie = r - l + 1 let color = 'rgb(' for (let i = 1; i <= 3; ++i) {
const ran = Math.floor(Math.random() * choie + l) color = color + ran + ',' } color = color.substring(0, color.length - 1) color += ')' return color } var code = 'qwertyuiopasdfghjklzxcvbnm' function draw () {
const convas = document.getElementById('code') const ctx = convas.getContext('2d') ctx.clearRect(0, 0, 110, 40) ctx.beginPath() ctx.lineWidth = 1 ctx.fillStyle = rgb(160, 233) ctx.fillRect(0, 0, 110, 40) ctx.moveTo(0, Math.random() * 40) ctx.quadraticCurveTo(10, 10, 110, Math.random() * 40) ctx.strokeStyle = rgb(100, 140) ctx.stroke() ctx.moveTo(0, Math.random() * 40) ctx.quadraticCurveTo(20, 50, 110, Math.random() * 40) ctx.strokeStyle = rgb(1, 140) ctx.stroke() ctx.font = '20px Georgia' ctx.textAlign = 'center' ctx.textBaseline = 'middle' for (let i = 1; i <= 4; i++) {
ctx.fillStyle = rgb(100, 130) ctx.fillText(code.substr(Math.floor(Math.random() * code.length), 1), 22 * i, 20) } } window.onload = function () {
draw() } </script>
</html>
边栏推荐
猜你喜欢
随机推荐
量子计算+金融!D-Wave牵手国际信用卡组织Mastercard
二师兄的纪录片
Unhandled JS Exception: Unexpected identifier ‘_classCallCheck‘. import call expects exactly one arg
布局---BFC(块级格式化上下文)详解
Chapter 9 Yunji datacanvas ylearn causal learning open source project: from prediction to decision making
生成验证码
How does AI predict the COVID-19? A summary of Georgia Institute of technology's latest "data centric epidemic prediction"
China 1,2-pentanediol industry research and investment strategy report (2022 Edition)
独立搭建个人博客除了云服务器,还需要哪些技术知识?
Market Research and investment forecast report of China's tungsten powder industry (2022 Edition)
shell基础之条件判断
Go mod create project
My creation anniversary (July 18, 2021 - July 18, 2022)
机器学习-Kmeans
LeetCode 练习——剑指 Offer 66. 构建乘积数组
If the cause of death of the patient is controversial, the hospital should bear some responsibility if it fails to inform the autopsy
元宇宙:技术演进、产业生态与大国博弈
线程池学习
How to set measurable project goals?
公网IP自建数据库这种DTS实例类型,有什么特点?