Crates.io | nannou_webp_animation |
lib.rs | nannou_webp_animation |
version | |
source | src |
created_at | 2024-11-14 19:32:13.117458 |
updated_at | 2024-11-15 15:16:31.361602 |
description | A Rust library for decoding and rendering animated WebP images using the nannou creative coding framework. |
homepage | https://github.com/haradama/nannou_webp_animation |
repository | https://github.com/haradama/nannou_webp_animation |
max_upload_size | |
id | 1448242 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A Rust library for decoding and rendering animated WebP images using the nannou creative coding framework.
nannou_webp_animation
allows you to load, decode, and display animated WebP images within your nannou applications. It handles frame decoding, animation playback, and integrates seamlessly with nannou's rendering capabilities.
App
and Draw
APIs.Install libwebp
and pkg-config
using Homebrew:
brew install webp pkg-config
Install the required packages:
sudo apt-get update
sudo apt-get install libwebp-dev pkg-config
Install the dependencies:
sudo dnf install libwebp-devel pkgconf-pkg-config
Install the necessary packages:
sudo pacman -S libwebp pkgconf
Add the following to your Cargo.toml
:
[dependencies]
nannou = "0.19.0" # Or the latest version
libc = "0.2.162"
Clone this repository and include it as a local dependency if needed.
Here's a basic example of how to use nannou_webp_animation
in your application:
use nannou::prelude::*;
use nannou_webp_animation::WebpAnimation;
struct Model {
animation: WebpAnimation,
}
fn model(app: &App) -> Model {
// Create a new window
app.new_window().view(view).build().unwrap();
// Load the WEBP animation
let assets = app.assets_path().expect("Failed to find assets directory");
// Place 'animation.webp' in the 'assets' directory
let webp_path = assets.join("animation.webp");
// Initialize the animation
let animation =
WebpAnimation::from_file(&webp_path, app).expect("Failed to load WEBP animation");
Model { animation }
}
fn update(_app: &App, model: &mut Model, _update: Update) {
// Update the animation
model.animation.update();
}
fn view(app: &App, model: &Model, frame: Frame) {
// Clear the frame
frame.clear(BLACK);
let win = app.window_rect();
// Define the rectangle where the animation will be drawn
let r = Rect::from_w_h(
model.animation.width() as f32,
model.animation.height() as f32,
)
.top_left_of(win);
let draw = app.draw();
draw.texture(model.animation.texture())
.xy(r.xy())
.wh(r.wh());
draw.to_frame(app, &frame).unwrap();
}
fn main() {
nannou::app(model).update(update).run();
}
Place your animated WebP file named animation.webp
inside an assets
directory at the root of your project.
This project is licensed under the MIT License. See the LICENSE file for details.