Code Monkey home page Code Monkey logo

zoetrope's Introduction

Zoetrope

Create frame-based animations in SwiftUI, including support for animated images.

Overview

Zoetrope provides three native SwiftUI views:

  • FrameAnimator: a versatile wrapper around TimelineView for creating frame-based animations
  • AnimatedImageView: for playing back animated UIImage or NSImage instances
  • AsyncAnimatedImage: loads and plays images from URLs, similar to SwiftUI's AsyncImage.

All three views allow you to specify a start date to animate relative to. This allows you to synchronize playback across multiple views, or even multiple devices as long as their clocks are in sync.

Tip

For example, social apps that support looping GIF avatars (like Mastodon/Fediverse clients) could use a profile's creation date as the animation start date. If two people in the same room were looking at the same profile or post, they'd see the avatars playing in sync between their devices. 🪄 Magic!

Image format support

On UIKit platforms (iOS, iPadOS, visionOS, tvOS, watchOS, Mac Catalyst), Zoetrope supports animated GIF, WebP, HEIC, or APNG files, all using native UIImage.

Note

Support is provided using a special UIImage initializer that uses the native ImageIO framework to read those formats, storing any extra metadata (such as loop count and variable frame rate, if applicable) as Associated Objects on the UIImage instance itself. Zoetrope's image view can also play animated UIImage instances created using UIKit's built-in UIImage.animatedImage methods.

On AppKit platforms (native macOS), Zoetrope relies on NSImage's built-in support for animated GIF files.

Examples

Sources/Views/FrameAnimator.swift and Sources/Views/AsyncAnimatedImage.swift include Xcode previews with examples.

zoetrope's People

Contributors

daprice avatar

Stargazers

 avatar  avatar  avatar 愚非愚余 avatar David Bureš avatar palaniraja avatar beforeold avatar 东坡肘子 avatar Kern Jackson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.