@zsnout/ithkuil
Version:
A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.
45 lines (44 loc) • 1.1 kB
JavaScript
/**
* Rotates an SVG path 180 degrees, ignoring capital M commands.
*
* @param path The path to be modified.
* @returns The resulting path.
*/
export function rotate180(x) {
const all = x.split(" ");
return all
.map((text, index) => {
const value = +text;
if (isNaN(value) ||
index == 1 ||
index == 2 ||
all[index - 3] == "a" ||
all[index - 4] == "a" ||
all[index - 5] == "a") {
return text;
}
return -value;
})
.join(" ");
}
/**
* Rotates an SVG path 180 degrees, including capital M commands.
*
* @param path The path to be modified.
* @returns The resulting path.
*/
export function rotate180AndRotateStartingPoint(x) {
const all = x.split(" ");
return all
.map((text, index) => {
const value = +text;
if (isNaN(value) ||
all[index - 3] == "a" ||
all[index - 4] == "a" ||
all[index - 5] == "a") {
return text;
}
return -value;
})
.join(" ");
}