• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

A Swift playground that generates beautiful Julia set fractal images.

English | 中文

Julia Set Playground

This is an Xcode Playground that generates fractal images of the Julia set.

The Julia set is a classic concept in fractal theory that generates stunning fractal images by means of an extremely simple formula.

z(n+1) = z(n)^2 + c
# where 'z' is a complex number 

You can use Xcode 13 to open JuliaSet.playground, and view the rendered image results on the right side of the window. The Playground contains all the source code inside.

Also, you may know of other kinds of fractals besides the Julia set, such as the Mandelbrot set. With a simple modification of the code, you can draw it. You can try it yourself.

About

I have a standalone app called "The Mysteries of Fractal". It generates dynamic fractal images in real time (based on Metal shader). The Mysteries of Fractal is a paid app for iOS / iPadOS / macOS. Welcome to experience it: App Store Link.

Sample Code

You can specify the formula parameters and observe how they affect the fractal image:

let imageSize = CGSize(width: 600, height: 440)
var julia = JuliaSet()

julia.window = 4.0
julia.const = Complex(-0.5, 0.0)
julia.color = JuliaSetColor(
    hue: 0,
    brightness: 0.87,
    saturation: 0.9
)

let outputImage = JuliaSetRenderer.syncRender(julia, pixelSize: imageSize)

You can also export a particular fractal from the Mysteries of Fractal app and draw it in Playground:

var code = "juliaset://?code=25477FFF7FFF7FEB5A4400FE"  // exported from app
let outputImage = JuliaSetRenderer.syncRender(JuliaSet.decodeURL(code)!, pixelSize: imageSize)

The render API supports asynchronous execution.

// render in background...
JuliaSetRenderer.asyncRender(julia, sizeInPixel: imageSize) { outputImage in
    // ...then get result in main thread
}

More Mathematics Playground Projects

Contact

Feel free to contact me if you need more information ;)

Email: [email protected]

More Repositories

1

you-dont-know-js-epub

"You Don't Know JS Yet" (2nd Edition) ePub generator.
Shell
190
star
2

procbridge

A super-lightweight IPC (Inter-Process Communication) protocol over TCP socket.
121
star
3

fft2d-swift-playground

A Swift playground for 2D Image FFT (Fast Fourier Transformation) implementation.
Swift
37
star
4

procbridge-python

A super-lightweight IPC (Inter-Process Communication) protocol over TCP socket.
Python
24
star
5

swift-complex-number

An elegant complex number library for Swift. (You can do "i ^ 2 == -1")
Swift
14
star
6

GZMatchedTransformEffect

Create a 🧈 smooth transition between any two SwiftUI Views.
Swift
14
star
7

HiCoffeeApp

13
star
8

swift-fourier-expansion

A Swift playground that demonstrates the Fourier series expansion.
Swift
11
star
9

procbridge-java

A super-lightweight IPC (Inter-Process Communication) protocol over TCP socket.
Java
8
star
10

swift-event-dispatch

An extremely convenience Swift class that used to implement callbacks, property observing, event publish-subscribe, and MVC/MVP/MVVM patterns. It's also a replacement for KVO.
Swift
5
star
11

procbridge-nodejs

A super-lightweight IPC (Inter-Process Communication) protocol over TCP socket.
JavaScript
3
star
12

service-kit

A group of utility classes for developing Java CLI tools and services.
Java
2
star
13

vue-cli-docker

Docker image for Vue CLI 3
Dockerfile
2
star
14

ifs-fractal-playground

A Swift playground that demonstrates Iterated function systems (IFS) fractals.
Swift
2
star
15

swiftui-availability-check-crash

FB9816443
Swift
2
star
16

awesome-icloud-503

Help 🍎 Apple track and resolve the issue about ☁️ iCloud 503 service unavailable error.
2
star
17

conways-game-of-life

Conway's Game of Life in Xcode Playground
Swift
2
star
18

jdat

Java Dependency Analysis Toolkit
Java
1
star
19

snowberry

Integration of design patterns Eclipse plug-in
Java
1
star
20

snell-docker

Docker image for surge-networks/snell proxy service.
Dockerfile
1
star
21

procbridge-swift

A modern Swift implementation of ProcBridge
Swift
1
star
22

reverse-proxy

Simple Nginx HTTP Reverse Proxy
Dockerfile
1
star
23

album-splitter

Split single audio file into separate tracks.
Shell
1
star