All Projects → rnkyr → Metaballs

rnkyr / Metaballs

Licence: mit
Blob effect implementation with UIKIt

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Metaballs

react-hooks-uikit-express-oauth-boiler-v2
A React/TypeScript fullstack boilerplate utilizing React hooks, using Express as backend, UIKit for frontend, MongoDB for storage & open-authenticator for OAuth.
Stars: ✭ 110 (-63.33%)
Mutual labels:  uikit
Chakra Ui
⚡️ Simple, Modular & Accessible UI Components for your React Applications
Stars: ✭ 22,745 (+7481.67%)
Mutual labels:  uikit
Uikitplus
🏰 Declarative UIKit with LivePreview for iOS9+ (best alternative to SwiftUI)
Stars: ✭ 294 (-2%)
Mutual labels:  uikit
mantine
React components library with native dark theme support
Stars: ✭ 4,390 (+1363.33%)
Mutual labels:  uikit
Verge
🟣 Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.
Stars: ✭ 273 (-9%)
Mutual labels:  uikit
Nbaseuikit
个人平时使用的一些Qt编写的组件(有部分是整合的开源作品,部分是自己原创);
Stars: ✭ 286 (-4.67%)
Mutual labels:  uikit
laravel-starter-kit
A minimal starter kit for Laravel 8 using Bootstrap 5 and Webpixels CSS.
Stars: ✭ 23 (-92.33%)
Mutual labels:  uikit
Mbtileparser
MBTileParser is a game engine written using pure UIKit in the days before SpriteKit.
Stars: ✭ 297 (-1%)
Mutual labels:  uikit
Passwordrules
A Swift library for defining strong password generation rules
Stars: ✭ 281 (-6.33%)
Mutual labels:  uikit
Wtrequestcenter
WTKit is my Code accumulation
Stars: ✭ 293 (-2.33%)
Mutual labels:  uikit
Kotlinwanandroid
Kotlin+模块化+响应式+MVVM 实现的风格简约、代码优雅的WanAndroid客户端
Stars: ✭ 265 (-11.67%)
Mutual labels:  uikit
Ezswiftextensions
😏 How Swift standard types and classes were supposed to work.
Stars: ✭ 2,911 (+870.33%)
Mutual labels:  uikit
Framework Codeidea
System file classification
Stars: ✭ 289 (-3.67%)
Mutual labels:  uikit
python-paginate
Pagination support for python web frameworks (study from will_paginate).
Stars: ✭ 17 (-94.33%)
Mutual labels:  uikit
Deskapp
DeskApp Admin is a free to use Bootstrap 4 admin template.
Stars: ✭ 296 (-1.33%)
Mutual labels:  uikit
SafeAreaExample
The example project which allows you to play with safe areas introduced in iOS 11
Stars: ✭ 64 (-78.67%)
Mutual labels:  uikit
Material Bread
Cross Platform React Native Material Design Components
Stars: ✭ 287 (-4.33%)
Mutual labels:  uikit
Chakra Ui
⚡️Simple, Modular & Accessible UI Components for your React Applications
Stars: ✭ 295 (-1.67%)
Mutual labels:  uikit
Swiftui Cheat Sheet
SwiftUI 2.0 Cheat Sheet
Stars: ✭ 3,417 (+1039%)
Mutual labels:  uikit
Contraflutterkit
A Flutter UI kit with 50 plus screens for beginners to learn.
Stars: ✭ 288 (-4%)
Mutual labels:  uikit

Blob effect in iOS

Swift 5.0 iOS 9+ swiftlint

The project demonstrates implementation of a 2D blob effect (or metaballs) written using UIKit. Project contains example setup and separated MetaballsView with the implementation of an effect.

Overview

Mostly inspired by these two articles I implemented the effect utilizing Bezier curves with the help of UIKit. During the R&D process, I tried a couple of approaches (like building pixel-by-pixel, marching squares and some more), but due to the nature of the rendering process on a mobile platform selected one is the most efficient. Each time a user move a ball (changes its position), the host view recalculates curves for each pair of balls.

Implementation details

There's a host view class MetaballsView which is responsible for building, configuring and interaction.

It holds a list of interactable UIViews (yep, it holds it twice due to the hierarchy, but in that case, it doesn't create any retain issues).

blobLayers is a two-dimensional array of CAShapeLayers that used to display blob connection between balls. To be able to directly access layer between i-th and j-th balls, the array is made two-dimensional so it could be accessed like blobLayers[i][j]. Due to mirroring, blobLayers[j][i] should be drawn the same as blobLayers[i][j], but I haven't optimized it yet, just ignoring the path.

The Blob entity calculates and holds information regarding tangent points and handle curves points.

The Metaball entity holds actual ball information and utilizes Blob to build a path with another Metaball and translate it into UIBezierPath. Basically, these two classes could be used to implement the same effect independently from UIKit.

The following image demonstrates the principle behind math.

There're two bezier curves: from point p1 to p3 with control points in h1 and h3, and inversed one from points p2 to p4 through h2, h4. Refer to debugging branch to view details.

For pixel-by-pixel implementation refer to this branch.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].