Tweakpane +svg实现可调参数的傅里叶变换绘图效果代码

代码语言:html

所属分类:其他

代码描述:Tweakpane +svg实现可调参数的傅里叶变换绘图效果代码

代码标签: Tweakpane svg 参数 傅里叶 变换 绘图

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

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

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

  
  
  
<style>
html,
body {
	height: 100vh;
	margin: 0;
	width: 100vw;
}
body {
	display: grid;
	place-content: center;
}

svg {
	border: 1px solid black;
	width: 100vw;
	height: 100vh;
}

#pane-container {
	position: fixed;
	right: 10px;
	top: 10px;
	width: 250px;

	.tp-lblv_l {
		max-width: 50px;
	}

	input[type="range"] {
		min-width: 260px;
	}

	input:not([type="range"]) {
		width: 60px;
	}
}
</style>


  
  
</head>

<body translate="no">
  <div id="pane-container"></div>
<dialog id="info"></dialog>
<svg id="svg"></svg>
  
      <script type="module">
import { Pane } from "//repo.bfw.wiki/bfwrepo/js/tweakpane.4.0.3.js";

const svg = document.getElementById("svg");

const settings = getQueryParams();

const pane = new Pane({ container: document.getElementById("pane-container") });
let step = 0.00001;
pane.addBinding(settings, "R", { min: 5, max: 320, step });
pane.addBinding(settings, "r", { min: 0.01, max: 3, step });
pane.addBinding(settings, "d", { min: -200, max: 200, step });
pane.addBinding(settings, "nPoints", { min: 10, max: 2000, step: 10 });
pane.addBinding(settings, "stroke", {
  picker: "inline",
  expanded: true });

pane.addBinding(settings, "animate");

const btnShareSVG = pane.addButton({
  title: "Copy SVG" });

const btnShareLink = pane.addButton({
  title: "Copy link" });


btnShareSVG.on("click", () => {
  copyToClipboard("SVG copied to clipboard", svg.outerHTML);
});
btnShareLink.on("click", () => {
  copyToClipboard("Link to this object copied to clipboard", getURL());
});

pane.on("change", () => {
  drawEpicycloid(settings);
});

function copyToClipboard(infoText, data) {
  navigator.clipboard.
  writeText(data).
  then(() => {
    showInfo(infoText);
  }).
  catch(err => {
    console.error("Failed to copy SVG: ", err);
  });
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0