A Swift wrapper to Manim.
This package uses the engine of ManimCE and PythonKit for Python interoperation.
To use this package, please make sure you have ManimCE installed.
Examples of using Manim.
try await withManim { scene in
let dot1 = Dot(color: .blue)
let dot2 = Dot(color: .green)
scene.arrange(dot1, dot2, direction: .right)
let line = Line(from: dot1.center, to: dot2.center, color: .red)
line.moveTo(start: dot1.track(\.center), end: dot2.track(\.center))
scene.add(line, dot1, dot2)
let x = dot1.track(\.x)
let y = dot2.track(\.y)
withAnimation {
x += 4
}
withAnimation(in: .parallel) {
x.become(-4)
y += 2
}
} configuration: {
$0.quality = .high
}@ValueTracker var value = 0.0
let number = DecimalNumber($value, format: .precision(fractionLength: 4))
let dot = Dot()
let numberLine = NumberLine(range: Range(0...4))
scene.add(VStack(numberLine, number), dot)
dot.move(to: numberLine.convert(number: $value))
withAnimation {
$value.become(.pi)
}
scene.sleep()
withAnimation {
$value.become(0)
}See Gallery
Swift-Manim uses Swift Package Manager as its build tool. If you want to import in your own project, it's as simple as adding a dependencies clause to your Package.swift:
dependencies: [
.package(url: "https://github.com/Vaida12345/Swift-Manim.git", branch: "main")
]and then adding the appropriate module to your target dependencies.
.product(name: "Manim", package: "Swift-Manim"),You can add this framework as a dependency to your Xcode project by clicking File -> Swift Packages -> Add Package Dependency. The package is located at:
https://github.com/Vaida12345/Swift-Manim.git
Swift-Manim uses Python ManimCE as its engine, hence it is essential to setup Python and let Swift-Manim know where to look.
Please follow this guide to setup your environment.
This package uses DocC for documentation. Most shapes and methods come with sample code and example picture / video. View on Github Pages