A block with forces (Force::new(name, x, y), in newtons, y up) drawn from its middle,
scale units per newton. The arrows grow one after another, each labelled at its tip with
its name and magnitude. Then the other forces dim and their sum grows as a dashed arrow
labelled net = … N, or net = 0 under the block when they balance. net_force() gives
the sum. Gallery scene: FreeBody.

FreeBody 4.5 suse fframes_kit::prelude::*;
fn figure<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> { ui.show(FreeBody { forces: vec![ Force::new("W", 0.0, -5.0), Force::new("N", 0.0, 5.0), Force::new("F", 6.0, 0.0), Force::new("f", -2.0, 0.0), ], center: (0.0, -0.4), scale: 0.45, delay: 0.5, ..ui.defaults() })}Components are plain structs. Set the fields you need and fill the rest with ..ui.defaults(): the defaults below come from the current theme (theme. values are fields of Theme).
FreeBody
Section titled “FreeBody”| Field | Type | Default | Description |
|---|---|---|---|
forces |
Vec<Force> |
Vec::new() |
The forces on the block, each with a name and components in newtons (y up). |
center |
(f64, f64) |
(0.0, 0.0) |
The middle of the block, where the arrows start, in units of ui.space. |
scale |
f64 |
0.5 |
Units of ui.space per newton. |
size |
f32 |
160.0 |
Side of the square block in pixels. |
delay |
f32 |
0.0 |
Seconds after the local start before the first arrow starts to grow. |
grow |
f32 |
0.6 |
Seconds each arrow takes to grow. |
stagger |
f32 |
0.5 |
Seconds between the start of one arrow and the next. |
net |
bool |
true |
Draws the sum of the forces as a dashed arrow after the others, or net = 0 under the block when they balance. |
net_name |
&str |
"net" |
The name in the net force’s label, “net = 4 N”. |
labels |
bool |
true |
Writes each force’s name at its tip. |
magnitudes |
bool |
true |
Adds the magnitude in newtons to each label. |
block_color |
Color |
theme.colors.muted |
Colour of the block. |
force_color |
Color |
theme.colors.accent |
Colour of the force arrows that have no colour of their own. |
net_color |
Color |
theme.colors.highlight |
Colour of the net force arrow and its label. |
text_color |
Color |
theme.colors.text |
Colour of the force labels; the net force’s label takes net_color. |
stroke_width |
f32 |
theme.stroke.regular |
Width of the arrow shafts in pixels. |
enter |
Option<EnterAnim> |
None |
How the block draws in; None shows it from the start. |
exit |
Option<ExitAnim> |
None |
How the block leaves at the end of the container; None stays. |
parts_enter |
Option<FadeIn> |
None |
How the arrows and labels fade in; None for none. |
parts_exit |
Option<FadeOut> |
None |
How the arrows and labels fade out before the end; None for none. |
Methods:
fn net_force(&self) -> (f64, f64): The sum of the forces in newtons.fn start_of(&self, i: usize) -> f32: Seconds after the local start when forceistarts to grow;forces.len()gives the start of the net force.
Feature physics · Source
