Add interactive roadmap setup
This commit is contained in:
28
lib/renderer/utils.ts
Normal file
28
lib/renderer/utils.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export function getRGBFromDecimalColor(color: number) {
|
||||
let red = (color >> 16) & 0xff;
|
||||
let green = (color >> 8) & 0xff;
|
||||
let blue = color & 0xff;
|
||||
return `rgb(${red},${green},${blue})`;
|
||||
}
|
||||
|
||||
export function makeSVGElement(
|
||||
type: string,
|
||||
attributes: Record<string, any> = {},
|
||||
parent?: any
|
||||
): SVGElement {
|
||||
let element = document.createElementNS('http://www.w3.org/2000/svg', type);
|
||||
|
||||
for (let prop in attributes) {
|
||||
if (!attributes.hasOwnProperty(prop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
element.setAttribute(prop, attributes[prop]);
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
Reference in New Issue
Block a user