Skip to content

Instantly share code, notes, and snippets.

@ovace
Forked from robkamp/ColorElements.ajs
Created May 14, 2024 20:35
Show Gist options
  • Save ovace/d970d6eac3e6a228c4371883455e9a29 to your computer and use it in GitHub Desktop.
Save ovace/d970d6eac3e6a228c4371883455e9a29 to your computer and use it in GitHub Desktop.
#jArchi Color the selected elements with web safe colors
// Author: Rob Kamp
// Requires: jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
// Purpose: Color the selected elements with web safe colors
// Date: 2019-11-20
// Version 1.1
// Change: changed the title to add the #jArchi tag
console.log("Start: Color the selected elemets");
// Web safe colors
colors = ['#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231', '#911eb4', '#46f0f0', '#f032e6', '#bcf60c', '#fabebe', '#008080', '#e6beff', '#9a6324', '#fffac8', '#800000', '#aaffc3', '#808000', '#ffd8b1', '#000075', '#808080'];
// Sort the selected concepts on the diagram
$(selection).sort(function (left,right) {
return left.bounds.x-right.bounds.x;
});
// Vairable to track the color to be selected
color = 0;
// Walk through the sorted and selected elements
$(selection).each(function (element) {
// Select the fill color
element.fillColor = colors[color++ % colors.length];
});
console.log("End: Color the selected elemets");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment