码迷,mamicode.com
首页 > 其他好文 > 详细

knova绘制进度条

时间:2018-11-30 13:46:25      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:动画   blur   nova   eth   img   span   doc   display   技术分享   

效果:

技术分享图片

源码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>knova绘制进度条</title>
    <style>
        body {
            padding: 0;
            margin: 0;
            background-color: #f0f0f0;
            overflow: hidden;
        }
    </style>
    <script type="text/javascript" src="konva.min.js"></script>
</head>
<body>
<div id="container"></div>
<script>
    var stage = new Konva.Stage({
        container: container,
        width: window.innerWidth,
        height: window.innerHeight
    });

    var layer = new Konva.Layer();
    stage.add(layer);

    var progressValueRect = new Konva.Rect({
        x: stage.getWidth() / 8,
        y: stage.getHeight() / 2,
        height: 40,
        width: stage.getWidth() / 8 * 3,
        fill: lightblue,
        cornerRadius: 5,
        lineCap: round
    });
    layer.add(progressValueRect);


    var progressLine = new Konva.Rect({
        strokeWidth: 5,
        x: stage.getWidth() / 8,
        y: stage.getHeight() / 2,
        height: 40,
        width: stage.getWidth() / 8 * 6,
        stroke: #d0d0d0,
        cornerRadius: 5,
        shadowBlur: 4,
        shadowColor: #f0f0f0,
        shadowOffset: {x : 0, y : 0},
        shadowOpacity: 0.5
    });
    layer.add(progressLine);

    layer.draw();
    
    layer.draw();

    setInterval(function(){
        if(progressValueRect.width() < progressLine.width() ) {
            progressValueRect.width(progressValueRect.width() + 1);
            layer.batchDraw();
        }
    },20);

    var animate = new Konva.Animation(function(frame){
        var time = frame.time,        //动画执行的时间
            timeDiff = frame.timeDiff,    //上次动画执行到现在的时间
            frameRate = frame.frameRate;    //每秒中执行的帧数
    }, layer);

    animate.start();
</script>
</body>
</html>

 

knova绘制进度条

标签:动画   blur   nova   eth   img   span   doc   display   技术分享   

原文地址:https://www.cnblogs.com/alex-xxc/p/10043277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!