paperjs pointtext onhover选择并调整大小

问题描述 投票:0回答:2

我正在尝试使用paperjs在画布上添加pointtext。我能够在画布上创建pointtext但需要处理文本的拖动和调整大小。

scope.drawText = function () {
               var pointTextLocation = new p.Point(100,100);
                var myText = new p.PointText(pointTextLocation);
                myText.fillColor = 'red';
                myText.fontSize= 25;
                myText.content = 'Sample Text';
            };

是否可以使用paperjs在屏幕下方进行操作。

我没有在谷歌找到任何地方。请建议怎么做?

enter image description here

text resize drag point paperjs
2个回答
2
投票

这是可能的(使用Item.scaling),但您必须自己编码缩放框(通过使用与鼠标和键盘事件交互的常规形状绘制)。这个手工制作的缩放框将控制你的PointText.scalingPointText.rotation属性。

缩放框不是简单的编码,也不是很难,我很遗憾地注意到,这是一个非常频繁的问题,它还没有标准解决方案(实现这种缩放框的解决方案太多),以及据我所知,还没有好的代码片段可供依赖。


-1
投票

我已经更新了我的代码。我能够创建pointtext并在画布中的任何其他位置拖动。 check here

但是,当我双击时,我必须编辑文本。怎么做?

var pointTextLocation = new p.Point(x,y);

                var myText = new p.PointText(pointTextLocation);
                myText.fillColor = 'red';
                myText.fontSize= 25;
                myText.content = 'Sample Text';

                myText.onDoubleClick = function(event) {
                    this.fontSize= 50;
                }
                myText.onClick = function(event) {
                    if(this.selected){
                        this.selected= false;
                    }else{
                     this.selected= true;   
                    }

                }
                 myText.onMouseDrag = function(event) {
                    myText.position=event.point;
                }
© www.soinside.com 2019 - 2024. All rights reserved.