diff --git a/src/layout.js b/src/layout.js index 9bd83c8..49e0e66 100644 --- a/src/layout.js +++ b/src/layout.js @@ -13,6 +13,7 @@ import { getFontScale, getFontSize, getText, + getRotation, getTransform, rotate, } from './utils'; @@ -170,12 +171,17 @@ export function layout({ // @ts-ignore .padding(padding) .words(clonedeep(sortedWords)) - .rotate(() => { + .rotate((word) => { if (rotations === undefined) { // Default rotation algorithm return (~~(random() * 6) - 3) * 30; } + // get rotation from word + if (getRotate(word)){ + return getRotate(word); + } + return rotate(rotations, rotationAngles, random); }) .spiral(spiral) diff --git a/src/utils.js b/src/utils.js index 0c0252b..f158f18 100644 --- a/src/utils.js +++ b/src/utils.js @@ -43,6 +43,10 @@ export function getText(word) { return word.text; } +export function getRotation(word) { + return word.rotation; +} + export function getTransform(word) { const translate = `translate(${word.x}, ${word.y})`; const rotate =