How to override drawRect method in BpmnRenderer?

I want to fill the rectangle with a color gradient by overriding the drawRect method in BpmnRenderer.

Hi raangs4u,

If you want to generate a color gradient in the BpmnRenderer, you can use the gradient function of SnapSVG:

function drawRect(p, width, height, r, offset, attrs) {

    var gradient = p.gradient("l(0, 0, 1, 1)#000-#f00-#fff");

    attrs = computeStyle(attrs, {
      stroke: 'black',
      strokeWidth: 2,
      fill: gradient

But the preferred solution would be to style the gradient using CSS outside the BpmnRenderer

Hi pedesen,

Thanks for your reply.

I don’t want to edit the source code that is why I wanted to override the method.

I was to able to change the color of tasks using css but I am unable to generate gradient using css for the tasks.

Could you provide a sample code for the css changes?

Okay, I might misunderstood you. If you want to know how to generally override the BpmnRenderer you could take a look at our custom elements example: There you can find a CustomRenderer where you can see how to add custom elements. You can also override the rendering of existing BPMN elements if you use the according type (i.e. bpmn:Task instead of custom:triangle).

It’s different than I said, and it is apparently not possible to style a gradient on SVG elements using CSS, my bad, sorry.

Have you solved it? I also want to know how to do it.

Please do not necrobump old topics. Instead link to this thread from new topic.