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",
fill: true,
})
}
var m = 3.5 * n;
new Zdog.Ellipse({
width: 0.75,
height: 1.5,
addTo: d,
color: c.eye,
translate: {
x: m
},
stroke: 2,
fill: true,
});
new Zdog.Ellipse({
addTo: d,
height: 3,
width: 1.2,
quarters: 2,
translate: {
x: m,
y: -3
},
rotate: {
z: -TAU / 4 + 0.15 * n * (g ? 1 : -1)
},
color: c.hair,
stroke: 1,
fill: false,
closed: true,
})
});
new Zdog.Shape({
path: [{
x: -1
}, {
x: 1
}, {
z: -4
}, ],
addTo: f,
translate: {
y: -4,
z: -1
},
stroke: 18,
color: c.hair,
});
var a = new Zdog.Shape({
path: [{}, {
arc: [{
z: 4,
y: 4
}, {
z: 0,
y: 8
}, ]
}, ],
addTo: f,
translate: {
x: 2,
y: -7.5,
z: 6
},
rotate: {
x: 0.5,
z: -0.5
},
stroke: 4,
color: c.hair,
closed: false,
});
a.copy({
translate: {
x: 5,
y: -6,
z: 5
},
rotate: {
x: -0.3,
z: -0.5
},
});
a.copy({
translate: {
x: 5,
y: -6,
z: 3
},
rotate: {
y: -0.7,
z: -1
},
});
a.copy({
translate: {
x: -2,
y: -7.5,
z: 6
},
rotate: {
x: 0,
z: TAU / 16 * 6
},
});
a.copy({
translate: {
x: -5,
y: -6,
z: 5
},
rotate: {
x: 0,
z: TAU / 4
},
});
a.copy({
translate: {
x: -5,
y: -6,
z: 3
},
rotate: {
y: 0.7,
z: 1
},
});
new Zdog.Shape({
path: [{
x: -3
}, {
x: 3
}, ],
addTo: f,
stroke: 7,
translate: {
y: -8,
z: 5
},
color: c.hair,
});
var l = new Zdog.Shape({
path: [{
y: -4,
z: 0
}, {
bezier: [{
y: -10,
z: -14
}, {
y: 0,
z: -16
}, {
y: 0,
z: -26
}]
.........完整代码请登录后点击上方下载按钮下载查看
网友评论0