# base/pivot (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/base/pivot/

Pivot / anchor values.
- The Pivot object of the original base/pivot.js moved to associated constants.

## Pivot (struct)

Pivot and anchor constants. (ratios within the content size, (0, 0) is the top left, (1, 1) the bottom right)

Example: Set a node's pivot to the bottom center

```rust
use vanilla::{NodeTree, Pivot, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let icon_id = node_tree.create_child(root_id, "icon");
node_tree[icon_id].set_content_size(Vector2::create(64.0, 64.0));
node_tree[icon_id].set_pivot(Pivot::BOTTOM_CENTER);
assert_eq!(node_tree[icon_id].get_pivot(), Vector2::create(0.5, 1.0));
```

- `pub const TOP_LEFT: Vector2 = Vector2::create(0.0, 0.0)` (static, since 0.3.2): Top left. (0, 0)
  - returns Vector2
- `pub const TOP_CENTER: Vector2 = Vector2::create(0.5, 0.0)` (static, since 0.3.2): Top center. (0.5, 0)
  - returns Vector2
- `pub const TOP_RIGHT: Vector2 = Vector2::create(1.0, 0.0)` (static, since 0.3.2): Top right. (1, 0)
  - returns Vector2
- `pub const MIDDLE_LEFT: Vector2 = Vector2::create(0.0, 0.5)` (static, since 0.3.2): Middle left. (0, 0.5)
  - returns Vector2
- `pub const MIDDLE_CENTER: Vector2 = Vector2::create(0.5, 0.5)` (static, since 0.3.2): Middle center. (0.5, 0.5)
  - returns Vector2
- `pub const MIDDLE_RIGHT: Vector2 = Vector2::create(1.0, 0.5)` (static, since 0.3.2): Middle right. (1, 0.5)
  - returns Vector2
- `pub const BOTTOM_LEFT: Vector2 = Vector2::create(0.0, 1.0)` (static, since 0.3.2): Bottom left. (0, 1)
  - returns Vector2
- `pub const BOTTOM_CENTER: Vector2 = Vector2::create(0.5, 1.0)` (static, since 0.3.2): Bottom center. (0.5, 1)
  - returns Vector2
- `pub const BOTTOM_RIGHT: Vector2 = Vector2::create(1.0, 1.0)` (static, since 0.3.2): Bottom right. (1, 1)
  - returns Vector2
