You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.7 KiB
94 lines
2.7 KiB
5 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
||
|
<title>Leon Sans - Pattern</title>
|
||
|
|
||
|
<style>
|
||
|
html, body {
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
overflow: hidden;
|
||
|
outline: 0;
|
||
|
margin: 0;
|
||
|
padding: 0;
|
||
|
background-color: #502c8d;
|
||
|
cursor: move;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
|
||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js"></script>
|
||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.js"></script>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<script src="../dist/leon.js"></script>
|
||
|
<script src="js/util.js"></script>
|
||
|
<script>
|
||
|
let leon, controll;
|
||
|
|
||
|
function init() {
|
||
|
generateCanvas();
|
||
|
|
||
|
controll = {
|
||
|
color: {},
|
||
|
align: {},
|
||
|
patternWidth: 40,
|
||
|
patternHeight: 10,
|
||
|
drawing: () => {
|
||
|
let i, total = leon.drawing.length;
|
||
|
for (i = 0; i < total; i++) {
|
||
|
TweenMax.killTweensOf(leon.drawing[i]);
|
||
|
TweenMax.fromTo(leon.drawing[i], 2, {
|
||
|
value: 0
|
||
|
}, {
|
||
|
delay: i * 0.05,
|
||
|
value: 1,
|
||
|
ease: Power4.easeOut
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
leon = new LeonSans({
|
||
|
text: 'The quick brown\nfox jumps over\nthe lazy dog',
|
||
|
size: getSize(120),
|
||
|
weight: 400,
|
||
|
isPath: true,
|
||
|
pathGap: 0.2
|
||
|
});
|
||
|
|
||
|
const gui = new dat.GUI();
|
||
|
gui.add(leon, 'text');
|
||
|
gui.add(leon, 'size', 20, 300);
|
||
|
gui.add(leon, 'pathGap', 0, 1);
|
||
|
gui.add(controll, 'patternWidth', 1, 200);
|
||
|
gui.add(controll, 'patternHeight', 1, 100);
|
||
|
gui.add(controll, 'drawing');
|
||
|
|
||
|
requestAnimationFrame(animate);
|
||
|
}
|
||
|
|
||
|
function animate(t) {
|
||
|
requestAnimationFrame(animate);
|
||
|
|
||
|
ctx.clearRect(0, 0, sw, sh);
|
||
|
|
||
|
const x = (sw - leon.rect.w) / 2;
|
||
|
const y = (sh - leon.rect.h) / 2;
|
||
|
leon.position(x + moveX, y + moveY);
|
||
|
|
||
|
leon.pattern(ctx, controll.patternWidth, controll.patternHeight);
|
||
|
}
|
||
|
|
||
|
window.onload = () => {
|
||
|
init();
|
||
|
};
|
||
|
</script>
|
||
|
</body>
|
||
|
|
||
|
</html>
|