我如何在画布中移动旋转图标?

时间:2017-02-16 06:12:54

标签: javascript html5-canvas fabricjs

enter image description here

这是我的代码

var _changeCanvasIcons = function(side){
        side.hasControlCallback = {
            tr: true,
            mtr: true
        };

        side.controlCallback = {
            tr: function (ctx, left, top, size) {
                var image = new Image(), x, y;

                image.src = 'assets/img/control-icons/delete.png';
                x = left - image.width/2 + size/2;
                y = top - image.height/2 + size/2;

                ctx.drawImage(image, x, y);
            },
            mtr: function (ctx, left, top, size) {
                var image = new Image(), x, y;

                image.src = 'assets/img/control-icons/rotate.png';


                ctx.drawImage(image, x, y);
            }
        };
    }

0 个答案:

没有答案