简体   繁体   English

将背景图像添加到jsPlumb中的连接器

[英]Add a background image to a connector in jsPlumb

I'm wondering if it is possible to add a background image to a connector. 我想知道是否可以将背景图像添加到连接器。

My objective is to create something like this: 我的目标是创建这样的东西: 在此输入图像描述

This way I could have an animated images in the background symbolizing the direction and type of the connection. 这样我可以在背景中有一个动画图像,象征着连接的方向和类型。

AFAIK it is not possible since the connection is made up of SVG object which itself acts as background image. AFAIK是不可能的,因为连接由SVG对象组成,SVG对象本身充当背景图像。 You can try dashstyle option while tweaking paint-style and gradients to obtain appropriate arrow as shown in image. 您可以在调整绘画样式和渐变时尝试使用dashstyle选项以获得图像中所示的相应箭头。 For more refer: API DOC 有关更多信息,请参阅: API DOC

Sample Code: 示例代码:

jsPlumb.Defaults.PaintStyle = {
    lineWidth: 4,
    strokeStyle: 'rgba(123, 123, 123, 1)',
    gradient:{
              stops:[[0,"green"], [1,"red"]]
        },
    dashstyle: "7"
};

Result: 结果:

示例图像

Note : Remember to use jsPlumb.setRenderMode(jsPlumb.SVG) since dashstyle doesn't work with jsPlumb.CANVAS (by default it is SVG) 注意 :请记住使用jsPlumb.setRenderMode(jsPlumb.SVG)因为dashstyle不能与jsPlumb.CANVAS一起使用(默认情况下它是SVG)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM