Custom link with multiple segments

hi i’m working on a project which needs to draw a segmented link.
and each segment has different color and pattern. and they needs to behave like a single link. so i don’t want to add any intermediate nodes to have multiple separate links.
do you guys have any ideas?

If you have a reasonable limit on the maximum number of colors that a link can have, then:

thank you walter, it’s working.
0pF3bAAAAAElFTkSuQmCC