# core/component/outline (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/component/outline/

A component that draws only an outline. (Outline in vanilla.js core/component/outline.js)
- Paint only fills, so this is used to put a separate outline over a see-through panel. (stacking two filled panels mixes the outer color into the see-through inside)
- A rounded box outline uses the node's content size as is, and a circle outline is drawn at its center with half the shorter side as the radius.
- The line stays inside the content size. (the center of the line is half the thickness inward)

## Outline (struct) (Default, Component)

A component that draws only an outline. (leaves the inside empty and strokes only the border of the node's content_size)
- Initially white, thickness 1, round size 0, box outline.
- The line is stroked inside the content size, so the outer shape equals the content size. The round size is also based on the outer shape.

Example: Put a round outline over a see-through panel

```rust
use vanilla::{Color, NodeTree, Outline, Paint, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let card_id = node_tree.create_child(root_id, "Card");
node_tree[card_id].set_content_size(Vector2::create(200.0, 120.0));
node_tree.add_component(card_id, Paint::create_with_color(Color::black().with_alpha(0.4)));
let outline = node_tree.add_component(card_id, Outline::new()).unwrap();
outline.set_color("#ffcc00");
outline.set_line_width(3.0);
outline.set_round_size(12.0);

let outline = node_tree[card_id].get_component::<Outline>().unwrap();
assert_eq!(outline.get_line_width(), 3.0);
assert!(!outline.is_circle());
```

- `pub fn new() -> Outline` (constructor, since 0.4.0): Constructor.
  - returns Outline: Box outline component, white, thickness 1, round size 0.
- `pub fn draw_outline(&self, transform: &NodeTransform, graphic: &mut Graphic)` (method, since 0.4.0): Draw.
  - Does not draw if the thickness is 0 or less, or if the width or height left after subtracting the thickness (the radius for a circle) is 0 or less.
  - The Graphic's stroke color changes to this color.
  - `transform` &NodeTransform: Node transform to draw the outline on. (reads content_size)
  - `graphic` &mut Graphic: Graphic to draw to. (with the node transform applied)
- `pub fn set_color(&mut self, color: impl Into<Color>)` (method, since 0.4.0): Sets the color. (a Color or a string such as "#rrggbb")
  - `color` impl Into<Color>: Outline color. (alpha is the opacity, initially white)
- `pub fn get_color(&self) -> Color` (method, since 0.4.0): Returns the color.
  - returns Color: Outline color.
- `pub fn set_line_width(&mut self, line_width: f64)` (method, since 0.4.0): Sets the thickness. (0 does not draw)
  - `line_width` f64: Line thickness. (node coordinates, does not draw if 0 or less, initially 1)
- `pub fn get_line_width(&self) -> f64` (method, since 0.4.0): Returns the thickness.
  - returns f64: Line thickness. (node coordinates)
- `pub fn set_round_size(&mut self, round_size: f64)` (method, since 0.4.0): Sets the corner roundness. (based on the outer shape)
  - `round_size` f64: Corner round size of the outer shape. (node coordinates, initially 0) The center of the line is stroked half the thickness less rounded. Not used for circle outlines.
- `pub fn get_round_size(&self) -> f64` (method, since 0.4.0): Returns the corner roundness.
  - returns f64: Corner round size of the outer shape. (node coordinates)
- `pub fn set_circle(&mut self, is_circle: bool)` (method, since 0.4.0): Sets whether to draw as a circle border.
  - `is_circle` bool: If true, a circle outline at the center of the content size with half the shorter side as the outer radius, if false, a box outline. (initially false)
- `pub fn is_circle(&self) -> bool` (method, since 0.4.0): Returns whether it is a circle border.
  - returns bool: true for a circle outline, false for a box outline.
