Skip to content

Instantly share code, notes, and snippets.

@mortenjust
Created January 31, 2023 20:54
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mortenjust/d6115ab68acdb0ddd998edb356cff40d to your computer and use it in GitHub Desktop.
Save mortenjust/d6115ab68acdb0ddd998edb356cff40d to your computer and use it in GitHub Desktop.
//
// Blobs.swift
// SwiftUI Demos
//
// Created by Morten Just on 1/31/23.
//
import SwiftUI
struct Blobs: View {
@State var white : CGFloat = 0.5
@State var blur : CGFloat = 0.5
var body: some View {
GeometryReader { reader in
VStack {
HStack {
Slider(value: $white)
Slider(value: $blur)
}
ZStack {
let over = Color(white: white)
ZStack {
Movable(location: CGPoint(x: 200, y: 100))
.frame(width: reader.size.width * 0.4)
Movable(location: CGPoint(x: 300, y: 100))
.frame(width: reader.size.width * 0.3)
}.blur(radius: blur * 100)
Rectangle()
.fill(over)
.blendMode(.colorDodge)
.allowsHitTesting(false)
Rectangle()
.fill(over)
.blendMode(.colorBurn)
.allowsHitTesting(false)
.blendMode(.plusLighter)
}.ignoresSafeArea()
}
}
}
}
/// A movable circle
struct Movable : View {
@State var location : CGPoint
var body: some View {
/// Play with the fill style for wildly different results
Circle()
// .fill(RadialGradient(colors: [.white, .blue], center: .center, startRadius: 0, endRadius: 100))
.fill(LinearGradient(colors: [.mint, .blue], startPoint: .top, endPoint: .bottom))
.position(location)
.gesture(
DragGesture()
.onChanged({ value in
location = value.location
})
)
}
}
struct Blobs_Previews: PreviewProvider {
static var previews: some View {
Blobs()
}
}
@Treata11
Copy link

Treata11 commented Feb 1, 2023

Beautiful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment