From 0b74ad78e2432864671ccdc366d7c8d30a75f998 Mon Sep 17 00:00:00 2001 From: ADI TEJA DASARI Date: Thu, 26 Sep 2024 16:16:33 +1000 Subject: [PATCH 1/2] Update utils.js - add method getRotation --- src/utils.js | 4 ++++ 1 file changed, 4 insertions(+) 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 = From 57e1bdf4d9b71730a3954591153957bc9811678e Mon Sep 17 00:00:00 2001 From: ADI TEJA DASARI Date: Thu, 26 Sep 2024 16:23:05 +1000 Subject: [PATCH 2/2] Update layout.js - apply rotation defined in word --- src/layout.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)