zdog实现可拖拽三维旋转的卡通人物精灵面对面效果代码

代码语言:html

所属分类:三维

代码描述:zdog实现可拖拽三维旋转的卡通人物精灵面对面效果代码

代码标签: zdog 拖拽 三维 旋转 卡通 人物 精灵 面对面

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

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

<head>
    <meta charset="UTF-8">
<style>
html {
	height:100%
}
body {
	min-height:100%;
	margin:0;
	display:flex;
	align-items:center;
	justify-content:center;
	background:#435;
	color:white;
	font-family:sans-serif;
	text-align:center
}
canvas {
	display:block;
	margin:0 auto;
	cursor:move
}

</style>
</head>

<body>

    <div class="container"><canvas class="illo"></canvas>
        <p>拖拽旋转</p>
    </div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zdog.dist.js"></script>
    <script>
  

var BokehShape = Zdog.Shape.subclass({
    bokehSize: 5,
    bokehLimit: 64,
});
BokehShape.prototype.updateBokeh = function() {
    this.bokeh = Math.abs(this.sortValue) / this.bokehLimit;
    this.bokeh = Math.max(0, Math.min(1, this.bokeh));
    return this.bokeh
};
BokehShape.prototype.getLineWidth = function() {
    return this.stroke + this.bokehSize * this.bokeh * this.bokeh
};
BokehShape.prototype.getBokehAlpha = function() {
    var a = 1 - this.bokeh;
    a *= a;
    return a * 0.8 + 0.2
};
BokehShape.prototype.renderCanvasDot = function(a) {
    this.updateBokeh();
    a.globalAlpha = this.getBokehAlpha();
    Zdog.Shape.prototype.renderCanvasDot.apply(this, arguments);
    a.globalAlpha = 1
};
BokehShape.prototype.renderPath = function(a, b) {
    this.updateBokeh();
    if (b.isCanvas) {
        a.globalAlpha = this.getBokehAlpha()
    }
    Zdog.Shape.prototype.renderPath.apply(this, arguments);
    if (b.isCanvas) {
        a.globalAlpha = 1
    }
};
var TAU = Zdog.TAU;

function makeMadeline(g, c, i) {
    var j = new Zdog.Anchor(i);
    var b = new Zdog.Group({
        addTo: j,
        rotate: {
            x: -TAU / 8
        },
        translate: {
            z: -48
        },
        updateSort: true,
    });
    var f = new Zdog.Anchor({
        addTo: b,
        translate: {
            y: -11,
            z: -2
        },
        rotate: {
            x: TAU / 8
        },
    });
    var e = new Zdog.Ellipse({
        diameter: 6,
        addTo: f,
        translate: {
            z: 4
        },
        stroke: 8,
        color: c.skin,
    });
    var d = new Zdog.Group({
        addTo: e,
        translate: {
            z: e.stroke / 2 - 0.5
        },
    });
    [-1, 1].forEach(function(n) {
        if (g) {
            new Zdog.Ellipse({
                width: 2,
                height: 1.3,
                addTo: d,
                translate: {
                    x: 4.5 * n,
                    y: 3,
                    z: -1
                },
                rotate: {
                    y: -TAU / 16 * n
                },
                stroke: 1,
                color: "#FA8",
          .........完整代码请登录后点击上方下载按钮下载查看

网友评论0