首页 > 其他 > 详细

canvas_21 矩阵变换

时间:2021-09-16 14:09:23      阅读:37      评论:0      收藏:0      [点我收藏+]

技术分享图片

<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>

 

canvas_21 矩阵变换

原文:https://www.cnblogs.com/luwei0915/p/15265858.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!