{"id":18031736,"url":"https://github.com/dagronf/dsfimageflipbook","last_synced_at":"2025-03-27T05:30:54.427Z","repository":{"id":63907289,"uuid":"352208822","full_name":"dagronf/DSFImageFlipbook","owner":"dagronf","description":"A simple 'flipbook' of images that can be presented as flipbook-style animation","archived":false,"fork":false,"pushed_at":"2021-07-16T02:37:35.000Z","size":11,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T04:31:36.890Z","etag":null,"topics":["combine-framework","flipbook","ios","macos","tvos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dagronf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-28T00:33:13.000Z","updated_at":"2024-06-27T18:00:10.000Z","dependencies_parsed_at":"2022-11-28T22:54:33.407Z","dependency_job_id":null,"html_url":"https://github.com/dagronf/DSFImageFlipbook","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFImageFlipbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFImageFlipbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFImageFlipbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFImageFlipbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/DSFImageFlipbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791332,"owners_count":20672665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combine-framework","flipbook","ios","macos","tvos"],"created_at":"2024-10-30T10:10:36.352Z","updated_at":"2025-03-27T05:30:54.042Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSFImageFlipbook\n\nA simple 'flipbook' of images that can be presented as flipbook-style animation.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/dagronf/DSFImageFlipbook\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.0-orange.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-lightgrey\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n\u003cbr/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macOS-10.12+-blue\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/iOS-13+-orange\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tvOS-13+-green\" /\u003e\n\u003c/p\u003e\n\nDSFImageFlipbook presents each image in the flipbook to the owner of the flipbook (using a block callback or combine publisher) for the duration of the image frame.\n\nSupports :-\n\n* loading images from a gif, a movie or manually frame-by-frame.\n* repeat count\n* speed\n* scrubbing\n* cancellation\n\n## Why?\n\nI wanted to put an animated gif in a dock tile. Due to the nature of `NSDockTile` you cannot just play an `NSImageView` as the `contentView` of the tile - the only time a dock tile updates is when you tell it to (via `display()`)\n\nSo I needed a class that could present me individual images at a defined time so that I could manually update the dock image.\n\n## Examples\n\n### Using a callback block\n\n```swift\nlet flipbook = DSFImageFlipbook()\n\n...\n\n// Add frames manually\nflipbook.addFrame(image: image1, duration: 0.5)   // first frame for 0.5 seconds\nflipbook.addFrame(image: image2, duration: 0.5)   // second frame for 0.5 seconds\nflipbook.addFrame(image: image3, duration: 0.5)   // third frame for 0.5 seconds\nflipbook.addFrame(image: image4, duration: 2.0)   // last frame for 2.0 seconds\n\n// And start the animation\nflipbook.start() { [weak self] (frame, current, count, stop) in\n   // Do something with the provided frame\n}\n```\n\n### Using Combine (macOS 10.15+, iOS 13+, tvOS 13+)\n\n```swift\nlet flipbook = DSFImageFlipbook()\n\n// Load the frames from a gif\nlet gif = Bundle.main.image(forResource: NSImage.Name(\"animation.gif\"))!\n_ = flipbook.loadFrames(from: gif)\n\n...\n\n// Use a combine sink to listen to frame changes in localFlipbook\ncancellable = flipbook.publisher\n   .map { return $0.image }\n   .sink(receiveValue: { [weak self] image in\n       ... do something with 'image'\n\t})\n\n// Start the animation at 2x the speed defined in the flipbook. Repeat 10 times.\nflipbook.start(speed: 2, repeatCount: 10)\n```\n\n## License\n\nMIT. Use it and abuse it for anything you want, just attribute my work. Let me know if you do use it somewhere, I'd love to hear about it!\n\n```\nMIT License\n\nCopyright (c) 2021 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfimageflipbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fdsfimageflipbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfimageflipbook/lists"}