canvas_21 矩阵变换

canvas_21  矩阵变换

<template>
    <view class="zcvs">

        <view class="zcvs-item">
            <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.setFillStyle("#007AFF");

                ctx.beginPath();
                // transform() 方法的行为相对于由 rotate(), scale(), translate()
                ctx.fillStyle = "yellow";
                ctx.fillRect(100, 0, 150, 100);

                ctx.transform(1, 0.5, -0.5, 1, 30, 10);
                ctx.fillStyle = "red";
                ctx.fillRect(100, 0, 150, 100);

                ctx.transform(1, 0.5, -0.5, 1, 30, 10);
                ctx.fillStyle = "blue";
                ctx.fillRect(100, 0, 150, 100);

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

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

 

上一篇:电力调度优化理论与应用例题代码(1)


下一篇:canvas_15 阴影与透明