• Stars
    star
    215
  • Rank 183,925 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 4 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create animated irregular gradients in SwiftUI.

IrregularGradient Project logo

Twitter: @joogps

A SwiftUI library for rendering beautiful, animated and irregular gradient views.

Installation

Since this is a Swift package, it can be installed via the Swift Package Manager. To do this, all you gotta do is open your Xcode project, add a new depedency under File > Add Packages, search for this repo and install it. Then, it's all done!

Usage

To add an irregular gradient to your app all you gotta do is add import IrregularGradient to the file you're using and then use the irregularGradient(colors: [Color], background: () -> View, shouldAnimate: Binding<Bool> = .constant(true), speed: Double = 10) modifier.

  • The first, required, argument colors specifies the colors of each blob. Order and amount matters, so the colors will be stacked in the order of the array on the Z axis. Having two entries of the same color will create two completely distinct blobs of that color.
  • The background argument defines the background of your gradient. It's a closure that returns a view, but can also just be a simple color if you use backgroundColor instead. Not specifying this value it will make the background clear.
  • shouldAnimate is a boolean that specifies whether or not the gradient blobs should move. It can be enabled and disabled dinamically, and movement will always slow down to a stop. The default value is true.
  • The speed argument accepts a Double and defines the speed of the movement – a 0.5 speed means the blobs will update every 2 seconds. The default value is 1.
RoundedRectangle(cornerRadius: 30.0, style: .continuous)
    .irregularGradient(colors: [.orange, .pink, .yellow, .orange, .pink, .yellow], backgroundColor: .orange)

You can also use the IrregularGradient standalone view, which exists in its own container.

Implementation

The current implementation of this package is done through the creation of blobs (SwiftUI's Ellipse shape) of the specified colors that move and scale randomly in the container, and are then blurred to achieve the desired effect.

Questions

If you have any questions or suggestions, you can create an issue or pull request on this GitHub repository or even contact me via Twitter or email.

More Repositories

1

Glur

A library for progressive blurs in SwiftUI.
Swift
1,325
star
2

SlideOverCard

A SwiftUI card view, made great for setup interactions.
Swift
1,067
star
3

ExitButton

A native, colored and all-SwiftUI exit button icon.
Swift
45
star
4

Corona-Widget

A simple iOS and macOS widget for checking data about COVID-19.
Swift
25
star
5

Storees

Because everything has stories these days.
Swift
24
star
6

WWDC-2020

My submission for the WWDC20 Swift Student Challenge. (Accepted)
Swift
8
star
7

WWDC-2021

My submission for the WWDC21 Swift Student Challenge. (Accepted)
Swift
7
star
8

MQTT-Climate-Sync

A Home Assistant component for syncing MQTT IR transmitters/receivers with climate entities.
Python
7
star
9

WWDC21-Community-Hackathon

The 2 and ½ team's project for the WWDC Community Hackathon.
Swift
6
star
10

Processing-Sketchbook

Some of the sketches I made in the Processing IDE.
Processing
6
star
11

PeelKit

A manual implementation of a peel effect in SwiftUI using trigonometry.
Swift
6
star
12

joogps.com

My personal website and blog.
TypeScript
3
star
13

Vincent-Van-Proc

Trying to create an animated version of The Starry Night using Processing.
Processing
2
star
14

Wii-Menu

The Wii Menu, but in SwiftUI.
Swift
2
star
15

Under-Construction-Website

My website when it was... under construction.
CSS
1
star
16

StaticNoise

Quick static noise experimentations in SwiftUI with Canvas and TimelineView
Swift
1
star
17

Time-Tracker

A simple stopwatch and timer iOS app.
Swift
1
star
18

Metal-Experiments

A collection of my experiments with Metal.
Swift
1
star
19

Sphere

Little experiment with SwiftUI and Canvas
Swift
1
star
20

Basic-Text-Widget

A basic text widget with irregular gradients.
Swift
1
star
21

WWDC22-Community-Hackathon

Play hide and seek worldwide.
Swift
1
star
22

Metaballs

Recreating the Dynamic Island metaballs using Canvas in SwiftUI
Swift
1
star
23

SmartEdit

A proof-of concept of a smarted message editing system in SwiftUI.
Swift
1
star
24

muv

Repositório do nosso projeto de Programação III no semestre 2022.2
Java
1
star