Decode BlurHash strings to SwiftUI MeshGradient or Color with various customization options.
BlurHashViews
Decode BlurHash strings to SwiftUI Color
or MeshGradient
with various customization options.
BlurHash (blurha.sh) is a way of representing placeholders for images using a compact string representation. Existing implementations focus on decoding a BlurHash to a small image that can be used as a placeholder. This package allows you to create native SwiftUI views directly from BlurHash encoded strings.
Open Sources/BlurHashViews/Previews.swift
in Xcode 16 for an interactive SwiftUI preview with example views of BlurHashes from social media sites, allowing you to try different customization options for how they are displayed, including:
punch
argument to control the contrast between colors in the BlurHash.There’s also a decoder that returns the mesh points and colors so you can customize it in code however you want – animate the points to make it swirl, find the most intense color in the image, make custom transitions… whatever you can dream up!
Color
from the average of a BlurHash.MeshGradient
from the colors in a BlurHash.For previous operating systems, the original BlurHash library provides a UIImage-based decoding implementation.