Skip to content
프로젝트

소개

A fluid, animated gradient implemented with CoreAnimation and SwiftUI.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

🐰 Fluid Gradient Project logo

A fluid, animated gradient implemented with CoreAnimation and SwiftUI, made available as a Swift Package.

Fluid Gradient

How it works

This implementation works by displaying stacked "blobs" in a coordinate space, and blurring them afterwards to make it seem seamless. The blobs are simple CAGradientLayer layers added to two separate CALayer layers: base and highlight. The latter one has an overlay blend mode to create unique patterns. You can optionally provide colors for both the base and highlight layers.

Why CALayer?

While it's easy to create the blob shapes in SwiftUI, animation in SwiftUI is still performed on the CPU. This means that your app will probably consume double-digit CPU percentages and be noted as a "high" energy consumer in Activity Monitor.

We use CALayer instead because it offloads all the work to the WindowServer, making your app have a zero performance impact despite running the gradient animation at full screen refresh rate.

Performance of Fluid Gradient

Note You can learn to code this project by yourself in a series of development tutorial articles written for the Cindori Blog.

Example usage

You can find an example buildable project that uses FluidGradient in the root of this repository (requires Xcode 14 and macOS Ventura). To use it in your app, you can start with the following:

import SwiftUI
import FluidGradient

struct ContentView: View {
    var body: some View {
        FluidGradient(blobs: [.red, .green, .blue],
                      highlights: [.yellow, .orange, .purple],
                      speed: 1.0,
                      blur: 0.75)
          .background(.quaternary)
    }
}

About Cindori

Cindori

We're a small team of developers dedicated to crafting amazing experiences for Apple platforms.

Check out our apps and developer blog at cindori.com.

Contributors

Licensing

This project is made available through the MIT License.

관련 프로젝트 살펴보기

불러오는 중…