Conversation
…ions into test-pattern # Conflicts: # README.md # Sources/CIColor+Extensions.swift # Sources/CIImage+Blending.swift # Sources/CIImage+Text.swift # Sources/CIImage+Transformation.swift # Sources/CIKernel+MetalSource.swift # Tests/ColorExtensionsTests.swift # Tests/ImageTransformationTests.swift
maikz
left a comment
There was a problem hiding this comment.
I reviewed parts of it. The rest will follow soon
| // Note: We reverse here so the first color specified in the array is displayed on the top. | ||
| for (row, color) in rowColors.reversed().enumerated() { | ||
| var swatch = CIImage.colorSwatch(for: color) | ||
| swatch = swatch.moved(to: CGPoint(x: CGFloat(column) * (swatch.extent.width + self.margin), y: CGFloat(row) * (swatch.extent.height + self.margin))) |
There was a problem hiding this comment.
let swatch = CIImage.colorSwatch()
.moved(to:)
or even
pattern = CIImage.colorSwatch()
.moved(to:)
.composited(over: pattern)
?
There was a problem hiding this comment.
The problem here (and with the label) is that I need the extent of the swatch in the moved(to:), so I can't really chain it.
| /// Colors for which swatches should be rendered, ordered by columns (outer) and rows (inner arrays). | ||
| private static var swatchColors: [[CIColor]] { [[.red, .green, .blue], [.cyan, .magenta, .yellow]] } | ||
| /// The different color spaces in which colors should be rendered in the color swatches. | ||
| private static var swatchColorSpaces: [(label: String, colorSpace: CGColorSpace)] = [ |
There was a problem hiding this comment.
Would it make sense to have some kind of Swatch type with label, color space and color?
There was a problem hiding this comment.
This dict here is only needed to assign labels to the different color spaces. What would the Swatch type replace then?
| // Put a label in the bottom left corner over the tile that displays the brightness value (also in nits). | ||
| let labelText = String(format: "%.2f (%d nits)", brightness, Int(brightness * 500)) | ||
| let labelColor = CIColor(extendedWhite: brightness)!.contrastOverlayColor | ||
| let label = CIImage.text(labelText, fontName: self.labelFont, fontSize: size.height / 8.0, color: labelColor)! |
There was a problem hiding this comment.
If we want to be very safe we can add a fontScaleFactor since we divide by 8 multiple times.
There was a problem hiding this comment.
And one time / 7.0. 😅
I didn't want to over-engineer this more than I already did. Otherwise, I'll end up writing a layout system for Core Image. 😬
Created an EDR brightness and wide gamut color test pattern image that can be used, for instance, to verify colors are displayed correctly, filters conserve those color properties correctly, etc.