# core/node/worldnode (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/node/worldnode/

월드 노드.
- 부모/자식 계층 + 활성화 (원본 Node)
- 컴포넌트 보유 + tick (원본 ComponentNode)
- 로컬 TRS + 렌더 재귀 (원본 TransformNode)
- pivot / anchor / content_size + 터치 (원본 WorldNode)
- 노드는 씬의 NodeTree 저장소에 들어 있고, 부모와 자식은 핸들(NodeId)로 잇는다.
  트리를 바꾸는 일(자식 붙이기, 지우기, 찾기)과 트리를 도는 일(tick, draw, 터치)은 NodeTree 가 한다.

## NodeTransform (struct) (Clone, Debug, Default)

노드 트랜스폼. (컴포넌트가 tick / draw 에서 받아 읽고 바꾸는 노드 상태)
- local_position 은 부모 영역 안에서 자기 피봇 점의 좌표다. (anchor 는 anchored_position 계산용)
- local_rotation 은 도 단위. (원본과 같음)

예제: 가운데 피봇 노드를 사각형에 놓고 경계 보기

```rust
use vanilla::{NodeTransform, Pivot, Rect, Vector2};

let mut transform = NodeTransform::new();
transform.set_pivot(Pivot::MIDDLE_CENTER);
transform.set_rect(10.0, 20.0, 100.0, 50.0);
assert_eq!(transform.get_local_position(), Vector2::create(60.0, 45.0));
assert_eq!(transform.get_local_bounds(), Rect::create(10.0, 20.0, 100.0, 50.0));
transform.set_local_scale(Vector2::create(2.0, 2.0));
assert_eq!(transform.get_local_bounds(), Rect::create(-40.0, -5.0, 200.0, 100.0));
```

- `pub fn new() -> NodeTransform` (constructor, since 0.3.2): 생성.
  - returns NodeTransform: 위치 (0, 0), 배율 1, 회전 0, 불투명도 1, 내용 크기 0, 피봇과 앵커는 가운데, 보이는 트랜스폼.
- `pub fn set_local_position(&mut self, local_position: Vector2)` (method, since 0.3.2): 로컬 위치 설정.
  - `local_position` Vector2: 부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리.
- `pub fn get_local_position(&self) -> Vector2` (method, since 0.3.2): 로컬 위치 반환.
  - returns Vector2: 로컬 위치. (부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리)
- `pub fn set_local_scale(&mut self, local_scale: Vector2)` (method, since 0.3.2): 로컬 크기 설정.
  - `local_scale` Vector2: 축마다 배율. (1 이 원래 크기, 음수면 그 축으로 뒤집혀 그려진다)
- `pub fn get_local_scale(&self) -> Vector2` (method, since 0.3.2): 로컬 크기 반환.
  - returns Vector2: 로컬 배율.
- `pub fn set_local_rotation(&mut self, local_rotation: f64)` (method, since 0.3.2): 로컬 회전 설정. (도)
  - `local_rotation` f64: 회전. (도, 양수면 화면에서 시계 방향)
- `pub fn get_local_rotation(&self) -> f64` (method, since 0.3.2): 로컬 회전 반환. (도)
  - returns f64: 로컬 회전. (도)
- `pub fn set_local_opacity(&mut self, local_opacity: f64)` (method, since 0.3.2): 로컬 투명도 설정. (자식에게 곱해져 내려간다)
  - `local_opacity` f64: 불투명도. (0 ~ 1, 밖의 값은 잘라 넣는다)
- `pub fn get_local_opacity(&self) -> f64` (method, since 0.3.2): 로컬 투명도 반환.
  - returns f64: 로컬 불투명도. (0 ~ 1)
- `pub fn set_pivot(&mut self, pivot: Vector2)` (method, since 0.3.2): 피봇 설정. (content_size 안에서 기준점의 비율, 기본 가운데)
  - `pivot` Vector2: 내용 크기 안의 기준점 비율. ((0, 0) 왼쪽 위, (1, 1) 오른쪽 아래, Pivot 상수)
- `pub fn get_pivot(&self) -> Vector2` (method, since 0.3.2): 피봇 반환.
  - returns Vector2: 피봇. (내용 크기 안의 비율)
- `pub fn set_content_size(&mut self, content_size: Vector2)` (method, since 0.3.2): 컨텐츠 크기 설정.
  - `content_size` Vector2: 내용 크기. (노드 좌표, 배율을 걸기 전)
- `pub fn get_content_size(&self) -> Vector2` (method, since 0.3.2): 컨텐츠 크기 반환.
  - returns Vector2: 내용 크기. (노드 좌표, 배율을 걸기 전)
- `pub fn set_local_position_xy(&mut self, x: f64, y: f64)` (method, since 0.4.0): 로컬 위치 설정. (x, y 를 바로 받는다, 원본 setLocalPositionXY)
  - `x` f64: 로컬 위치 x.
  - `y` f64: 로컬 위치 y.
- `pub fn set_local_scale_xy(&mut self, x: f64, y: f64)` (method, since 0.4.0): 로컬 크기 설정. (x, y 를 바로 받는다, 원본 setLocalScaleXY)
  - `x` f64: 가로 배율.
  - `y` f64: 세로 배율.
- `pub fn set_content_size_xy(&mut self, width: f64, height: f64)` (method, since 0.4.0): 컨텐츠 크기 설정. (너비, 높이를 바로 받는다, 원본 setContentSizeXY)
  - `width` f64: 내용 너비.
  - `height` f64: 내용 높이.
- `pub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)` (method, since 0.4.0): 부모 영역 안의 사각형에 놓기. (x, y 는 이 노드의 왼쪽 위, 부모 내용 영역의 왼쪽 위가 원점, 원본 setRect)
  - 내용 크기를 width, height 로 두고, 피봇이 어디든 왼쪽 위가 (x, y) 에 오게 로컬 위치를 정한다. (x + width * pivot.x, y + height * pivot.y)
  - 앵커는 바꾸지 않는다. 로컬 위치는 앵커와 무관하게 부모 왼쪽 위 기준이라 앵커가 어디든 같은 자리다.
  - 로컬 배율과 회전은 보지 않는다. (배율 1, 회전 0 일 때 화면에서도 그 사각형이다)
  - `x` f64: 왼쪽 위 x. (부모 내용 영역의 왼쪽 위 기준)
  - `y` f64: 왼쪽 위 y. (부모 내용 영역의 왼쪽 위 기준)
  - `width` f64: 내용 너비.
  - `height` f64: 내용 높이.
- `pub fn set_anchor(&mut self, anchor: Vector2)` (method, since 0.3.2): 앵커 설정. (부모 content_size 안의 비율)
  - `anchor` Vector2: 부모 내용 크기 안의 비율. (anchored_position 의 기준점, Pivot 상수)
- `pub fn get_anchor(&self) -> Vector2` (method, since 0.3.2): 앵커 반환.
  - returns Vector2: 앵커. (부모 내용 크기 안의 비율)
- `pub fn set_anchored_position(&mut self, anchored_position: Vector2, parent_content_size: Vector2)` (method, since 0.3.2): 앵커 기준 위치 설정. (부모 content_size 를 알아야 한다)
  - 로컬 위치를 (부모 내용 크기 x 앵커) + anchored_position 으로 둔다.
  - `anchored_position` Vector2: 앵커 점에서 본 위치.
  - `parent_content_size` Vector2: 부모의 내용 크기.

  예제: 부모 오른쪽 아래에서 20 씩 안쪽에 놓기

  ```rust
  use vanilla::{NodeTransform, Pivot, Vector2};
  
  let mut transform = NodeTransform::new();
  transform.set_anchor(Pivot::BOTTOM_RIGHT);
  let parent_content_size = Vector2::create(800.0, 600.0);
  transform.set_anchored_position(Vector2::create(-20.0, -20.0), parent_content_size);
  assert_eq!(transform.get_local_position(), Vector2::create(780.0, 580.0));
  assert_eq!(transform.get_anchored_position(parent_content_size), Vector2::create(-20.0, -20.0));
  ```

- `pub fn get_anchored_position(&self, parent_content_size: Vector2) -> Vector2` (method, since 0.3.2): 앵커 기준 위치 반환.
  - `parent_content_size` Vector2: 부모의 내용 크기.
  - returns Vector2: 앵커 점(부모 내용 크기 x 앵커)에서 본 로컬 위치.
- `pub fn set_visible(&mut self, is_visible: bool)` (method, since 0.3.2): 보이기 설정. (꺼도 tick 은 돈다. 원본 isVisible)
  - `is_visible` bool: 그릴지. (false 면 이 노드와 자손을 그리지 않고 터치도 받지 않는다)
- `pub fn is_visible(&self) -> bool` (method, since 0.3.2): 보이기 여부.
  - returns bool: 보이면 true.
- `pub fn calculate_local_matrix(&self) -> TransformMatrix` (method, since 0.3.2): 로컬 변환 행렬. (push_transform 과 같은 순서: 이동 → 회전 → 크기 → 피봇 보정)
  - returns TransformMatrix: 이 노드 내용 좌표의 점을 부모 내용 좌표로 옮기는 행렬.
- `pub fn get_local_bounds(&self) -> Rect` (method, since 0.3.2): 부모 영역에서 본 경계 사각형. (회전이 없을 때 정확하다. 충돌 검사 등)
  - returns Rect: 부모 내용 좌표의 경계 사각형. (배율은 절댓값으로 걸고 회전은 넣지 않는다)

## WorldNode (struct)

월드 노드.
- 이름, 활성, 터치 받기, 트랜스폼, 컴포넌트 목록, 부모와 자식 핸들을 든다.

예제: 노드 하나에 컴포넌트를 붙이고 찾기

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

let mut node = WorldNode::new("card");
node.set_content_size(Vector2::create(120.0, 80.0));
node.add_component(Paint::create_with_color(Color::white()));
assert_eq!(node.get_name(), "card");
assert!(node.has_component::<Paint>());
assert_eq!(node.get_component::<Paint>().expect("paint").get_color(), Color::white());
assert!(node.is_root());
```

- `pub fn new(name: &str) -> WorldNode` (constructor, since 0.3.2): 생성. (트리에 넣을 때는 NodeTree::create_node 를 쓴다)
  - `name` &str: 노드 이름. (이름으로 찾기에 쓴다)
  - returns WorldNode: 부모가 없고 활성인 새 노드. (터치는 받지 않는다)
- `pub fn get_instance_id(&self) -> u64` (method, since 0.3.2): 인스턴스 식별자.
  - returns u64: 만들 때 받은 번호. (1 부터, 노드마다 겹치지 않는다)
- `pub fn set_name(&mut self, name: &str)` (method, since 0.3.2): 이름 설정.
  - `name` &str: 새 이름.
- `pub fn get_name(&self) -> &str` (method, since 0.3.2): 이름 반환.
  - returns &str: 노드 이름.
- `pub fn get_parent_id(&self) -> Option<NodeId>` (method, since 0.3.2): 부모 핸들. (루트이거나 아직 붙지 않았으면 None)
  - returns Option<NodeId>: 부모 핸들. 루트이거나 아직 붙지 않았으면 None.
- `pub fn get_child_ids(&self) -> &[NodeId]` (method, since 0.3.2): 자식 핸들 목록. (그리는 순서)
  - returns &[NodeId]: 자식 핸들 목록. (앞이 먼저 그려진다)
- `pub fn get_child_count(&self) -> usize` (method, since 0.3.2): 자식 수.
  - returns usize: 바로 아래 자식 수.
- `pub fn is_root(&self) -> bool` (method, since 0.4.0): 부모가 없는지. (원본 isRoot, 트리의 루트와 아직 붙이지 않은 노드)
  - returns bool: 부모가 없으면 true.
- `pub fn is_leaf(&self) -> bool` (method, since 0.4.0): 자식이 없는지. (원본 isLeaf)
  - returns bool: 자식이 없으면 true.
- `pub fn has_parent(&self) -> bool` (method, since 0.4.0): 부모가 있는지. (원본 hasParent)
  - returns bool: 부모가 있으면 true.
- `pub fn get_child(&self, child_index: usize) -> Option<NodeId>` (method, since 0.4.0): 그 자리의 자식. (범위 밖이면 None, 원본 getChild 의 null)
  - `child_index` usize: 자식 자리. (0 부터, 그리는 순서)
  - returns Option<NodeId>: 그 자리의 자식 핸들. 범위 밖이면 None.
- `pub fn has_child(&self, child_id: NodeId) -> bool` (method, since 0.4.0): 그 노드가 자식인지. (원본 hasChild)
  - `child_id` NodeId: 찾을 노드.
  - returns bool: 바로 아래 자식이면 true.
- `pub fn get_child_index(&self, child_id: NodeId) -> Option<usize>` (method, since 0.4.0): 자식의 자리. (그리는 순서의 번호, 자식이 아니면 None. 원본 getChildIndex 의 -1)
  - `child_id` NodeId: 찾을 자식.
  - returns Option<usize>: 그리는 순서의 번호. (0 부터) 바로 아래 자식이 아니면 None.
- `pub fn set_active(&mut self, is_active: bool)` (method, since 0.3.2): 활성화 설정. (꺼지면 tick 도 draw 도 하지 않는다)
  - `is_active` bool: 켤지. (false 면 이 노드와 자손이 tick, 그리기, 터치에서 빠진다)
- `pub fn is_active(&self) -> bool` (method, since 0.3.2): 활성화 여부.
  - returns bool: 자기 활성 플래그. (조상까지 보려면 NodeTree::is_active_in_hierarchy)
- `pub fn set_interactable(&mut self, is_interactable: bool)` (method, since 0.3.2): 터치를 받을지 설정.
  - `is_interactable` bool: 터치를 받을지. (기본 false)
- `pub fn is_interactable(&self) -> bool` (method, since 0.3.2): 터치를 받는지.
  - returns bool: 터치를 받으면 true.
- `pub fn set_gizmo_visible(&mut self, is_gizmo_visible: bool)` (method, since 0.3.2): 기즈모 표시 설정.
  - `is_gizmo_visible` bool: 기즈모(내용 테두리와 피봇 점)를 그릴지.
- `pub fn is_gizmo_visible(&self) -> bool` (method, since 0.3.2): 기즈모 표시 여부.
  - returns bool: 기즈모를 그리면 true.
- `pub fn set_opacity_layer(&mut self, is_opacity_layer: bool)` (method, since 0.4.0): 투명도 층 설정. (CSS opacity 처럼 투명도를 노드와 자손에 묶어 한 번에 얹을지)
  - 켜고 투명도(부모의 것을 곱한 값)가 1 보다 작으면 NodeTree 가 이 노드와 자손을 층에 모아 그렸다가 그 투명도로 한 번에 얹는다. (Graphic::begin_opacity_layer)
    겹친 자식끼리 비치지 않는다. 끄면(처음) 노드마다 투명도를 곱해 따로 얹는다.
  - `is_opacity_layer` bool: 투명도를 묶어 얹을지.

  예제: 반투명한 묶음 노드 (겹친 자식이 서로 비치지 않는다)

  ```rust
  use vanilla::NodeTree;
  
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let group_id = node_tree.create_child(root_id, "group");
  node_tree[group_id].set_local_opacity(0.5);
  node_tree[group_id].set_opacity_layer(true);
  assert!(node_tree[group_id].is_opacity_layer());
  ```

- `pub fn is_opacity_layer(&self) -> bool` (method, since 0.4.0): 투명도 층 여부.
  - returns bool: 투명도를 노드와 자손에 묶어 얹으면 true.
- `pub fn get_transform(&self) -> &NodeTransform` (method, since 0.3.2): 트랜스폼 반환.
  - returns &NodeTransform: 노드 트랜스폼.
- `pub fn get_transform_mut(&mut self) -> &mut NodeTransform` (method, since 0.3.2): 트랜스폼 반환. (변경용)
  - returns &mut NodeTransform: 노드 트랜스폼. (변경용)
- `pub fn set_local_position(&mut self, local_position: Vector2)` (method, since 0.3.2): 트랜스폼 바로가기.
  - 로컬 위치 설정. (NodeTransform::set_local_position)
  - `local_position` Vector2: 부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리.
- `pub fn get_local_position(&self) -> Vector2` (method, since 0.3.2): 로컬 위치 반환. (NodeTransform::get_local_position)
  - returns Vector2: 로컬 위치. (부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리)
- `pub fn set_local_scale(&mut self, local_scale: Vector2)` (method, since 0.3.2): 로컬 배율 설정. (NodeTransform::set_local_scale)
  - `local_scale` Vector2: 축마다 배율. (1 이 원래 크기, 음수면 그 축으로 뒤집혀 그려진다)
- `pub fn get_local_scale(&self) -> Vector2` (method, since 0.3.2): 로컬 배율 반환. (NodeTransform::get_local_scale)
  - returns Vector2: 로컬 배율.
- `pub fn set_local_rotation(&mut self, local_rotation: f64)` (method, since 0.3.2): 로컬 회전 설정. (NodeTransform::set_local_rotation)
  - `local_rotation` f64: 회전. (도, 양수면 화면에서 시계 방향)
- `pub fn get_local_rotation(&self) -> f64` (method, since 0.3.2): 로컬 회전 반환. (NodeTransform::get_local_rotation)
  - returns f64: 로컬 회전. (도)
- `pub fn set_local_opacity(&mut self, local_opacity: f64)` (method, since 0.3.2): 로컬 불투명도 설정. (NodeTransform::set_local_opacity, 자식에게 곱해져 내려간다)
  - `local_opacity` f64: 불투명도. (0 ~ 1, 밖의 값은 잘라 넣는다)
- `pub fn get_local_opacity(&self) -> f64` (method, since 0.3.2): 로컬 불투명도 반환. (NodeTransform::get_local_opacity)
  - returns f64: 로컬 불투명도. (0 ~ 1)
- `pub fn set_pivot(&mut self, pivot: Vector2)` (method, since 0.3.2): 피봇 설정. (NodeTransform::set_pivot)
  - `pivot` Vector2: 내용 크기 안의 기준점 비율. ((0, 0) 왼쪽 위, (1, 1) 오른쪽 아래, Pivot 상수)
- `pub fn get_pivot(&self) -> Vector2` (method, since 0.3.2): 피봇 반환. (NodeTransform::get_pivot)
  - returns Vector2: 피봇. (내용 크기 안의 비율)
- `pub fn set_content_size(&mut self, content_size: Vector2)` (method, since 0.3.2): 내용 크기 설정. (NodeTransform::set_content_size)
  - `content_size` Vector2: 내용 크기. (노드 좌표, 배율을 걸기 전)
- `pub fn get_content_size(&self) -> Vector2` (method, since 0.3.2): 내용 크기 반환. (NodeTransform::get_content_size)
  - returns Vector2: 내용 크기. (노드 좌표, 배율을 걸기 전)
- `pub fn copy_content_size_to(&self, target: &mut Vector2)` (method, since 0.4.0): 내용 크기를 target 에 적는다. (원본 copyContentSizeTo, 새 값을 만들지 않고 받을 자리에 적는다)
  - `target` &mut Vector2: 내용 크기를 받을 벡터. (노드 좌표, 배율을 걸기 전)

  예제

  ```rust
  use vanilla::{Vector2, WorldNode};
  
  let mut node = WorldNode::new("panel");
  node.set_content_size(Vector2::create(30.0, 40.0));
  let mut content_size = Vector2::zero();
  node.copy_content_size_to(&mut content_size);
  assert_eq!(content_size, Vector2::create(30.0, 40.0));
  ```

- `pub fn read_content_size(&self, out: &mut Vector2)` (method, since 0.4.0): 내용 크기를 out 에 적는다. (원본 readContentSize, get_content_size 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)
  - `out` &mut Vector2: 적을 자리.

  예제

  ```rust
  use vanilla::{Vector2, WorldNode};
  
  let mut node = WorldNode::new("panel");
  node.set_content_size(Vector2::create(30.0, 40.0));
  let mut out = Vector2::zero();
  node.read_content_size(&mut out);
  assert_eq!(out, Vector2::create(30.0, 40.0));
  ```

- `pub fn read_pivot(&self, out: &mut Vector2)` (method, since 0.4.0): 피봇을 out 에 적는다. (원본 readPivot, get_pivot 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)
  - `out` &mut Vector2: 적을 자리.

  예제

  ```rust
  use vanilla::{Vector2, WorldNode};
  
  let mut node = WorldNode::new("panel");
  node.set_pivot(Vector2::create(0.5, 1.0));
  let mut out = Vector2::zero();
  node.read_pivot(&mut out);
  assert_eq!(out, Vector2::create(0.5, 1.0));
  ```

- `pub fn read_local_position(&self, out: &mut Vector2)` (method, since 0.4.0): 로컬 위치를 out 에 적는다. (원본 readLocalPosition, get_local_position 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)
  - `out` &mut Vector2: 적을 자리.

  예제

  ```rust
  use vanilla::{Vector2, WorldNode};
  
  let mut node = WorldNode::new("panel");
  node.set_local_position(Vector2::create(3.0, 4.0));
  let mut out = Vector2::zero();
  node.read_local_position(&mut out);
  assert_eq!(out, Vector2::create(3.0, 4.0));
  ```

- `pub fn read_local_scale(&self, out: &mut Vector2)` (method, since 0.4.0): 로컬 배율을 out 에 적는다. (원본 readLocalScale, get_local_scale 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)
  - `out` &mut Vector2: 적을 자리.

  예제

  ```rust
  use vanilla::{Vector2, WorldNode};
  
  let mut node = WorldNode::new("panel");
  node.set_local_scale(Vector2::create(2.0, 0.5));
  let mut out = Vector2::zero();
  node.read_local_scale(&mut out);
  assert_eq!(out, Vector2::create(2.0, 0.5));
  ```

- `pub fn set_local_position_xy(&mut self, x: f64, y: f64)` (method, since 0.4.0): 로컬 위치 설정. (x, y 를 바로 받는다, NodeTransform::set_local_position_xy)
  - `x` f64: 로컬 위치 x.
  - `y` f64: 로컬 위치 y.
- `pub fn set_local_scale_xy(&mut self, x: f64, y: f64)` (method, since 0.4.0): 로컬 배율 설정. (x, y 를 바로 받는다, NodeTransform::set_local_scale_xy)
  - `x` f64: 가로 배율.
  - `y` f64: 세로 배율.
- `pub fn set_content_size_xy(&mut self, width: f64, height: f64)` (method, since 0.4.0): 내용 크기 설정. (너비, 높이를 바로 받는다, NodeTransform::set_content_size_xy)
  - `width` f64: 내용 너비.
  - `height` f64: 내용 높이.
- `pub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)` (method, since 0.4.0): 부모 영역 안의 사각형에 놓기. (NodeTransform::set_rect, 피봇이 어디든 왼쪽 위가 (x, y) 에 온다)
  - `x` f64: 왼쪽 위 x. (부모 내용 영역의 왼쪽 위 기준)
  - `y` f64: 왼쪽 위 y. (부모 내용 영역의 왼쪽 위 기준)
  - `width` f64: 내용 너비.
  - `height` f64: 내용 높이.
- `pub fn set_last_drawn_maximum_scale(&mut self, last_drawn_maximum_scale: f64, frame_number: u64)` (method, since 0.4.0): 지난번 그릴 때의 가장 큰 배율과 그 그리기 프레임 번호 기억. (NodeTree 가 push_transform 뒤에 부른다, 원본 setLastDrawnMaximumScale)
  - 그리기 프레임 번호는 Graphic::begin_frame_statistics 마다 하나씩 오른다. 지난 프레임에 그리지 않은 노드(화면 밖이라 하위 트리째 건너뛴 것)는 다음에 그릴 때 처음 그리는 것으로 본다.
  - `last_drawn_maximum_scale` f64: 변환의 가장 큰 배율. (0 이면 모른다)
  - `frame_number` u64: 그린 그리기 프레임 번호. (모르면 0)
- `pub fn get_last_drawn_maximum_scale(&self) -> f64` (method, since 0.4.0): 지난번 그릴 때 변환의 가장 큰 배율 반환.
  - returns f64: 가장 큰 배율. (0 이면 아직 모른다)
- `pub fn get_last_drawn_frame_number(&self) -> u64` (method, since 0.4.0): 지난번 그린 그리기 프레임 번호. (원본 getLastDrawnFrameNumber)
  - returns u64: set_last_drawn_maximum_scale 로 기억한 프레임 번호. (그린 적 없으면 0)

  예제: 기억한 배율과 프레임 번호 읽기

  ```rust
  use vanilla::WorldNode;
  
  let mut node = WorldNode::new("label");
  assert_eq!(node.get_last_drawn_frame_number(), 0);
  node.set_last_drawn_maximum_scale(2.0, 7);
  assert_eq!(node.get_last_drawn_maximum_scale(), 2.0);
  assert_eq!(node.get_last_drawn_frame_number(), 7);
  ```

- `pub fn mark_draw_bounds_dirty(&self)` (method, since 0.4.0): 이 노드의 하위 트리 그리기 경계가 바뀌었음을 알린다. (원본 TransformNode.markDrawBoundsDirty)
  - 내용 크기, 기즈모 표시, 컴포넌트 더하고 빼기는 엔진이 알아서 부른다. 컴포넌트의 그리는 사각형이 바뀌면 컴포넌트가 mark_drawn_rect_dirty 를 부른다.
  - 다음에 경계를 읽을 때(그리기 전) 이 노드와 조상이 다시 셈한다. 트리에 들지 않은 노드면 할 일이 없다.

  예제: 경계를 다시 셈하게 하기

  ```rust
  use vanilla::{NodeTree, Paint, Pivot};
  
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let node_id = node_tree.create_child(root_id, "panel");
  node_tree[node_id].set_pivot(Pivot::TOP_LEFT);
  node_tree[node_id].set_rect(10.0, 20.0, 100.0, 50.0);
  node_tree[node_id].mark_draw_bounds_dirty();
  node_tree[node_id].mark_parent_draw_bounds_dirty();
  ```

- `pub fn mark_parent_draw_bounds_dirty(&self)` (method, since 0.4.0): 부모의 하위 트리 그리기 경계가 바뀌었음을 알린다. (원본 TransformNode.markParentDrawBoundsDirty, 이 노드의 변환, 켜짐, 보임이 바뀌면 엔진이 알아서 부른다)
- `pub fn set_anchor(&mut self, anchor: Vector2)` (method, since 0.3.2): 앵커 설정. (NodeTransform::set_anchor)
  - `anchor` Vector2: 부모 내용 크기 안의 비율. (anchored_position 의 기준점, Pivot 상수)
- `pub fn get_anchor(&self) -> Vector2` (method, since 0.3.2): 앵커 반환. (NodeTransform::get_anchor)
  - returns Vector2: 앵커. (부모 내용 크기 안의 비율)
- `pub fn set_visible(&mut self, is_visible: bool)` (method, since 0.3.2): 보이기 설정. (NodeTransform::set_visible, 꺼도 tick 은 돈다)
  - `is_visible` bool: 그릴지. (false 면 이 노드와 자손을 그리지 않고 터치도 받지 않는다)
- `pub fn is_visible(&self) -> bool` (method, since 0.3.2): 보이기 여부. (NodeTransform::is_visible)
  - returns bool: 보이면 true.
- `pub fn add_component<T: Component + 'static>(&mut self, component: T) -> &mut T` (method, since 0.3.2): 컴포넌트 추가. (추가한 컴포넌트를 돌려준다)
  - 붙이기 전에 의존 컴포넌트(Component::require)가 없으면 만들어 붙이고, 그 뒤 attach 를 부른다.
  - attach_to_tree 는 부르지 않는다. 붙을 때 자식 노드를 만드는 컴포넌트는 NodeTree::add_component 로 붙인다.
  - `component` T: 붙일 컴포넌트.
  - returns &mut T: 붙인 컴포넌트. (변경용)

  예제: 붙이면서 돌려받은 컴포넌트를 바로 고치기

  ```rust
  use vanilla::{Color, Paint, WorldNode};
  
  let mut node = WorldNode::new("panel");
  let paint = node.add_component(Paint::new());
  paint.set_color(Color::create(1.0, 0.0, 0.0, 1.0));
  assert_eq!(node.get_component::<Paint>().expect("paint").get_color(), Color::create(1.0, 0.0, 0.0, 1.0));
  ```

- `pub fn get_or_add_component<T: Component + Default + 'static>(&mut self) -> &mut T` (method, since 0.4.0): 컴포넌트 반환. 없으면 기본값으로 만들어 붙이고 반환. (원본 getOrAddComponent)
  - returns &mut T: 그 타입의 첫 컴포넌트. (변경용) 없었으면 새로 붙인 기본값.

  예제: 두 번 불러도 하나만 붙는다

  ```rust
  use vanilla::{Paint, WorldNode};
  
  let mut node = WorldNode::new("node");
  node.get_or_add_component::<Paint>().set_round_size(8.0);
  assert_eq!(node.get_or_add_component::<Paint>().get_round_size(), 8.0);
  assert_eq!(node.get_components::<Paint>().len(), 1);
  ```

- `pub fn get_components<T: Component + 'static>(&self) -> Vec<&T>` (method, since 0.4.0): 그 타입의 컴포넌트 모두. (원본 getComponents)
  - returns Vec<&T>: 그 타입의 컴포넌트 모두. (붙인 차례) 없으면 빈 목록.
- `pub fn get_component<T: Component + 'static>(&self) -> Option<&T>` (method, since 0.3.2): 컴포넌트 반환. (그 타입의 첫 번째)
  - returns Option<&T>: 그 타입의 첫 컴포넌트. 없으면 None.
- `pub fn get_component_mut<T: Component + 'static>(&mut self) -> Option<&mut T>` (method, since 0.3.2): 컴포넌트 반환. (변경용, 그 타입의 첫 번째)
  - returns Option<&mut T>: 그 타입의 첫 컴포넌트. (변경용) 없으면 None.
- `pub fn has_component<T: Component + 'static>(&self) -> bool` (method, since 0.3.2): 컴포넌트가 있는지.
  - returns bool: 그 타입의 컴포넌트가 있으면 true.
- `pub fn remove_component<T: Component + 'static>(&mut self) -> usize` (method, since 0.3.2): 컴포넌트 제거. (그 타입 모두, 제거한 수)
  - 떼는 컴포넌트마다 detach 를 부른다.
  - returns usize: 뗀 컴포넌트 수. (없으면 0)

  예제: 그 타입을 모두 떼기

  ```rust
  use vanilla::{Paint, WorldNode};
  
  let mut node = WorldNode::new("node");
  node.add_component(Paint::new());
  node.add_component(Paint::new());
  assert_eq!(node.remove_component::<Paint>(), 2);
  assert!(!node.has_component::<Paint>());
  assert_eq!(node.remove_component::<Paint>(), 0);
  ```

- `pub fn get_all_components(&self) -> &Vec<Box<dyn Component>>` (method, since 0.3.2): 모든 컴포넌트.
  - returns &Vec<Box<dyn Component>>: 붙인 컴포넌트 모두. (붙인 차례)
- `pub fn push_transform(&self, graphic: &mut Graphic)` (method, since 0.3.2): 출력 상태 시작. (이동 → 회전 → 크기 → 피봇 보정 → 투명도 곱)
  - Graphic 상태를 하나 쌓은 뒤 건다. pop_transform 과 짝으로 부른다.
  - `graphic` &mut Graphic: 트랜스폼을 걸 Graphic.
- `pub fn push_component_transforms(&mut self, graphic: &mut Graphic)` (method, since 0.4.0): 컴포넌트의 노드 출력 상태 시작. (push_transform 바로 뒤, 켜진 컴포넌트를 붙인 차례로)
  - `graphic` &mut Graphic: 그리는 Graphic. (push_transform 이 걸린 상태)
- `pub fn pop_component_transforms(&mut self, graphic: &mut Graphic)` (method, since 0.4.0): 컴포넌트의 노드 출력 상태 끝. (pop_transform 바로 앞, 켜진 컴포넌트를 붙인 차례의 거꾸로)
  - `graphic` &mut Graphic: 그리는 Graphic.
- `pub fn draw_components(&mut self, graphic: &mut Graphic) -> (Option<f64>, bool)` (method, since 0.3.2): 컴포넌트 출력. (자식은 NodeTree 가 그린다)
  - 돌려주는 것: (Mask 가 있으면 둥근 크기, 화면 밖이라 건너뛰었는지)
  - 켜진 컴포넌트가 모두 그리는 사각형을 알려 주면(calculate_drawn_rect) 그 합을 지금 Graphic 변환으로 화면에 대 보고, 밖이면 그리지 않는다.
    하나라도 모르면 거르지 않는다. 걸러도 자식은 NodeTree 가 따로 판정한다.
  - `graphic` &mut Graphic: 그릴 Graphic. (push_transform 이 걸린 상태)
  - returns (Option<f64>, bool): (켜진 자르는 컴포넌트(Mask)의 귀퉁이 둥근 크기, 없으면 None. 화면 밖이라 그리지 않았으면 true)
- `pub fn draw_gizmos(&mut self, graphic: &mut Graphic)` (method, since 0.3.2): 기즈모 출력. (기즈모 표시가 켜진 컴포넌트의 draw_gizmos 다음에 content_size 테두리와 피봇 점)
  - 전역 알파를 잠깐 1 로 두고 그린 뒤 되돌린다. 테두리와 피봇 점은 '#00ff00', 테두리 굵기 1, 피봇 점 반지름 4.
  - `graphic` &mut Graphic: 그릴 Graphic. (push_transform 이 걸린 상태)
- `pub fn pop_transform(&self, graphic: &mut Graphic)` (method, since 0.3.2): 출력 상태 종료.
  - `graphic` &mut Graphic: push_transform 에서 쌓은 상태를 꺼낼 Graphic.
- `pub fn contains_point(&self, world_matrix: &TransformMatrix, view_position: Vector2) -> bool` (method, since 0.3.2): 점이 이 노드의 content_size 영역 안에 있는지. (world_matrix 는 이 노드까지 누적한 행렬)
  - `world_matrix` &TransformMatrix: 루트부터 이 노드까지 곱한 행렬. (NodeTree::calculate_world_matrix)
  - `view_position` Vector2: 볼 점. (뷰 좌표)
  - returns bool: 점이 내용 영역 (0, 0) ~ content_size 안이면 true. (경계 포함) 행렬을 뒤집을 수 없으면 false.

  예제: 왼쪽 위 피봇 노드의 영역 안과 밖

  ```rust
  use vanilla::{NodeTree, Pivot, Vector2};
  
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let node_id = node_tree.create_child(root_id, "button");
  node_tree[node_id].set_pivot(Pivot::TOP_LEFT);
  node_tree[node_id].set_rect(100.0, 100.0, 50.0, 30.0);
  let world_matrix = node_tree.calculate_world_matrix(node_id);
  assert!(node_tree[node_id].contains_point(&world_matrix, Vector2::create(120.0, 110.0)));
  assert!(!node_tree[node_id].contains_point(&world_matrix, Vector2::create(10.0, 10.0)));
  ```

