zdog实现三维金币旋转翻转动画效果代码

代码语言:html

所属分类:动画

代码描述:zdog实现三维金币旋转翻转动画效果代码

代码标签: zdog 三维 金币 旋转 翻转 动画

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

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

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

  
  
<style>
body {
	margin: 0;
	min-block-size: 100svb;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 1rem;
	color: hsl(42, 15%, 13%);
	background: url('data:image/svg+xml,<svg opacity="0.2" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">\
        <pattern id="p" width="4" height="4" patternTransform="rotate(45)" patternUnits="userSpaceOnUse" viewBox="-10 -10 20 20">\
            <circle fill="hsl(47 100%25 62%25)" r="5" />\
            <circle fill="hsl(42 96%25 50%25)" r="4" />\
            <circle fill="hsl(47 100%25 62%25)" r="2" />\
		</pattern>\
    <rect fill="url(%23p)" width="40" height="40" />\
    </svg>'),
		hsl(45, 100%, 96%);
	font-family: system-ui;
	background-size: 100%;
}

canvas {
	display: block;
	width: 400px;
	height: 400px;
}

button {
	color: hsl(45, 100%, 96%);
	background: hsl(42, 15%, 13%);
	display: block;
	font-family: inherit;
	font-size: 1rem;
	border: none;
	padding: 0.4rem 0.8rem;
	transition: translate 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:focus {
	outline-offset: 2px;
}

button[data-state="spin"] {
	transition-duration: 1s;
	transition-timing-function: cubic-bezier(0.68, -0.6, 0.32, 1.6);
	translate: -1rem 0;
}
</style>


  
</head>

<body >
  <canvas width="400" height="400"></canvas>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zdog.dist.js"></script>
      <script  >
const { Illustration, Shape, Cylinder, TAU } = Zdog;

const stroke = 0;
const diameter = 30;
const length = 2;
const rim = 2;

const colors = {
  coin: ["hsl(35 100% 47%)", "hsl(42 96% 50%)", "hsl(47 100% 62%)"],
  details: "hsl(210 10% 23%)" };


const illustration = new Illustration({
  element: "canvas",
  zoom: 10 });


const base = new Cylinder({
  addTo: illustration,
  color: colors.coin[1],
  stroke,
  diameter,
  length });


const overlay = new Cylinder({
  color: colors.coin[0],
  frontFace: colors.coin[2],
  stroke,
  diameter: base.diameter / 2,
  length: base.length });


overlay.copyGraph({
  addTo: base,
  translate: {
    z: overlay.length / 2 + base.length / 2 } });



overlay.copyGraph({
  addTo: base,
  translate: {
    z: (overlay.length / 2 + base.length / 2) * -1 },

  rotate: {
    y: TAU / 2 } });



const r = diameter / 2.1;
const o = overlay.length + base.length / 2;

const ring = new Shape({
  addTo: base,
  color: colors.coin[2],
  stroke,
  fill: true,
  path: [
  { x: 0, y: r * -1 },
  {
    arc: [
    { x: r, y: r * -1 },
    { x: r, y: 0 }] },


  {
    arc: [
    { x: r, y: r },
    { x: 0, y: r }] },


  {
    arc: [
    { x: r * -1, y: r },
    { x: r * -1, y: 0 }] }.........完整代码请登录后点击上方下载按钮下载查看

网友评论0