canvas_03 画弧线

canvas_03 画弧线

 

 

<template>
    <view class="zcvs">

        <view class="zcvs-item">
            <view>02_画弧线</view>
            <view>
                <canvas class="zcvs-cvs" canvas-id="cvs2" id="cvs2" />
            </view>
        </view>

    </view>
</template>

<script>
    export default {
        data() {
            return {

            };
        },
        onReady() {
            this.drawCvs2();
        },
        methods: {
            // 02_画弧线
            drawCvs2() {
                const ctx = uni.createCanvasContext('cvs2');
                ctx.beginPath();
                let angle = 0
                let timer = setInterval(() => {
                    ctx.setLineWidth(20);
                    ctx.setStrokeStyle('#007AFF');
                    ctx.setFillStyle("#4CD964")
                    ctx.arc(100, 100, 50, angle * Math.PI, (angle + 0.5) * Math.PI, false);
                    ctx.fill();
                    ctx.stroke();
                    ctx.draw();
                    angle += 0.5;
                }, 200)
                setTimeout(() => {
                    clearInterval(timer);
                }, 10000)
            },
            drawCvsn() {
                const ctx = uni.createCanvasContext('cvsn');
                ctx.setLineWidth(30);
            },
        }
    }
</script>

<style lang="scss" scoped>
    .zcvs {
        .zcvs-item {
            border: 1upx solid #eee;
            margin-bottom: 40upx;
        }

        .zcvs-cvs {
            border: 1px solid #007AFF;
            height: 500upx;
            width: 100%;
            box-sizing: border-box;
        }
    }
</style>

 

上一篇:Unity3d相机跟随角色


下一篇:第1天 CSS3有哪些新增的特性?