【问题标题】:Putting multiple films in a circle in Raphael/Joint.js在 Raphael/Joint.js 中将多部电影放在一个圆圈中
【发布时间】:2013-12-03 23:37:21
【问题描述】:

我在joint.js 中有一个FSA,我需要从圆圈底部开始将状态(圆圈)半填充到特定比例,例如1/2 或1/6。棘手的部分是它需要做两次——一个较大的半填充和一个较小的半填充。

这就是我想要做的:

我不知道如何做到这一点。

【问题讨论】:

    标签: javascript jointjs


    【解决方案1】:

    诀窍是创建三个 SVG 圆圈并为它们定义剪辑路径。以下示例使用自定义 SVG 标记创建自定义 JointJS 形状(继承自 fsa.State),以启用您在图像中显示的颜色:

    var graph = new joint.dia.Graph;
    var paper = new joint.dia.Paper({ el: $('#paper'), width: 650, height: 400, model: graph });
    
    joint.shapes.fsa.MyState = joint.shapes.fsa.State.extend({
    
        markup: [
            '<g class="rotatable"><g class="scalable">',
            '<clipPath id="clip-top1"><rect x="-30" y="0" width="60" height="30"/></clipPath>',
            '<clipPath id="clip-top2"><rect x="-30" y="15" width="60" height="30"/></clipPath>',
            '<circle class="a"/><circle class="b"/><circle class="c"/>',
            '</g><text/></g>'
        ].join(''),
    
        defaults: joint.util.deepSupplement({
            type: 'fsa.MyState',
            size: { width: 60, height: 60 },
            attrs: {
                'circle': { fill: 'white' },
                '.b': { fill: 'red', 'clip-path': 'url(#clip-top1)' },
                '.c': { fill: 'blue', 'clip-path': 'url(#clip-top2)' }
            }
        }, joint.shapes.fsa.State.prototype.defaults)
    });
    
    var mystate1 = new joint.shapes.fsa.MyState({
        position: { x: 50, y: 50 },
        size: { width: 100, height: 100 },
        attrs: { text: { text: 'my state 1' } }
    });
    graph.addCell(mystate1);
    
    var mystate2 = new joint.shapes.fsa.MyState({
        position: { x: 50, y: 160 },
        size: { width: 50, height: 50 }
    });
    graph.addCell(mystate2);
    

    【讨论】:

      猜你喜欢
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      • 2018-04-14
      相关资源
      最近更新 更多