p5实现线条斜角绘制圆动画效果代码

代码语言:html

所属分类:动画

代码描述:p5实现线条斜角绘制圆动画效果代码,结合p5.capture科实现将动画过程录制成gif,按s键录制。

代码标签: p5 线条 斜角 绘制 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
    * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  background: radial-gradient(circle at center, #878889, #2f353f);
  display: grid;
  grid-template-rows: 1fr -webkit-min-content;
  grid-template-rows: 1fr min-content;
  place-items: center;
}

.ui {
  padding: 1rem;
}

button {
  background: #f2f2f2;
  border: none;
  border-radius: 0.2rem;
  color: #2f353f;
  padding: 0.5rem;
}
</style>

</head>

<body>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.5.0.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tinycolor.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.capture.umd.min.js"></script>
    <script >
        const zinc = "#EEEBEB";
const paynes = "#29313E";
const cobaltTeal = "#38B0C1";

const weeklyColors = [
cobaltTeal,
"#FFBE98"];

const dailyColors = [];

let colors = weeklyColors.concat(dailyColors);
colors = colors.map(color => tinycolor(color).toHsl());
colors = colors.filter(color => {
  return color.h > 0 && color.s > 0.07;
});
colors = colors.sort((a, b) => {
  return b.l - a.l;
});
colors = colors.map(color => tinycolor(color).toHslString());

const modulateColor = (baseColor, hRange = 8, sRange = 8, lRange = 8) => {
  const random = (min, max) => Math.random() * (max - min) + min;
  baseColor = tinycolor(baseColor).toHsl();

  const h = Math.floor(baseColor.h + random(-hRange, hRange));
  const s = Math.floor(baseColor.s * 100 + random(-sRange, sRange));
  const l = Math.floor(baseColor.l * 100 + random(-lRange, lRange));

  return `hsl(${h}, ${s}%, ${l}%)`;
};

P5Capture.setDefaultOptions({
  disableUi: true,
  duration: 300,
  format: "gif",
  framerate: 60 });


let scaleOutput = 1;
let d.........完整代码请登录后点击上方下载按钮下载查看

网友评论0