repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ghost_nodes.rs | examples/ui/ghost_nodes.rs | //! This example demonstrates the use of Ghost Nodes.
//!
//! UI layout will ignore ghost nodes, and treat their children as if they were direct descendants of the first non-ghost ancestor.
//!
//! # Warning
//!
//! This is an experimental feature, and should be used with caution,
//! especially in concert with 3rd par... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/borders.rs | examples/ui/borders.rs | //! Example demonstrating bordered UI nodes
use bevy::{color::palettes::css::*, ecs::spawn::SpawnIter, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);
// labels fo... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/strikethrough_and_underline.rs | examples/ui/strikethrough_and_underline.rs | //! This example illustrates UI text with strikethrough and underline decorations
use bevy::{
color::palettes::css::{GREEN, NAVY, RED, YELLOW},
prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/text_wrap_debug.rs | examples/ui/text_wrap_debug.rs | //! This example demonstrates text wrapping and use of the `LineBreakOn` property.
use argh::FromArgs;
use bevy::{prelude::*, text::LineBreak, window::WindowResolution};
#[derive(FromArgs, Resource)]
/// `text_wrap_debug` demonstrates text wrapping and use of the `LineBreakOn` property
struct Args {
#[argh(option... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/size_constraints.rs | examples/ui/size_constraints.rs | //! Demonstrates how the to use the size constraints to control the size of a UI node.
use bevy::{color::palettes::css::*, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_message::<ButtonActivated>()
.add_systems(Startup, setup)
.add_systems(Update, (update_bu... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ui_material.rs | examples/ui/ui_material.rs | //! Demonstrates the use of [`UiMaterials`](UiMaterial) and how to change material values
use bevy::{
color::palettes::css::DARK_BLUE, prelude::*, reflect::TypePath, render::render_resource::*,
shader::ShaderRef,
};
/// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PAT... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/text_debug.rs | examples/ui/text_debug.rs | //! Shows various text layout options.
use std::{collections::VecDeque, time::Duration};
use bevy::{
color::palettes::css::*,
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
prelude::*,
ui::widget::TextUiWriter,
window::PresentMode,
};
fn main() {
App::new()
.add_plugins((... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ui_scaling.rs | examples/ui/ui_scaling.rs | //! This example illustrates the [`UiScale`] resource from `bevy_ui`.
use bevy::{color::palettes::css::*, prelude::*};
use core::time::Duration;
const SCALE_TIME: u64 = 400;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(TargetScale {
start_scale: 1.0,
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/relative_cursor_position.rs | examples/ui/relative_cursor_position.rs | //! Showcases the [`RelativeCursorPosition`] component, used to check the position of the cursor relative to a UI node.
use bevy::{camera::Viewport, prelude::*, ui::RelativeCursorPosition};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ui_texture_slice.rs | examples/ui/ui_texture_slice.rs | //! This example illustrates how to create buttons with their textures sliced
//! and kept in proportion instead of being stretched by the button dimensions
use bevy::{
color::palettes::css::{GOLD, ORANGE},
prelude::*,
ui::widget::NodeImageMode,
};
fn main() {
App::new()
.add_plugins(DefaultPl... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/z_index.rs | examples/ui/z_index.rs | //! Demonstrates how to use the z-index component on UI nodes to control their relative depth
//!
//! It uses colored boxes with different z-index values to demonstrate how it can affect the order of
//! depth of nodes compared to their siblings, but also compared to the entire UI.
use bevy::{
color::palettes::bas... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/viewport_node.rs | examples/ui/viewport_node.rs | //! A simple scene to demonstrate spawning a viewport widget. The example will demonstrate how to
//! pick entities visible in the widget's view.
use bevy::{
asset::RenderAssetUsages,
camera::RenderTarget,
picking::pointer::PointerInteraction,
prelude::*,
render::render_resource::{TextureDimension,... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/standard_widgets_observers.rs | examples/ui/standard_widgets_observers.rs | //! This experimental example illustrates how to create widgets using the `bevy_ui_widgets` widget set.
//!
//! The patterns shown here are likely to change substantially as the `bevy_ui_widgets` crate
//! matures, so please exercise caution if you are using this as a reference for your own code,
//! and note that ther... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/feathers.rs | examples/ui/feathers.rs | //! This example shows off the various Bevy Feathers widgets.
use bevy::{
color::palettes,
feathers::{
controls::{
button, checkbox, color_plane, color_slider, color_swatch, radio, slider,
toggle_switch, ButtonProps, ButtonVariant, ColorChannel, ColorPlane, ColorPlaneValue,
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/standard_widgets.rs | examples/ui/standard_widgets.rs | //! This experimental example illustrates how to create widgets using the `bevy_ui_widgets` widget set.
//!
//! These widgets have no inherent styling, so this example also shows how to implement custom styles.
//!
//! The patterns shown here are likely to change substantially as the `bevy_ui_widgets` crate
//! matures... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/directional_navigation.rs | examples/ui/directional_navigation.rs | //! Demonstrates how to set up the directional navigation system to allow for navigation between widgets.
//!
//! Directional navigation is generally used to move between widgets in a user interface using arrow keys or gamepad input.
//! When compared to tab navigation, directional navigation is generally more direct, ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/tab_navigation.rs | examples/ui/tab_navigation.rs | //! This example illustrates the use of tab navigation.
use bevy::{
color::palettes::basic::*,
input_focus::{
tab_navigation::{TabGroup, TabIndex, TabNavigationPlugin},
InputDispatchPlugin, InputFocus,
},
prelude::*,
};
fn main() {
App::new()
.add_plugins((DefaultPlugins, I... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/display_and_visibility.rs | examples/ui/display_and_visibility.rs | //! Demonstrates how Display and Visibility work in the UI.
use bevy::{
color::palettes::css::{DARK_CYAN, DARK_GRAY, YELLOW},
ecs::{component::Mutable, hierarchy::ChildSpawnerCommands},
prelude::*,
};
const PALETTE: [&str; 4] = ["27496D", "466B7A", "669DB3", "ADCBE3"];
const HIDDEN_COLOR: Color = Color::s... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/transparency_ui.rs | examples/ui/transparency_ui.rs | //! Demonstrates how to use transparency with UI.
//! Shows two colored buttons with transparent text.
use bevy::prelude::*;
fn main() {
App::new()
.insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands:... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/font_weights.rs | examples/ui/font_weights.rs | //! This example demonstrates how to use font weights with text.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let font: FontSource = asset_server.load... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/overflow_debug.rs | examples/ui/overflow_debug.rs | //! Tests how different transforms behave when clipped with `Overflow::Hidden`
use bevy::{input::common_conditions::input_just_pressed, prelude::*, ui::widget::TextUiWriter};
use std::f32::consts::{FRAC_PI_2, PI, TAU};
const CONTAINER_SIZE: f32 = 150.0;
const LOOP_LENGTH: f32 = 4.0;
fn main() {
App::new()
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ui_drag_and_drop.rs | examples/ui/ui_drag_and_drop.rs | //! Demonstrates dragging and dropping UI nodes
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
const COLUMNS: i16 = 10;
const ROWS: i16 = 10;
const TILE_SIZE: f32 = 40.;
fn setup(mut commands: Commands) {
commands.spaw... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/gradients.rs | examples/ui/gradients.rs | //! Simple example demonstrating linear gradients.
use bevy::color::palettes::css::BLUE;
use bevy::color::palettes::css::GREEN;
use bevy::color::palettes::css::INDIGO;
use bevy::color::palettes::css::LIME;
use bevy::color::palettes::css::ORANGE;
use bevy::color::palettes::css::RED;
use bevy::color::palettes::css::VIOL... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ui/ui_texture_slice_flip_and_tile.rs | examples/ui/ui_texture_slice_flip_and_tile.rs | //! This example illustrates how to how to flip and tile images with 9-slicing in the UI.
use bevy::{
image::{ImageLoaderSettings, ImageSampler},
prelude::*,
ui::widget::NodeImageMode,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(UiScale(2.))
.add_sys... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/extra_source.rs | examples/asset/extra_source.rs | //! An example of registering an extra asset source, and loading assets from it.
//! This asset source exists in addition to the default asset source.
use bevy::{
asset::{
io::{AssetSourceBuilder, AssetSourceId},
AssetPath,
},
prelude::*,
};
use std::path::Path;
fn main() {
App::new()
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/web_asset.rs | examples/asset/web_asset.rs | //! Example usage of the `https` asset source to load assets from the web.
//!
//! Run with the feature `https`, and optionally `web_asset_cache`
//! for a simple caching mechanism that never invalidates.
//!
use bevy::{asset::io::web::WebAssetPlugin, prelude::*};
fn main() {
App::new()
.add_plugins(Defaul... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/multi_asset_sync.rs | examples/asset/multi_asset_sync.rs | //! This example illustrates how to wait for multiple assets to be loaded.
use std::{
f32::consts::PI,
ops::Drop,
sync::{
atomic::{AtomicBool, AtomicU32, Ordering},
Arc,
},
};
use bevy::{gltf::Gltf, prelude::*, tasks::AsyncComputeTaskPool};
use event_listener::Event;
use futures_lite::... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/repeated_texture.rs | examples/asset/repeated_texture.rs | //! By default Bevy loads images to textures that clamps the image to the edges
//! This example shows how to configure it to repeat the image instead.
use bevy::{
image::{ImageAddressMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor},
math::Affine2,
prelude::*,
};
fn main() {
App::new()... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/custom_asset.rs | examples/asset/custom_asset.rs | //! Implements loader for a custom asset type.
use bevy::{
asset::{io::Reader, AssetLoader, LoadContext},
prelude::*,
reflect::TypePath,
};
use serde::Deserialize;
use thiserror::Error;
#[derive(Asset, TypePath, Debug, Deserialize)]
struct CustomAsset {
#[expect(
dead_code,
reason = "U... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/embedded_asset.rs | examples/asset/embedded_asset.rs | //! Example of loading an embedded asset.
//! An embedded asset is an asset included in the program's memory, in contrast to other assets that are normally loaded from disk to memory when needed.
//! The below example embeds the asset at program startup, unlike the common use case of embedding an asset at build time. ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/asset_settings.rs | examples/asset/asset_settings.rs | //! This example demonstrates the usage of '.meta' files and [`AssetServer::load_with_settings`] to override the default settings for loading an asset
use bevy::{
image::{ImageLoaderSettings, ImageSampler},
prelude::*,
};
fn main() {
App::new()
.add_plugins(
// This just tells the asse... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/asset_loading.rs | examples/asset/asset_loading.rs | //! This example illustrates various ways to load assets.
use bevy::{asset::LoadedFolder, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
meshes: Res<Asset... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/custom_asset_reader.rs | examples/asset/custom_asset_reader.rs | //! Implements a custom asset io loader.
//! An [`AssetReader`] is what the asset server uses to read the raw bytes of assets.
//! It does not know anything about the asset formats, only how to talk to the underlying storage.
use bevy::{
asset::io::{
AssetReader, AssetReaderError, AssetSource, AssetSourceB... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/hot_asset_reloading.rs | examples/asset/hot_asset_reloading.rs | //! Hot reloading allows you to modify assets files to be immediately reloaded while your game is
//! running. This lets you immediately see the results of your changes without restarting the game.
//! This example illustrates hot reloading mesh changes.
//!
//! Note that hot asset reloading requires the [`AssetWatcher... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/alter_mesh.rs | examples/asset/alter_mesh.rs | //! Shows how to modify mesh assets after spawning.
use bevy::{
asset::RenderAssetUsages, gltf::GltfLoaderSettings,
input::common_conditions::input_just_pressed, mesh::VertexAttributeValues, prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, (setup, sp... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/alter_sprite.rs | examples/asset/alter_sprite.rs | //! Shows how to modify texture assets after spawning.
use bevy::{
asset::RenderAssetUsages, image::ImageLoaderSettings,
input::common_conditions::input_just_pressed, prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, (setup, spawn_text))
.add_... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/asset_decompression.rs | examples/asset/asset_decompression.rs | //! Implements loader for a Gzip compressed asset.
use bevy::{
asset::{
io::{Reader, VecReader},
AssetLoader, ErasedLoadedAsset, LoadContext, LoadDirectError,
},
prelude::*,
reflect::TypePath,
};
use flate2::read::GzDecoder;
use std::{io::prelude::*, marker::PhantomData};
use thiserror:... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/asset/processing/asset_processing.rs | examples/asset/processing/asset_processing.rs | //! This example illustrates how to define custom `AssetLoader`s, `AssetTransformer`s, and `AssetSaver`s, how to configure them, and how to register asset processors.
use bevy::{
asset::{
embedded_asset,
io::{Reader, Writer},
processor::LoadTransformAndSave,
saver::{AssetSaver, Save... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/custom_skinned_mesh.rs | examples/animation/custom_skinned_mesh.rs | //! Skinned mesh example with mesh and joints data defined in code.
//! Example taken from <https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_019_SimpleSkin.md>
use std::f32::consts::*;
use bevy::{
asset::RenderAssetUsages,
math::ops,
mesh::{
skinning::{SkinnedMe... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/easing_functions.rs | examples/animation/easing_functions.rs | //! Demonstrates the behavior of the built-in easing functions.
use bevy::prelude::*;
#[derive(Component)]
#[require(Visibility, Transform)]
struct EaseFunctionPlot(EaseFunction, Color);
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animation_masks.rs | examples/animation/animation_masks.rs | //! Demonstrates how to use masks to limit the scope of animations.
use bevy::{
animation::{AnimatedBy, AnimationTargetId},
color::palettes::css::{LIGHT_GRAY, WHITE},
prelude::*,
};
use std::collections::HashSet;
// IDs of the mask groups we define for the running fox model.
//
// Each mask group defines ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/morph_targets.rs | examples/animation/morph_targets.rs | //! Play an animation with morph targets.
//!
//! Also illustrates how to read morph target names in `name_morphs`.
use bevy::{prelude::*, scene::SceneInstanceReady};
use std::f32::consts::PI;
const GLTF_PATH: &str = "models/animated/MorphStressTest.gltf";
fn main() {
App::new()
.add_plugins(DefaultPlugi... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animated_mesh_control.rs | examples/animation/animated_mesh_control.rs | //! Plays animations from a skinned glTF.
use std::{f32::consts::PI, time::Duration};
use bevy::{animation::RepeatAnimation, light::CascadeShadowConfigBuilder, prelude::*};
const FOX_PATH: &str = "models/animated/Fox.glb";
fn main() {
App::new()
.insert_resource(GlobalAmbientLight {
color: C... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animated_mesh_events.rs | examples/animation/animated_mesh_events.rs | //! Plays animations from a skinned glTF.
use std::{f32::consts::PI, time::Duration};
use bevy::{
animation::{AnimationEvent, AnimationTargetId},
color::palettes::css::WHITE,
light::CascadeShadowConfigBuilder,
prelude::*,
};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
const FOX_PATH: &... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animated_transform.rs | examples/animation/animated_transform.rs | //! Create and play an animation defined by code that operates on the [`Transform`] component.
use std::f32::consts::PI;
use bevy::{
animation::{animated_field, AnimatedBy, AnimationTargetId},
prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(GlobalAmbien... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animation_graph.rs | examples/animation/animation_graph.rs | //! Demonstrates animation blending with animation graphs.
//!
//! The animation graph is shown on screen. You can change the weights of the
//! playing animations by clicking and dragging left or right within the nodes.
use bevy::{
color::palettes::{
basic::WHITE,
css::{ANTIQUE_WHITE, DARK_GREEN},... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animated_ui.rs | examples/animation/animated_ui.rs | //! Shows how to use animation clips to animate UI properties.
use bevy::{
animation::{
animated_field, AnimatedBy, AnimationEntityMut, AnimationEvaluationError, AnimationTargetId,
},
prelude::*,
};
use std::any::TypeId;
// Holds information about the animation we programmatically create.
struct A... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animated_mesh.rs | examples/animation/animated_mesh.rs | //! Plays an animation on a skinned glTF model of a fox.
use std::f32::consts::PI;
use bevy::{light::CascadeShadowConfigBuilder, prelude::*, scene::SceneInstanceReady};
// An example asset that contains a mesh and animation.
const GLTF_PATH: &str = "models/animated/Fox.glb";
fn main() {
App::new()
.inse... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/color_animation.rs | examples/animation/color_animation.rs | //! Demonstrates how to animate colors in different color spaces using mixing and splines.
use bevy::{math::VectorSpace, prelude::*};
// We define this trait so we can reuse the same code for multiple color types that may be implemented using curves.
trait CurveColor: VectorSpace<Scalar = f32> + Into<Color> + Send + ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/animation_events.rs | examples/animation/animation_events.rs | //! Demonstrate how to use animation events.
use bevy::{
animation::AnimationEvent,
color::palettes::css::{ALICE_BLUE, BLACK, CRIMSON},
post_process::bloom::Bloom,
prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(U... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/animation/eased_motion.rs | examples/animation/eased_motion.rs | //! Demonstrates the application of easing curves to animate a transition.
use std::f32::consts::FRAC_PI_2;
use bevy::{
animation::{animated_field, AnimatedBy, AnimationTargetId},
color::palettes::css::{ORANGE, SILVER},
math::vec3,
prelude::*,
};
fn main() {
App::new()
.add_plugins(Defaul... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/dynamic.rs | examples/ecs/dynamic.rs | #![expect(
unsafe_code,
reason = "Unsafe code is needed to work with dynamic components"
)]
//! This example show how you can create components dynamically, spawn entities with those components
//! as well as query for entities with those components.
use std::{alloc::Layout, collections::HashMap, io::Write, p... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/generic_system.rs | examples/ecs/generic_system.rs | //! Generic types allow us to reuse logic across many related systems,
//! allowing us to specialize our function's behavior based on which type (or types) are passed in.
//!
//! This is commonly useful for working on related components or resources,
//! where we want to have unique types for querying purposes but want... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/run_conditions.rs | examples/ecs/run_conditions.rs | //! This example demonstrates how to use run conditions to control when systems run.
use bevy::prelude::*;
fn main() {
println!();
println!("For the first 2 seconds you will not be able to increment the counter");
println!("Once that time has passed you can press space, enter, left mouse, right mouse or t... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/observer_propagation.rs | examples/ecs/observer_propagation.rs | //! Demonstrates how to propagate events through the hierarchy with observers.
use std::time::Duration;
use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer};
use rand::{rng, seq::IteratorRandom, Rng};
fn main() {
App::new()
.add_plugins((MinimalPlugins, LogPlugin::default()))
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/custom_schedule.rs | examples/ecs/custom_schedule.rs | //! Demonstrates how to add custom schedules that run in Bevy's `Main` schedule, ordered relative to Bevy's built-in
//! schedules such as `Update` or `Last`.
use bevy::{
app::MainScheduleOrder,
ecs::schedule::{ExecutorKind, ScheduleLabel},
prelude::*,
};
#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/hierarchy.rs | examples/ecs/hierarchy.rs | //! Demonstrates techniques for creating a hierarchy of parent and child entities.
//!
//! When [`DefaultPlugins`] are added to your app, systems are automatically added to propagate
//! [`Transform`] and [`Visibility`] from parents to children down the hierarchy,
//! resulting in a final [`GlobalTransform`] and [`Inhe... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/system_stepping.rs | examples/ecs/system_stepping.rs | //! Demonstrate stepping through systems in order of execution.
//!
//! To run this example, you must enable the `bevy_debug_stepping` feature.
use bevy::{ecs::schedule::Stepping, log::LogPlugin, prelude::*};
fn main() {
let mut app = App::new();
app
// to display log messages from Stepping resource
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/custom_query_param.rs | examples/ecs/custom_query_param.rs | //! This example illustrates the usage of the [`QueryData`] derive macro, which allows
//! defining custom query and filter types.
//!
//! While regular tuple queries work great in most of simple scenarios, using custom queries
//! declared as named structs can bring the following advantages:
//! - They help to avoid d... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/parallel_query.rs | examples/ecs/parallel_query.rs | //! Illustrates parallel queries with `ParallelIterator`.
use bevy::{ecs::batching::BatchingStrategy, prelude::*};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
#[derive(Component, Deref)]
struct Velocity(Vec2);
fn spawn_system(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/immutable_components.rs | examples/ecs/immutable_components.rs | //! This example demonstrates immutable components.
use bevy::{
ecs::{
component::{ComponentCloneBehavior, ComponentDescriptor, ComponentId, StorageType},
lifecycle::HookContext,
world::DeferredWorld,
},
platform::collections::HashMap,
prelude::*,
ptr::OwningPtr,
};
use core... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/change_detection.rs | examples/ecs/change_detection.rs | //! This example illustrates how to react to component and resource changes.
use bevy::prelude::*;
use rand::Rng;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(
Update,
(
change_component,
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/state_scoped.rs | examples/ecs/state_scoped.rs | //! Shows how to spawn entities that are automatically despawned either when
//! entering or exiting specific game states.
//!
//! This pattern is useful for managing menus, levels, or other state-specific
//! content that should only exist during certain states.
//!
//! If the entity was already despawned then no erro... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/one_shot_systems.rs | examples/ecs/one_shot_systems.rs | //! Demonstrates the use of "one-shot systems", which run once when triggered.
//!
//! These can be useful to help structure your logic in a push-based fashion,
//! reducing the overhead of running extremely rarely run systems
//! and improving schedule flexibility.
//!
//! See the [`World::run_system`](World::run_syst... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/iter_combinations.rs | examples/ecs/iter_combinations.rs | //! Shows how to iterate over combinations of query results.
use bevy::{color::palettes::css::ORANGE_RED, math::FloatPow, prelude::*};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(ClearColor(Color::BLACK))
.... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/observers.rs | examples/ecs/observers.rs | //! Demonstrates how to observe events: both component lifecycle events and custom events.
use bevy::{
platform::collections::{HashMap, HashSet},
prelude::*,
};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.init_resource::<S... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/entity_disabling.rs | examples/ecs/entity_disabling.rs | //! Disabling entities is a powerful feature that allows you to hide entities from the ECS without deleting them.
//!
//! This can be useful for implementing features like "sleeping" objects that are offscreen
//! or managing networked entities.
//!
//! While disabling entities *will* make them invisible,
//! that's no... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/system_closure.rs | examples/ecs/system_closure.rs | //! Shows how anonymous functions / closures can be used as systems.
use bevy::{log::LogPlugin, prelude::*};
fn main() {
// create a simple closure.
let simple_closure = || {
// this is a closure that does nothing.
info!("Hello from a simple closure!");
};
// create a closure, with an... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/relationships.rs | examples/ecs/relationships.rs | //! Entities generally don't exist in isolation. Instead, they are related to other entities in various ways.
//! While Bevy comes with a built-in [`ChildOf`]/[`Children`] relationship
//! (which enables transform and visibility propagation),
//! you can define your own relationships using components.
//!
//! We can de... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/send_and_receive_messages.rs | examples/ecs/send_and_receive_messages.rs | //! From time to time, you may find that you want to both send and receive a message of the same type in a single system.
//!
//! Of course, this results in an error: the borrows of [`MessageWriter`] and [`MessageReader`] overlap,
//! if and only if the [`Message`] type is the same.
//! One system parameter borrows the... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/component_hooks.rs | examples/ecs/component_hooks.rs | //! This example illustrates the different ways you can employ component lifecycle hooks.
//!
//! Whenever possible, prefer using Bevy's change detection or Events for reacting to component changes.
//! Events generally offer better performance and more flexible integration into Bevy's systems.
//! Hooks are useful to ... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/system_param.rs | examples/ecs/system_param.rs | //! This example creates a custom [`SystemParam`] struct that counts the number of players.
use bevy::{ecs::system::SystemParam, prelude::*};
fn main() {
App::new()
.insert_resource(PlayerCount(0))
.add_systems(Startup, spawn)
.add_systems(Update, count_players)
.run();
}
#[derive... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/ecs_guide.rs | examples/ecs/ecs_guide.rs | //! This is a guided introduction to Bevy's "Entity Component System" (ECS)
//! All Bevy app logic is built using the ECS pattern, so definitely pay attention!
//!
//! Why ECS?
//! * Data oriented: Functionality is driven by data
//! * Clean Architecture: Loose coupling of functionality / prevents deeply nested inherit... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/system_piping.rs | examples/ecs/system_piping.rs | //! Illustrates how to make a single system from multiple functions running in sequence,
//! passing the output of the first into the input of the next.
use bevy::prelude::*;
use std::num::ParseIntError;
use bevy::log::{debug, error, info, Level, LogPlugin};
fn main() {
App::new()
.insert_resource(Messag... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/fixed_timestep.rs | examples/ecs/fixed_timestep.rs | //! Shows how to create systems that run every fixed timestep, rather than every tick.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// this system will run once every update (it should match your screen's refresh rate)
.add_systems(Update, frame_update)
... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/hotpatching_systems.rs | examples/ecs/hotpatching_systems.rs | //! This example demonstrates how to hot patch systems.
//!
//! It needs to be run with the dioxus CLI:
//! ```sh
//! dx serve --hot-patch --example hotpatching_systems --features hotpatching
//! ```
//!
//! All systems are automatically hot patchable.
//!
//! You can change the text in the `update_text` system, or the... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/error_handling.rs | examples/ecs/error_handling.rs | //! Showcases how fallible systems and observers can make use of Rust's powerful result handling
//! syntax.
use bevy::ecs::{error::warn, world::DeferredWorld};
use bevy::math::sampling::UniformMeshSampler;
use bevy::prelude::*;
use rand::distr::Distribution;
use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;
fn ma... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/message.rs | examples/ecs/message.rs | //! This example shows how to send, mutate, and receive, messages. It also demonstrates
//! how to control system ordering so that messages are processed in a specific order.
//! It does this by simulating a damage over time effect that you might find in a game.
use bevy::prelude::*;
// In order to send or receive me... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/startup_system.rs | examples/ecs/startup_system.rs | //! Demonstrates a startup system (one that runs once when the app starts up).
use bevy::prelude::*;
fn main() {
App::new()
.add_systems(Startup, startup_system)
.add_systems(Update, normal_system)
.run();
}
/// Startup systems are run exactly once when the app starts up.
/// They run rig... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/nondeterministic_system_order.rs | examples/ecs/nondeterministic_system_order.rs | //! By default, Bevy systems run in parallel with each other.
//! Unless the order is explicitly specified, their relative order is nondeterministic.
//!
//! In many cases, this doesn't matter and is in fact desirable!
//! Consider two systems, one which writes to resource A, and the other which writes to resource B.
/... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/fallible_params.rs | examples/ecs/fallible_params.rs | //! This example demonstrates how fallible parameters can prevent their systems
//! from running if their acquiry conditions aren't met.
//!
//! Fallible system parameters include:
//! - [`Res<R>`], [`ResMut<R>`] - Resource has to exist, and the [`World::default_error_handler`] will be called if it doesn't.
//! - [`Sin... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
bevyengine/bevy | https://github.com/bevyengine/bevy/blob/51a6fedb06a022ab5d39e099413caa882e1b022d/examples/ecs/removal_detection.rs | examples/ecs/removal_detection.rs | //! This example shows how you can know when a [`Component`] has been removed, so you can react to it.
//!
//! When a [`Component`] is removed from an [`Entity`], all [`Observer`] with an [`Remove`] trigger for
//! that [`Component`] will be notified. These observers will be called immediately after the
//! [`Component... | rust | Apache-2.0 | 51a6fedb06a022ab5d39e099413caa882e1b022d | 2026-01-04T15:31:59.438636Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/tests.rs | tests/src/tests.rs | //! Typst's test runner.
mod args;
mod collect;
mod custom;
mod logger;
mod output;
mod pdftags;
mod run;
mod world;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use std::time::Duration;
use clap::Parser;
use parking_lot::{Mutex, RwLock};
use rayon::iter::{ParallelBridge, ParallelIterator};
use rustc_has... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/pdftags.rs | tests/src/pdftags.rs | use std::collections::HashMap;
use std::fmt::Write;
use std::sync::{Arc, LazyLock};
use ecow::eco_format;
use hayro_syntax::content::ops::TypedInstruction;
use hayro_syntax::object::dict::keys;
use hayro_syntax::object::{Array, Dict, Name, Object, Stream};
use hayro_syntax::object::{Number, ObjRef};
use indexmap::Inde... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/world.rs | tests/src/world.rs | use std::borrow::Cow;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::OnceLock;
use comemo::Tracked;
use parking_lot::Mutex;
use rustc_hash::FxHashMap;
use typst::diag::{At, FileError, FileResult, SourceResult, StrResult, bail};
use typst::engine::Engine;
use typs... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/collect.rs | tests/src/collect.rs | use std::fmt::{self, Display, Formatter};
use std::io::IsTerminal;
use std::ops::Range;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::LazyLock;
use bitflags::{Flags, bitflags};
use ecow::{EcoString, eco_format};
use rustc_hash::{FxHashMap, FxHashSet};
use typst::foundations::Bytes;
use typst_pd... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/logger.rs | tests/src/logger.rs | use std::io::{self, IsTerminal, StderrLock, Write};
use std::time::{Duration, Instant};
use crate::collect::Test;
/// The result of running a single test.
pub struct TestResult {
/// The error log for this test. If empty, the test passed.
pub errors: String,
/// The info log for this test.
pub infos: ... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/args.rs | tests/src/args.rs | use std::path::PathBuf;
use std::sync::atomic::{AtomicU8, Ordering};
use clap::{Parser, Subcommand, ValueEnum};
use regex::Regex;
use crate::collect::TestStages;
/// Typst's test runner.
#[derive(Debug, Clone, Parser)]
#[command(bin_name = "cargo test --workspace --test tests --")]
#[clap(name = "typst-test", author... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/run.rs | tests/src/run.rs | use std::fmt::Write;
use std::ops::Range;
use std::str::FromStr;
use std::sync::LazyLock;
use parking_lot::RwLock;
use regex::{Captures, Regex};
use rustc_hash::FxHashMap;
use typst::diag::{SourceDiagnostic, Warned};
use typst::layout::PagedDocument;
use typst::{Document, WorldExt};
use typst_html::HtmlDocument;
use t... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/output.rs | tests/src/output.rs | use std::fmt::Display;
use std::str::FromStr;
use ecow::EcoString;
use indexmap::IndexMap;
use rustc_hash::FxBuildHasher;
use tiny_skia as sk;
use typst::diag::{At, SourceResult, StrResult, bail};
use typst::layout::{Abs, Frame, FrameItem, PagedDocument, Transform};
use typst::visualize::Color;
use typst_html::HtmlDoc... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/src/custom.rs | tests/src/custom.rs | use std::fmt::Write;
use typst::World;
use typst::foundations::Smart;
use typst::introspection::{Location, Tag};
use typst::layout::{Frame, FrameItem, PagedDocument};
use typst::model::DocumentInfo;
use crate::collect::Test;
use crate::world::TestWorld;
/// We don't want to panic when there is a failure.
macro_rules... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/fuzz/src/lib.rs | tests/fuzz/src/lib.rs | use typst::diag::{FileError, FileResult};
use typst::foundations::{Bytes, Datetime};
use typst::syntax::{FileId, Source};
use typst::text::{Font, FontBook};
use typst::utils::LazyHash;
use typst::{Library, LibraryExt, World};
pub struct FuzzWorld {
library: LazyHash<Library>,
book: LazyHash<FontBook>,
font... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/fuzz/src/bin/html.rs | tests/fuzz/src/bin/html.rs | #![no_main]
use libfuzzer_sys::fuzz_target;
use typst_fuzz::FuzzWorld;
use typst_html::HtmlDocument;
fuzz_target!(|text: &str| {
let world = FuzzWorld::new(text);
if let Ok(document) = typst::compile::<HtmlDocument>(&world).output {
_ = std::hint::black_box(typst_html::html(&document));
}
come... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/fuzz/src/bin/parse.rs | tests/fuzz/src/bin/parse.rs | #![no_main]
use libfuzzer_sys::fuzz_target;
use typst_syntax::parse;
fuzz_target!(|text: &str| {
std::hint::black_box(parse(text));
});
| rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/tests/fuzz/src/bin/paged.rs | tests/fuzz/src/bin/paged.rs | #![no_main]
use libfuzzer_sys::fuzz_target;
use typst::layout::PagedDocument;
use typst_fuzz::FuzzWorld;
use typst_pdf::PdfOptions;
fuzz_target!(|text: &str| {
let world = FuzzWorld::new(text);
if let Ok(document) = typst::compile::<PagedDocument>(&world).output {
if let Some(page) = document.pages.fi... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/crates/typst-macros/src/func.rs | crates/typst-macros/src/func.rs | use heck::ToKebabCase;
use proc_macro2::TokenStream;
use quote::quote;
use syn::parse::{Parse, ParseStream};
use syn::{Ident, Result, parse_quote};
use crate::util::{
determine_name_and_title, documentation, foundations, has_attr, kw, parse_attr,
parse_flag, parse_key_value, parse_string, parse_string_array, q... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/crates/typst-macros/src/lib.rs | crates/typst-macros/src/lib.rs | //! Procedural macros for Typst.
extern crate proc_macro;
#[macro_use]
mod util;
mod cast;
mod elem;
mod func;
mod scope;
mod time;
mod ty;
use proc_macro::TokenStream as BoundaryStream;
use syn::DeriveInput;
/// Makes a native Rust function usable as a Typst function.
///
/// This implements `NativeFunction` for a... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/crates/typst-macros/src/elem.rs | crates/typst-macros/src/elem.rs | use heck::ToKebabCase;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::{Ident, Result, Token};
use crate::util::{
BlockWithReturn, determine_name_and_title, documentation, foundations, has_attr, kw,
parse_attr, pars... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/crates/typst-macros/src/time.rs | crates/typst-macros/src/time.rs | use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use syn::parse::{Parse, ParseStream};
use syn::{Result, parse_quote};
use crate::util::{kw, parse_key_value, parse_string};
/// Expand the `#[time(..)]` macro.
pub fn time(stream: TokenStream, item: syn::ItemFn) -> Result<TokenStream> {
let meta: Meta = ... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
typst/typst | https://github.com/typst/typst/blob/a87f4b15ca86a0b2f98948d8f393608070ed731e/crates/typst-macros/src/util.rs | crates/typst-macros/src/util.rs | use heck::{ToKebabCase, ToTitleCase};
use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use syn::parse::{Parse, ParseStream};
use syn::token::Token;
use syn::{Attribute, Ident, Result, Token};
/// Return an error at the given item.
macro_rules! bail {
(callsite, $($tts:tt)*) => {
return Err(syn::... | rust | Apache-2.0 | a87f4b15ca86a0b2f98948d8f393608070ed731e | 2026-01-04T15:31:59.400510Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.