zoukankan      html  css  js  c++  java
  • HTML5 Cavans(8) 图像

    $代表jquery

            window.onload = function () {
                var cancans = document.getElementById("myCanvas");
                //得到2D渲染上下文
                var context = document.getElementById("myCanvas").getContext("2d");
    
                var img = new Image();
                img.width = "500";
                img.height = "400";
                img.src = "images/canvas.png";
                $(img).load(function () {
    
                    //context.drawImage(img, 0, 0); //默认图片大小
                    //context.drawImage(img, 10, 10, 100, 100)//指定大小
                    context.shadowBlur = 20;
                    context.shadowColor = "blue";
                    //图片裁剪 
                    //参数 源图,源图原点x,y坐标,源图在原点开始的宽长,画布开始画的点x,y,宽长
                    //drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
    
                    //万花筒效果
                    //右下
                    context.translate(200, 200);
                    context.drawImage(img, 0, 0, 500, 500, 0, 0, 200, 200);
    
                    //左下
                    //先缩放,画布坐标已经改变,(-200,200)为原(200,200)位置
                    context.setTransform(1, 0, 0, 1, 0, 0);
                    context.scale(-1, 1);
                    context.translate(-200, 200);
                    context.drawImage(img, 0, 0, 500, 500, 0, 0, 200, 200);
    
                    //左上
                    //先定位,不需要重新转换位置
                    context.setTransform(1, 0, 0, 1, 0, 0);
                    context.translate(200, 200);
                    context.scale(-1, -1);
                    context.drawImage(img, 0, 0, 500, 500, 0, 0, 200, 200);
    
                    //右上
                    context.setTransform(1, 0, 0, 1, 0, 0);
                    context.translate(200, 200);
                    context.scale(1, -1);
                    context.drawImage(img, 0, 0, 500, 500, 0, 0, 200, 200);
    
                });
    
            };
  • 相关阅读:
    DBCP连接池
    获取自动生成的主键
    将图片存储到数据库中
    java.nio.file.AccessDeniedException
    mysql8 :客户端连接caching-sha2-password问题
    理解 Android Build 系统(转载)
    C build error fix
    linux硬链接和软链接的区别
    du -sh
    linux proc maps文件分析
  • 原文地址:https://www.cnblogs.com/FlyCat/p/2580975.html
Copyright © 2011-2022 走看看