canvas齿轮旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas齿轮旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
html, body {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body translate="no">
<canvas id="c">
<script >
const c = document.querySelector("#c");
const ctx = c.getContext("2d");
const dpr = Math.min(2, window.devicePixelRatio);
c.width = window.innerWidth * dpr;
c.height = window.innerHeight * dpr;
c.style.imageRendering = "pixelated";
c.style.width = "100vw";
c.style.height = "100vh";
const bgPalette = ["#7209b7", "#560bad", "#480ca8", "#3a0ca3"];
const palette = [
"#f72585",
"#b5179e",
"#3f37c9",
"#4361ee",
"#4895ef",
"#4cc9f0"];
function pseudoRandom(seed) {
return Math.sin(seed) * 10000 - Math.floor(Math.sin(seed) * 10000);
}
function noise(x, y) {
const seed = x * 137 + y * 149; // Генерация уникального числа
return pseudoRandom(seed) % 1; // Возвращаем значение от .........完整代码请登录后点击上方下载按钮下载查看
网友评论0