js+svg实现一个svg花朵生成器代码
代码语言:html
所属分类:其他
代码描述:js+svg实现一个svg花朵生成器代码,可调节参数生成不同类型的花朵svg代码,而且svg代码可复制。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
display: grid;
place-items: center;
}
html, body {
background: #334d44;
height: 100%;
}
svg {
height: 100vh;
width: 100vw;
}
svg, g {
transform-box: fill-box;
transform-origin: 50% 50%;
}
.button {
background: #000;
border: none;
bottom: 2rem;
color: #fff;
cursor: pointer;
font-size: 0.7rem;
padding: 1em 2em;
position: absolute;
right: 2rem;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.button::after {
color: #fff;
content: "all done!";
height: 100%;
left: 0;
position: absolute;
top: -1.5em;
visibility: hidden;
width: 100%;
z-index: 0;
}
.button.copied::after {
opacity: 0;
transform: translateY(-200%);
transition: transform 0.75s ease-out, opacity 0.25s ease-out 0.5s;
visibility: visible;
}
</style>
</head>
<body >
<svg id="flower" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" aria-labelledby="svgTitle svgDesc" role="img">
<title id="svgTitle">A generative illustration</title>
<desc id="svgDesc">Click on the image to redraw it!</desc>
</svg>
<button class="button" type="button">Copy SVG</button>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script>
<script type="module">
import copy from "https://cdn.skypack.dev/copy-to-clipboard@3.3.1";
const utils = {
getRandFromRange: function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
};
class Illustration {
boxSize;
hue = 0;
box = { width: 0, height: 0 };
element;
svg;
constructor(selector, settings) {
this.boxSize = 500;
this.box = {
width: this.boxSize * 4,
height: this.boxSize * 4
};
this.settings = settings;
this.setSVG(selector);
this.createSettingsBox().........完整代码请登录后点击上方下载按钮下载查看
















网友评论0