# Neuron

> Neuron lies across the frame, length pixels from its dendrites to its axon terminals: dendrites branching from the cell body (placed from seed), the axon…

Page: https://fframes-kit.pages.dev/docs/biology/neuron/
Cargo feature: `biology` (`fframes-kit = { version = "..", features = ["biology"] }`)

`Neuron` lies across the frame, `length` pixels from its dendrites to its axon terminals:
dendrites branching from the cell body (placed from `seed`), the axon wrapped in myelin with
nodes of Ranvier between the segments, and the terminals. It grows in from `delay`, and with
`labels` each part is then named above or below it. At each time in `impulses` the cell body
fires and the impulse jumps from node to node along the axon at `speed` pixels a second; at
the terminals it releases neurotransmitter. Gallery scenes: `Neuron`, and `NeuralRelay`: three
neurons whose terminals touch the next one's dendrites, each firing as the impulse arrives.

Gallery clip of `Neuron`: https://fframes-kit.pages.dev/media/scenes/Neuron-233362a6.mp4

Gallery clip of `NeuralRelay`: https://fframes-kit.pages.dev/media/scenes/NeuralRelay-aa9ea90b.mp4

```rust
use fframes_kit::prelude::*;

fn two_signals<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> {
    ui.show(Neuron {
        impulses: vec![2.5, 3.5],
        labels: false,
        ..ui.defaults()
    })
}
```

## API

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

### Neuron

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `delay` | `f32` | `0.0` | Seconds after the container's start before the neuron begins to grow; `impulses` are not shifted by it. |
| `center` | `(f64, f64)` | `(0.0, -0.2)` | The middle of the neuron, in units of `ui.space`. |
| `length` | `f32` | `1320.0` | Pixels from the dendrite tips to the axon terminals. |
| `impulses` | `Vec<f32>` | `vec![4.6, 6.6]` | Times in seconds, from the container's start, when the cell body fires an impulse; empty for none. |
| `speed` | `f32` | `700.0` | Speed of the impulse along the axon, in pixels per second. |
| `labels` | `bool` | `true` | Names each part above or below it when `true`. |
| `seed` | `u64` | `5` | Seed for the shape of the dendrites and terminals; the same seed gives the same neuron. |
| `body_color` | `Color` | `Color::hex("#4dabf7")` | Fill of the cell body, dendrites and axon. |
| `nucleus_color` | `Color` | `Color::hex("#1c4a7a")` | Fill of the nucleus in the cell body. |
| `myelin_color` | `Color` | `Color::hex("#ffd8a8")` | Fill of the myelin sheath segments. |
| `impulse_color` | `Color` | `Color::hex("#ffe066")` | Colour of the travelling impulse and the released neurotransmitter. |
| `leader_color` | `Color` | `theme.colors.muted` | Colour of the leader lines and the dots that mark each named part. |
| `label_color` | `Color` | `theme.colors.text` | Colour of the part names. |
| `label_style` | `TextStyle` | `theme.typography.caption` | The font of the part names: family, size in pixels and weight. |
| `enter` | `Option<FadeIn>` | `None` | Fade in at the start; `None` for none. |
| `exit` | `Option<FadeOut>` | `None` | Fade out before the end; `None` for none. |

Feature `biology` · [Source](https://github.com/khanhthanhdev/fframes-kit/blob/main/fframes-kit/src/kits/biology/neuron.rs#L145)
