Skip to content

Commit

Permalink
build: prep for release
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Feb 1, 2024
1 parent ea6073d commit 55cd8db
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 124 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

### added

- State machines are now available behind the `animation-controller` cargo feature
- State machines are now available behind the `player` cargo feature
- `PlaybackSettings` can now be bundled with `VelloAssetBundle` to augment playback

### changed

- `RenderMode` changed to `CoordinateSpace`
- `Vector` has been renamed to `VelloAssetData`
- `VelloVector`, anywhere mentioned, has changed to `VelloAsset`
- `DebugVisualizations` are now feature-gated behind the `debug` cargo feature
- Color swapping now swaps by layer name only and applies to more cases (animated, gradients, etc.)
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ repository.workspace = true
[lib]

[features]
default = ["animation-controller", "debug"]
default = ["debug"]
debug = ["bevy/bevy_gizmos"]
animation-controller = []

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Expand Down
45 changes: 6 additions & 39 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use bevy::{asset::AssetMetaCheck, log::LogPlugin, prelude::*};
use bevy_egui::{
egui::{self, Color32},
egui::{self},
EguiContexts, EguiPlugin,
};
use bevy_vello::{
debug::DebugVisualizations, vello_svg::usvg::strict_num::Ulps, AnimationDirection,
AnimationLoopBehavior, AnimationPlayMode, AnimationState, AnimationTransition,
ColorPaletteSwap, LottiePlayer, PlaybackSettings, Vector, VelloAsset, VelloAssetBundle,
VelloPlugin, VelloText, VelloTextBundle,
AnimationLoopBehavior, AnimationState, AnimationTransition, LottiePlayer, PlaybackSettings,
Theme, VelloAsset, VelloAssetBundle, VelloAssetData, VelloPlugin, VelloText, VelloTextBundle,
};

fn main() {
Expand Down Expand Up @@ -44,7 +43,7 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
debug_visualizations: DebugVisualizations::Visible,
..default()
})
.insert(ColorPaletteSwap::default())
.insert(Theme::empty())
.insert(
LottiePlayer::new("stopped")
.with_state({
Expand Down Expand Up @@ -116,7 +115,7 @@ fn ui(
mut player: Query<(
&mut LottiePlayer,
&PlaybackSettings,
&mut ColorPaletteSwap,
&mut Theme,
&Handle<VelloAsset>,
)>,
assets: Res<Assets<VelloAsset>>,
Expand All @@ -128,7 +127,7 @@ fn ui(

let asset = assets.get(handle.id()).unwrap();
let metadata = asset.metadata().unwrap();
let Vector::Lottie {
let VelloAssetData::Lottie {
composition,
first_frame: _,
rendered_frames: _,
Expand Down Expand Up @@ -209,22 +208,6 @@ fn ui(
player.set_intermission(intermission);
};
});
ui.horizontal(|ui| {
ui.colored_label(Color32::YELLOW, "Set Direction");
let direction = playback_settings.direction;
if ui
.radio(direction == AnimationDirection::Normal, "Normal")
.clicked()
{
player.set_direction(AnimationDirection::Normal);
}
if ui
.radio(direction == AnimationDirection::Reverse, "Reverse")
.clicked()
{
player.set_direction(AnimationDirection::Reverse);
}
});
ui.horizontal(|ui| {
ui.label("Set Loop Behavior");
let looping = playback_settings.looping;
Expand All @@ -241,22 +224,6 @@ fn ui(
player.set_loop_behavior(AnimationLoopBehavior::Loop);
}
});
ui.horizontal(|ui| {
ui.colored_label(Color32::RED, "Set Play Mode");
let playmode = playback_settings.play_mode;
if ui
.radio(playmode == AnimationPlayMode::Normal, "Normal")
.clicked()
{
player.set_play_mode(AnimationPlayMode::Normal);
}
if ui
.radio(playmode == AnimationPlayMode::Bounce, "Bounce")
.clicked()
{
player.set_play_mode(AnimationPlayMode::Bounce);
}
});

ui.separator();

Expand Down
2 changes: 1 addition & 1 deletion src/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod parser;
pub(crate) mod vector;

pub use asset_loader::VelloAssetLoader;
pub use vector::Vector;
pub use vector::VelloAsset;
pub use vector::VelloAssetData;

pub(crate) use asset_loader::VectorLoaderError;
pub use parser::*;
6 changes: 3 additions & 3 deletions src/assets/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::asset_loader::VectorLoaderError;
use crate::{assets::vector::Vector, VelloAsset};
use crate::{assets::vector::VelloAssetData, VelloAsset};
use bevy::prelude::*;
use std::sync::Arc;
use vello::{SceneBuilder, SceneFragment};
Expand All @@ -20,7 +20,7 @@ pub fn load_svg_from_bytes(bytes: &[u8]) -> Result<VelloAsset, VectorLoaderError
let height = usvg.size.height();

let vello_vector = VelloAsset {
data: Vector::Svg {
data: VelloAssetData::Svg {
original: Arc::new(scene_frag),
first_frame: None,
},
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn load_lottie_from_bytes(bytes: &[u8]) -> Result<VelloAsset, VectorLoaderEr
let height = composition.height as f32;

let vello_vector = VelloAsset {
data: Vector::Lottie {
data: VelloAssetData::Lottie {
composition: Arc::new(composition),
rendered_frames: 0.0,
first_frame: None,
Expand Down
9 changes: 5 additions & 4 deletions src/assets/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vello::SceneFragment;
use vello_svg::usvg::strict_num::Ulps;

#[derive(Clone)]
pub enum Vector {
pub enum VelloAssetData {
Svg {
/// The original image encoding
original: Arc<SceneFragment>,
Expand All @@ -29,7 +29,7 @@ pub enum Vector {

#[derive(Asset, TypePath, Clone)]
pub struct VelloAsset {
pub data: Vector,
pub data: VelloAssetData,
pub local_transform_bottom_center: Transform,
pub local_transform_center: Transform,
pub width: f32,
Expand Down Expand Up @@ -77,6 +77,7 @@ impl VelloAsset {
[min, x_axis, max, y_axis]
}

/// Returns the 4 corner points of this vector's bounding box in screen space
pub fn bb_in_screen_space(&self, transform: &GlobalTransform) -> [Vec2; 4] {
let min = Vec3A::ZERO;
let x_axis = Vec3A::new(self.width, 0.0, 0.0);
Expand All @@ -98,7 +99,7 @@ impl VelloAsset {
/// Gets the lottie metadata (if vector is a lottie), an object used for inspecting
/// this vector's layers and shapes
pub fn metadata(&self) -> Option<Metadata> {
if let Vector::Lottie { composition, .. } = &self.data {
if let VelloAssetData::Lottie { composition, .. } = &self.data {
Some(Metadata {
composition: composition.clone(),
})
Expand All @@ -109,7 +110,7 @@ impl VelloAsset {

/// Calculate the playhead. Returns `None` is the Vector is an SVG.
pub fn calculate_playhead(&self, playback_settings: &PlaybackSettings) -> Option<f32> {
let Vector::Lottie {
let VelloAssetData::Lottie {
composition,
first_frame: _,
rendered_frames,
Expand Down
14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// #![deny(missing_docs)] - TODO add before 1.0
//! An integration to render SVG and Lottie assets in Bevy with Vello.

#[cfg(feature = "animation-controller")]
mod animation_controller;
mod assets;
mod color_swapping;
mod font;
mod lottie_player;
mod metadata;
mod playback_settings;
mod plugin;
mod renderer;
mod rendertarget;
mod theme;

use bevy::prelude::*;
use font::VelloFont;
Expand All @@ -23,20 +22,19 @@ pub use vellottie;
#[cfg(feature = "debug")]
pub mod debug;

#[cfg(feature = "animation-controller")]
pub use animation_controller::{AnimationState, AnimationTransition, LottiePlayer};
pub use assets::VelloAssetLoader;
pub use assets::{
load_lottie_from_bytes, load_lottie_from_str, load_svg_from_bytes, load_svg_from_str, Vector,
VelloAsset,
load_lottie_from_bytes, load_lottie_from_str, load_svg_from_bytes, load_svg_from_str,
VelloAsset, VelloAssetData,
};
pub use color_swapping::ColorPaletteSwap;
pub use font::VelloFontLoader;
pub use lottie_player::{AnimationState, AnimationTransition, LottiePlayer};
pub use playback_settings::{
AnimationDirection, AnimationLoopBehavior, AnimationPlayMode, PlaybackSettings,
};
pub use plugin::VelloPlugin;
pub use rendertarget::VelloCanvasMaterial;
pub use theme::Theme;

#[derive(PartialEq, Eq, PartialOrd, Ord, Component, Default, Copy, Clone, Debug, Reflect)]
#[reflect(Component)]
Expand Down
Loading

0 comments on commit 55cd8db

Please sign in to comment.