use bevy::camera::visibility::RenderLayers;
use bevy::prelude::*;
use bevy_smud::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, SmudPlugin))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, mut shaders: ResMut<Assets<Shader>>) {
let circle = shaders.add_sdf_expr("smud::sd_circle(p, 70.)");
commands.spawn((
Camera2d,
Camera {
order: 0,
viewport: Some(bevy::camera::Viewport {
physical_position: UVec2::ZERO,
physical_size: UVec2::new(512, 720),
..default()
}),
..default()
},
Name::new("camera_a"),
));
commands.spawn((
Camera2d,
Camera {
order: 1,
viewport: Some(bevy::camera::Viewport {
physical_position: UVec2::new(512, 0),
physical_size: UVec2::new(512, 720),
..default()
}),
..default()
},
RenderLayers::layer(1),
Name::new("camera_b"),
));
commands.spawn((
SmudShape {
color: Color::srgb(1.0, 0.2, 0.2),
sdf: circle.clone(),
bounds: Rectangle::from_length(160.),
..default()
},
Transform::from_xyz(-80., 0., 0.),
));
commands.spawn((
SmudShape {
color: Color::srgb(0.2, 0.2, 1.0),
sdf: circle,
bounds: Rectangle::from_length(160.),
..default()
},
Transform::from_xyz(80., 0., 0.),
RenderLayers::layer(1),
));
}