Skip to content

Instantly share code, notes, and snippets.

@AndyDentFree
Created February 17, 2022 04: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 AndyDentFree/c8c8b11368939869c1422e2ee3ce9c84 to your computer and use it in GitHub Desktop.
Save AndyDentFree/c8c8b11368939869c1422e2ee3ce9c84 to your computer and use it in GitHub Desktop.
Sample showing creating a Touchgram from within code, as part of our test suite.
static func makeManyTextVaryingOutlines(workNum: UInt32) -> tgTouchgram {
let fc = tgColor(systemColor: .red)
let ec = tgColor(systemColor: .yellow)
let pt: UInt16 = 48
let lw:[CGFloat] = Array(stride(from: 0.0, through: 4.0, by: 0.5))
return tgTouchgram(title: "Lots of Text Varying Outlines", scenes: [
tgScene(background: tgColorBackground(fill: tgColor(systemColor: .blue)),
triggers: [],
nodes: tgNodeList(nodes: [
tgSimpleTextNode(position: tgNodePosition(anchored: .topLeft, paddingPixels: 8),
text: "Hi",
styleToStash: tgTextStyle(fontName: "Arial", size: pt, traits: .plain,
drawStyle: tgDrawStyle(mainColor: fc, optionalColor: ec, lineWidth: lw[0])
)),
tgSimpleTextNode(position: tgNodePosition(anchored: .topCentered, paddingPixels: 8),
text: "Hello",
styleToStash: tgTextStyle(fontName: "Arial", size: pt, traits: .plain,
drawStyle: tgDrawStyle(mainColor: fc, optionalColor: ec, lineWidth: lw[1])
)),
tgSimpleTextNode(position: tgNodePosition(anchored: .topRight, paddingPixels: 8),
text: "Yo",
styleToStash: tgTextStyle(fontName: "Arial", size: pt, traits: .plain,
drawStyle: tgDrawStyle(mainColor: fc, optionalColor: ec, lineWidth: lw[2])
)),
tgSimpleTextNode(position: tgNodePosition(anchored: .centerLeft, paddingPixels: 0),
text: "Me",
styleToStash: tgTextStyle(fontName: "Arial", size: pt, traits: .plain,
drawStyle: tgDrawStyle(mainColor: fc, optionalColor: ec, lineWidth: lw[3])
)),
...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment