A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$
if your browser aliases it:
~ 108 byte version
extension CGImage { | |
var isDark: Bool { | |
get { | |
guard let imageData = self.dataProvider?.data else { return false } | |
guard let ptr = CFDataGetBytePtr(imageData) else { return false } | |
let length = CFDataGetLength(imageData) | |
let threshold = Int(Double(self.width * self.height) * 0.45) | |
var darkPixels = 0 | |
for i in stride(from: 0, to: length, by: 4) { | |
let r = ptr[i] |