Skip to content

MatrixView

Cargo featurefeatures = ["math"]

A matrix product worked out entry by entry: a × b = c, centered on (x, y). From delay, every step seconds the next entry of the product is written, row by row, while its row of a and column of b are highlighted. product(a, b) is the multiplication, None when the sizes do not fit. Gallery scene: MatrixView.

MatrixView demo, first frame
MatrixView 4.6 s
use fframes_kit::prelude::*;
use fframes_kit::kits::math::product;
fn figure<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> {
ui.show(MatrixView {
a: vec![vec![1.0, 2.0, 0.0], vec![-1.0, 3.0, 1.0]],
b: vec![vec![2.0, 1.0], vec![0.0, 1.0], vec![4.0, -2.0]],
delay: 1.0,
step: 0.8,
..ui.defaults()
})
}
let c = product(&[vec![1.0, 2.0]], &[vec![3.0], vec![4.0]]);
assert_eq!(c, Some(vec![vec![11.0]]));

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).

Field Type Default Description
a Vec<Vec<f64>> vec![vec![1.0, 2.0], vec![3.0, 4.0]] The left matrix, as rows of entries.
b Vec<Vec<f64>> vec![vec![5.0, 6.0], vec![7.0, 8.0]] The right matrix, as rows of entries; its row count must equal the column count of a, otherwise nothing is drawn.
x f32 960.0 Horizontal middle of the three matrices, in pixels of the canvas.
y f32 540.0 Vertical middle of the matrices, in pixels of the canvas.
gap f32 theme.spacing.lg Pixels between the matrices and the signs.
delay f32 0.5 Seconds after the container’s start before the first entry is worked out.
step f32 0.8 Seconds each entry of the product takes; its row and column highlight meanwhile.
decimals usize 2 Most digits after the decimal point of the written entries.
highlight Color theme.colors.highlight Colour of the highlight on the current row of a and column of b.
result_color Color theme.colors.accent Colour of the entries of the product.
matrices_enter Option<FadeIn> Some(FadeIn::themed(theme)) Fade in of the matrices; None shows them from the start.

Feature math · Source