zoukankan      html  css  js  c++  java
  • canvas_21 矩阵变换

    <template>
        <view class="zcvs">
    
            <view class="zcvs-item">
                <view>
                    <canvas canvas-id="cvs" id="cvs" style=" 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>
  • 相关阅读:
    重载
    两数之和
    求二叉树层序遍历
    最小的K的个数
    二分查找
    实现二叉树先序,中序,后序
    判断 链表中是否有环
    设计LRU缓存结构
    排序
    反转链条
  • 原文地址:https://www.cnblogs.com/luwei0915/p/15265858.html
Copyright © 2011-2022 走看看