Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ struct ContentView: View {

![image](https://github.com/user-attachments/assets/4b51ca16-889b-4a0a-80e5-9256c51825b8)

The `OrbView` can be customized using `OrbConfiguration`:
The `OrbView` can be customized using `OrbConfiguration` and OrbView modifiers:


```swift
let configuration = OrbConfiguration(
backgroundColors: [.purple, .blue, .pink], // Custom gradient colors
glowColor: .white, // Glow effect color
particleColor: .white, // Particle effect color
coreGlowIntensity: 1.2, // Intensity of the core glow
showBackground: true, // Toggle background visibility
showWavyBlobs: true, // Toggle organic movement elements
showParticles: true, // Toggle particle effects
showGlowEffects: true, // Toggle glow effects
showShadow: true, // Toggle shadow effects
speed: 60 // Animation speed
coreGlowIntensity: 1.2, // Intensity of the core glow
speed: 60 // Animation speed
)

OrbView(configuration: configuration)
.enableBackground(true) // Shows/hides the gradient background
.enableWavyBlobs(true) // Shows/hides organic movement elements
.enableParticles(true) // Shows/hides particle effects
.enableGlowEffects(true) // Shows/hides glow effects
.enableShadow(true) // Shows/hides shadow effects
.frame(width: 200, height: 200)
```

Expand All @@ -88,11 +88,6 @@ OrbView(configuration: configuration)
| `glowColor` | `Color` | `.white` | Color of the glow effects |
| `particleColor` | `Color` | `.white` | Color of the particle effects |
| `coreGlowIntensity` | `Double` | `1.0` | Intensity of the core glow effect (higher = brighter) |
| `showBackground` | `Bool` | `true` | Shows/hides the gradient background |
| `showWavyBlobs` | `Bool` | `true` | Shows/hides organic movement elements |
| `showParticles` | `Bool` | `true` | Shows/hides particle effects |
| `showGlowEffects` | `Bool` | `true` | Shows/hides glow effects |
| `showShadow` | `Bool` | `true` | Shows/hides shadow effects |
| `speed` | `Double` | `60` | Animation speed (higher = faster) |

### Preset Configurations
Expand All @@ -107,36 +102,46 @@ let mysticOrb = OrbConfiguration(
coreGlowIntensity: 1.2
)

OrbView(configuration: mysticOrb)

// Nature
let natureOrb = OrbConfiguration(
backgroundColors: [.green, .mint, .teal],
glowColor: .green,
speed: 45
)

OrbView(configuration: natureOrb)

// Sunset
let sunsetOrb = OrbConfiguration(
backgroundColors: [.orange, .red, .pink],
glowColor: .orange,
coreGlowIntensity: 0.8
)

OrbView(configuration: sunsetOrb)

// Ocean
let oceanOrb = OrbConfiguration(
backgroundColors: [.blue, .cyan, .teal],
glowColor: .cyan,
speed: 75
)

OrbView(configuration: oceanOrb)

// Minimal
let minimalOrb = OrbConfiguration(
backgroundColors: [.gray, .white],
glowColor: .white,
showWavyBlobs: false,
showParticles: false,
speed: 30
)

OrbView(configuration: minimalOrb)
.enableWavyBlobs(false)
.enableParticles(false)

// Cosmic
let cosmicOrb = OrbConfiguration(
backgroundColors: [.purple, .pink, .blue],
Expand All @@ -145,6 +150,8 @@ let cosmicOrb = OrbConfiguration(
speed: 90
)

OrbView(configuration: cosmicOrb)

// Fire
let fireOrb = OrbConfiguration(
backgroundColors: [.red, .orange, .yellow],
Expand All @@ -153,22 +160,28 @@ let fireOrb = OrbConfiguration(
speed: 80
)

OrbView(configuration: fireOrb)

// Arctic
let arcticOrb = OrbConfiguration(
backgroundColors: [.cyan, .white, .blue],
glowColor: .white,
coreGlowIntensity: 0.75,
showParticles: true,
speed: 40
)

OrbView(configuration: arcticOrb)
.enableParticles(false)

// Shadow
let shadowOrb = OrbConfiguration(
backgroundColors: [.black, .gray],
glowColor: .gray,
coreGlowIntensity: 0.7,
showParticles: false
coreGlowIntensity: 0.7
)

OrbView(configuration: shadowOrb)
.enableParticles(false)
```

## Requirements
Expand Down
26 changes: 0 additions & 26 deletions Sources/Config/OrbConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public struct OrbConfiguration {
public let backgroundColors: [Color]
public let particleColor: Color

public let showBackground: Bool
public let showWavyBlobs: Bool
public let showParticles: Bool
public let showGlowEffects: Bool
public let showShadow: Bool

public let coreGlowIntensity: Double
public let speed: Double

Expand All @@ -26,21 +20,11 @@ public struct OrbConfiguration {
glowColor: Color,
particleColor: Color,
coreGlowIntensity: Double,
showBackground: Bool,
showWavyBlobs: Bool,
showParticles: Bool,
showGlowEffects: Bool,
showShadow: Bool,
speed: Double
) {
self.backgroundColors = backgroundColors
self.glowColor = glowColor
self.particleColor = particleColor
self.showBackground = showBackground
self.showWavyBlobs = showWavyBlobs
self.showParticles = showParticles
self.showGlowEffects = showGlowEffects
self.showShadow = showShadow
self.coreGlowIntensity = coreGlowIntensity
self.speed = speed
}
Expand All @@ -49,23 +33,13 @@ public struct OrbConfiguration {
backgroundColors: [Color] = [.green, .blue, .pink],
glowColor: Color = .white,
coreGlowIntensity: Double = 1.0,
showBackground: Bool = true,
showWavyBlobs: Bool = true,
showParticles: Bool = true,
showGlowEffects: Bool = true,
showShadow: Bool = true,
speed: Double = 60
) {
self.init(
backgroundColors: backgroundColors,
glowColor: glowColor,
particleColor: .white,
coreGlowIntensity: coreGlowIntensity,
showBackground: showBackground,
showWavyBlobs: showWavyBlobs,
showParticles: showParticles,
showGlowEffects: showGlowEffects,
showShadow: showShadow,
speed: speed
)
}
Expand Down
48 changes: 48 additions & 0 deletions Sources/OrbView/Modifier/OrbView++.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// File.swift
// Orb
//
// Created by Yasir on 15/01/25.
//

import SwiftUI

/// Shows/hides the gradient background
public extension OrbView {
public func enableBackground(_ enable: Bool) -> Self {
self.showBackground = enable
return self
}
}

/// Shows/hides organic movement elements
public extension OrbView {
public func enableWavyBlobs(_ enable: Bool) -> Self {
self.showWavyBlobs = enable
return self
}
}

/// Shows/hides particle effects
public extension OrbView {
public func enableParticles(_ enable: Bool) -> Self {
self.showParticles = enable
return self
}
}

/// Shows/hides glow effects
public extension OrbView {
public func enableGlowEffects(_ enable: Bool) -> Self {
self.showGlowEffects = enable
return self
}
}

/// Shows/hides shadow effects
public extension OrbView {
public func enableShadow(_ enable: Bool) -> Self {
self.showShadow = enable
return self
}
}
18 changes: 12 additions & 6 deletions Sources/OrbView/OrbView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,39 @@ public struct OrbView: View {
public init(configuration: OrbConfiguration = OrbConfiguration()) {
self.config = configuration
}


@State package var showBackground: Bool = true
@State package var showWavyBlobs: Bool = true
@State package var showParticles: Bool = true
@State package var showGlowEffects: Bool = true
@State package var showShadow: Bool = true

public var body: some View {
GeometryReader { geometry in
let size = min(geometry.size.width, geometry.size.height)

ZStack {
// Base gradient background layer
if config.showBackground {
if showBackground {
background
}

// Creates depth with rotating glow effects
baseDepthGlows(size: size)

// Adds organic movement with flowing blob shapes
if config.showWavyBlobs {
if showWavyBlobs {
wavyBlob
wavyBlobTwo
}

// Adds bright, energetic core glow animations
if config.showGlowEffects {
if showGlowEffects {
coreGlowEffects(size: size)
}

// Overlays floating particle effects for additional dynamism
if config.showParticles {
if showParticles {
particleView
.frame(maxWidth: size, maxHeight: size)
}
Expand All @@ -55,7 +61,7 @@ public struct OrbView: View {
// Adding realistic, layered shadows so its brighter near the core, and softer as it grows outwards
.modifier(
RealisticShadowModifier(
colors: config.showShadow ? config.backgroundColors : [.clear],
colors: showShadow ? config.backgroundColors : [.clear],
radius: size * 0.08
)
)
Expand Down