Prism

1.0.0

A lightweight 3D renderer for SwiftUI.
aheze/Prism

What's New

Initial Release

2022-09-27T05:48:32Z

Thanks for checking out Prism! For some more animations with Prism, check out Find v3 — DM me on Twitter for the invite link.

Find.mp4

Prism

A lightweight 3D renderer for SwiftUI.

  • Works with any SwiftUI View.
  • Fully interactive and animatable.
  • Powered by perspective transforms.
  • 100% SwiftUI. No SceneKit or other weird stuff.
  • Supports sizing, extrusion, levitation, and more.
Logo cube Square that animates into a cube, with border 3 green cubes that bounce on click Thin, levitating blue prism Prism with an image on each side

Installation

Requires iOS 13+. Prism can be installed through the Swift Package Manager.

https://github.com/aheze/Prism

Usage

Prism is designed to be easy to use. First, define a PrismConfiguration for customization. Then just add a PrismCanvas, which can contain as many PrismViews as you'd like.

struct ContentView: View {
    @State var configuration = PrismConfiguration(
        tilt: 0.5, /// A value from 0 to 1, representing the perspective.
        size: CGSize(width: 200, height: 200), /// How big the prism is.
        extrusion: 100, /// The z height.
        levitation: 20, /// How far the prism is from the ground.
        shadowColor: Color.black, /// A dynamic shadow that's rendered underneath the prism.
        shadowOpacity: 0.25 /// The strength of the shadow.
    )

    var body: some View {
        PrismCanvas(tilt: configuration.tilt) {
            PrismView(configuration: configuration) {
                Color.blue
            } left: {
                Color.red
            } right: {
                Color.green
            }
        }
    }
}

Result, a multicolored cube

Example

Includes various samples of the library. Download it here!

Screenshot of example app

Community

Author

Popovers is made by aheze.

Contributing

All contributions are welcome. Just fork the repo, then make a pull request.

Need Help?

Open an issue or join the Discord server. You can also ping me on Twitter. Or read the source code — there's lots of comments.

Apps Using Popovers

Find is an app that lets you find text in real life. Popovers is currently used for the search bar settings and the camera message view — download to check it out!

If you have an app that uses Popovers, just make a PR or message me.

License

MIT License

Copyright (c) 2022 A. Zheng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Mar 16 2024 09:44:11 GMT-0900 (Hawaii-Aleutian Daylight Time)