Score Card 4.0.2 Released
- Date
Score Card 4.0.2 fixes a rare bug that could caused the new game screen to hang.
Check out the app on the App Store.
Score Card 4.0.2 fixes a rare bug that could caused the new game screen to hang.
Check out the app on the App Store.
Day 15 of Advent of Code is represented by a robot going haywire and moving boxes around. In part 2, these boxes go from occupying 1 space to occupying 2.
Day 10 of Advent of Code is a simple hike up a mountain. This visualization is just a representation of the searching algorithm, so a few more spaces are filled in that what represents a hiking trail.
For the past couple of years, I always used SIMD4<Float>
to represent a color, since that is what is directly used by
Metal. That’s always tricky because it’s hard to eyeball what color something is when looking at SIMD4<Float>(0.25,
0.75, 0.01, 1.0)
.
I added an extension for using native colors directly, so I can instead ask for
NativeColor.systemGreen.simd
. Under the hood, NativeColor
is just and alias for UIColor
or NSColor
.
Day 4 of Advent of Code had us do a word search for “XMAS”. My solution was to just look for the letter “X” and then spin around that point looking for the string. I though the spinning would look interesting, so I put together a simple 2D visualization.
Rendering a grid of text is slow. I added a new offscreenImage
function to my visualization library that
lets you generate a CGImage
using the same drawing tools you use for the main visualization.
let image = offscreenImage { offscreenContext in
let rect = CGRect(origin: .zero, size: CGSize(width: 20, height: 20))
let color = CGColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
fill(rect: rect, color: red, in: offscreenContext)
}
context.draw(image, in: screenRect)
Since rendering the found words would also be slow, I ended up recreating the text grid any time new highlights were found, allowing the main rendering loop to only render cursors and search vectors.