Skip to content

Instantly share code, notes, and snippets.

@aferriss
Last active November 20, 2018 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aferriss/bb76e9ba094cafbc43b3c0cdd1c83d22 to your computer and use it in GitHub Desktop.
Save aferriss/bb76e9ba094cafbc43b3c0cdd1c83d22 to your computer and use it in GitHub Desktop.
letters
var index = 0
var originalText = "Love"
var text = originalText
/// Letters is just an array of structs with information about character, fontSize, character width/height
var textPathLength = letters.map({$0.width}).reduce(0, +) /// The total length of my word before I start adding letters
while textPathLength.f < perimeter {
text += originalText[index]
textPathLength += letters[index].width
index = (index + 1) % originalText.count
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment