2D rendering examples
The engine's 2D rendering examples: what each one shows, whether it runs in a browser and the command that runs it.
Sprites, 2D meshes and shapes, 2D cameras, text in the world and 2D post-processing. There are 29 examples on this page. For the concepts behind them, see 2D.
Run any of them from the engine core's workspace (the folder of the engine source that holds the neo crate's Cargo.toml); see Run an example.
Examples#
| Example | What it shows | Web | Run |
|---|---|---|---|
| 2D Bloom | Illustrates bloom post-processing in 2d | Yes | cargo run --example bloom_2d |
| 2D Rotation to Cursor | Demonstrates rotating entities in 2D to follow the cursor | Yes | cargo run --example rotate_to_cursor |
| 2D Shapes | Renders simple 2D primitive shapes like circles and polygons | Yes | cargo run --example 2d_shapes --features neo_feathers |
| 2D Viewport To World | Demonstrates how to use the Camera::viewport_to_world_2d method with a dynamic viewport and camera. | Yes | cargo run --example 2d_viewport_to_world |
| 2D Wireframe | Showcases wireframes for 2d meshes | No | cargo run --example wireframe_2d --features neo_feathers |
| Arc 2D Meshes | Demonstrates UV-mapping of the circular segment and sector primitives | Yes | cargo run --example mesh2d_arcs |
| CPU Drawing | Manually read/write the pixels of a texture | Yes | cargo run --example cpu_draw |
| Dynamic Mipmap Generation | Demonstrates use of the mipmap generation plugin to generate mipmaps for a texture | No | cargo run --example dynamic_mip_generation --features neo_feathers |
| Generic 2D Rotation | Demonstrates rotating entities in 2D with quaternions | Yes | cargo run --example rotation |
| Manual Mesh 2D | Renders a custom mesh "manually" with "mid-level" renderer apis | Yes | cargo run --example mesh2d_manual |
| Mesh 2D | Renders a 2d mesh | Yes | cargo run --example mesh2d |
| Mesh 2D With Vertex Colors | Renders a 2d mesh with vertex color attributes | Yes | cargo run --example mesh2d_vertex_color_texture |
| Mesh2d Alpha Mode | Used to test alpha modes with mesh2d | Yes | cargo run --example mesh2d_alpha_mode |
| Mesh2d Repeated Texture | Showcase of using uv_transform on the ColorMaterial of a Mesh2d | Yes | cargo run --example mesh2d_repeated_texture |
| Move Sprite | Changes the transform of a sprite | Yes | cargo run --example move_sprite |
| Multi-Window Text | Renders text to multiple windows with different scale factors using both Text and Text2d | Yes | cargo run --example multi_window_text |
| Pixel Grid Snapping | Shows how to create graphics that snap to the pixel grid by rendering to a texture in 2D | Yes | cargo run --example pixel_grid_snap |
| Sprite | Renders a sprite | Yes | cargo run --example sprite |
| Sprite Animation | Animates a sprite in response to an event | Yes | cargo run --example sprite_animation |
| Sprite Flipping | Renders a sprite flipped along an axis | Yes | cargo run --example sprite_flipping |
| Sprite Scale | Shows how a sprite can be scaled into a rectangle while keeping the aspect ratio | Yes | cargo run --example sprite_scale |
| Sprite Sheet | Renders an animated sprite | Yes | cargo run --example sprite_sheet |
| Sprite Slice | Showcases slicing sprites into sections that can be scaled independently via the 9-patch technique | Yes | cargo run --example sprite_slice |
| Sprite Tile | Renders a sprite tiled in a grid | Yes | cargo run --example sprite_tile |
| Text 2D | Generates text in 2D | Yes | cargo run --example text2d |
| Texture Atlas | Generates a texture atlas (sprite sheet) from individual sprites | No | cargo run --example texture_atlas |
| Tilemap Chunk | Renders a tilemap chunk | Yes | cargo run --example tilemap_chunk |
| Tilemap Chunk with Orientations | Renders a tilemap chunk using tile orientations (mirrored, rotated) | Yes | cargo run --example tilemap_chunk_orientation |
| Transparency in 2D | Demonstrates transparency in 2d | Yes | cargo run --example transparency_2d |