Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PbrMotion, motion traits, and new crate bevy_vello_graphics #44

Merged
merged 7 commits into from
May 15, 2024

Conversation

nixon-voxell
Copy link
Member

@nixon-voxell nixon-voxell commented May 12, 2024

Follow up on #39

Changelog

TL;DR

  • Add PbrMotion & BuildPbrMotionExt
  • Replace build_vector! macro with BuildVectorMotionExt
  • Add motion traits
  • Separate shapes into new crate bevy_vello_graphics

PbrMotion & BuildPbrMotionExt

let mut pbr_motion = commands.build_pbr(transform, mesh_handle.clone(), material.clone());
let action = act!(
    (pbr_motion.id, Transform),
    start = { pbr_motion.transform }.scale,
    end = Vec3::splat(0.9),
);

Replace build_vector! macro with BuildVectorMotionExt

let mut line = commands.build_svector(
    Transform::default(),
    VelloLine::new(DVec2::new(-100.0, 0.0), DVec2::new(100.0, 0.0)),
    Stroke::default().with_brush(Brush::from_color(palette.get(ColorKey::Base8))),
);

let mut rect = commands.build_fsvector(
    Transform::default(),
    VelloRect::new(100.0, 100.0),
    Fill::new().with_color(palette.get(ColorKey::Blue)),
    Stroke::new(4.0).with_color(palette.get(ColorKey::Blue) * 1.5),
);

Motion traits

3 new motion traits are introduced:

  • TransformMotion with attribute - transform
  • FillMotion with attribute - fill
  • StrokeMotion with attribute - stroke

The attributes are used to indicate the identifier of the animated field (e.g. transform: Transform for TransformMotion).

Each of these traits must also implements the GetId trait.

Example:

#[derive(FillMotion, StrokeMotion, TransformMotion, GetId, Clone)]
pub struct FSVectorMotion<T> {
    #[id]
    pub id: Entity,
    #[transform]
    pub transform: Transform,
    pub vector: T,
    #[fill]
    pub fill: Fill,
    #[stroke]
    pub stroke: Stroke,
}

These motion traits provides default implementations of action creator functions that can be called without using the act! macro:

let mut line = commands.build_svector(
    Transform::default(),
    VelloLine::new(DVec2::new(-100.0, 0.0), DVec2::new(100.0, 0.0)),
    Stroke::default().with_brush(Brush::from_color(palette.get(ColorKey::Base8))),
);

let sequence = play!(
    commands,
    line.to_width(10.0).animate(1.0),
    line.to_color(Color::BLUE).animate(1.0),
)
.all();

New bevy_vello_graphics crate!

Vector shapes are now separated into a new crate. You can now use them separately from MotionGfx (even if you only need them to be static)!

Shapes include:

  • Line
  • Circle
  • Rect
  • Bezier Path

And drawing related components:

  • Brush
  • Fill
  • Stroke

As well as their builder systems which rebuilds these shapes when they are being mutated (using Bevy's filter Changed<T>):

  • build_vector

@nixon-voxell nixon-voxell added enhancement New feature or request quality of life Quality of life improvement labels May 12, 2024
@nixon-voxell nixon-voxell added this to the 0.1.0 milestone May 12, 2024
@nixon-voxell nixon-voxell self-assigned this May 12, 2024
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with Build(Fill/Stroke/FillStroke)MotionExts Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with Build(Fill/Stroke/FillStroke)MotionExts May 12, 2024
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with Build(Fill/Stroke/FillStroke)MotionExts Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with Build(Fill/Stroke/FillStroke)MotionExt May 12, 2024
@nixon-voxell nixon-voxell marked this pull request as ready for review May 12, 2024 13:44
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with Build(Fill/Stroke/FillStroke)MotionExt Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt May 14, 2024
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt, add motion traits May 14, 2024
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt, add motion traits Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt, add motion traits, separate shapes into new crate bevy_vello_graphics May 15, 2024
@nixon-voxell nixon-voxell changed the title Add PbrMotion & BuildPbrMotionExt, replace build_vector! macro with BuildVectorMotionExt, add motion traits, separate shapes into new crate bevy_vello_graphics PbrMotion, motion traits, and new crate bevy_vello_graphics May 15, 2024
@nixon-voxell nixon-voxell merged commit 10a1502 into main May 15, 2024
7 checks passed
@nixon-voxell nixon-voxell deleted the feature/pbr-builder branch May 15, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request quality of life Quality of life improvement
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant