其他分享
首页 > 其他分享> > canvas_10 画圆

canvas_10 画圆

作者:互联网

 

 

<template>
    <view class="zcvs">

        <view class="zcvs-item">
            <view>07_画圆</view>
            <view>
                <canvas canvas-id="cvs" id="cvs" style="width: 400px; height: 400px;border: 1px solid #007AFF;" />
            </view>
        </view>

    </view>
</template>

<script>
    export default {
        data() {
            return {};
        },
        onReady() {
            this.drawCvs();
        },
        methods: {
            drawCvs() {
                const ctx = uni.createCanvasContext('cvs');
                ctx.setLineWidth(3);
                ctx.setStrokeStyle("#007AFF");
                ctx.setFillStyle("#DD524D");

                let centX = 200;
                let centY = 200;
                let radius = 100;

                ctx.beginPath();
                ctx.arc(centX, centY, radius, 0, 1 * Math.PI, false);
                ctx.stroke();

                ctx.moveTo(centX / 2, centY / 2);
                ctx.arc(centX / 2, centY / 2, radius / 2, 0, 2 * Math.PI, false);

                ctx.fill();
                ctx.draw();
            },
        }
    }
</script>

<style lang="scss" scoped></style>

 

标签:10,canvas,centX,ctx,centY,radius,画圆,let
来源: https://www.cnblogs.com/luwei0915/p/15255641.html