Swiftpack.co - yukiny0811/swifty-creatives as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by yukiny0811.
yukiny0811/swifty-creatives v1.12.0
Creative coding framework for Swift. Built on Apple's Metal. Inspired by Processing.
⭐️ 46
🕓 3 weeks ago
iOS macOS
.package(url: "https://github.com/yukiny0811/swifty-creatives.git", from: "v1.12.0")

SwiftyCreatives

Release Swift Compatibility Platform Compatibility License

Creative coding framework for Swift.
Using Metal directly for rendering.

ExampleMacOSApp 2022年-12月-16日 18 08 41

Features

Geometry Other Features
Rectangle (with hit test) Perspective Camera
Circle Orthographic Camera
Triangle BlendMode(normal, add, alphaBlend)
Line Lighting
Box (with hit test) push/pop matrix
3D Model can be used as UIView / NSView
Image (with hit test) can be used as SwiftUI View
Text Post Processing
UIViewObject (3d view with interactive button) User-defined shaders

ExampleMacOSApp 2023年-02月-24日 17 11 06

CheckMacOS 2023年-03月-01日 6 46 57

QuickTime Player - 画面収録 2023-02-10 1 53 14 mov 2023年-02月-10日 2 55 14

Sample Code

Main sketch process

import SwiftyCreatives

final class SampleSketch: Sketch {
    override func draw(encoder: SCEncoder) {
        let count = 20
        for i in 0...count {
            color(1, Float(i) / 20, 0, 1)
            pushMatrix()
            rotateY(Float.pi * 2 / Float(count) * Float(i))
            translate(10, 0, 0)
            box(1, 1, 1)
            popMatrix()
        }
    }
}

You can use SketchView as SwiftUI View

ZStack {
    SketchView(SampleSketch())
}
.background(.black)
スクリーンショット 2023-02-03 7 51 34

Other Examples

GitHub

link
Stars: 46
Last commit: 5 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v1.12.0
3 weeks ago

New Feature

  • SCAnimationType (ease-out and linear)

Fix

  • Transparent Shader
  • add img() function to Sketch

Removed Feature

  • removed setColor() from all geometries

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics