# core/node/transformnode (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/core/node/transformnode/

계층적 TRS 객체.

## TransformNode extends ComponentNode

계층적 TRS 객체.
- Transform 기능.
- 렌더링 기능. (컴포넌트 포함)

예제: 부모를 거친 자리, 회전, 크기 읽기

```js
import { TransformNode, Vector2 } from "./build/vanilla.js";

const parent = new TransformNode();
parent.setLocalPosition(Vector2.create(100, 50));
parent.setLocalRotation(90);
parent.setLocalScale(Vector2.create(2, 2));
const child = new TransformNode();
child.setLocalPositionXY(10, 0);
child.setLocalOpacity(0.5);
parent.addChild(child);
const position = child.getPosition();
const rotation = child.getRotation();
const scale = child.getScale();
const opacity = child.getOpacity();
console.log(position.x, position.y, rotation, scale.x, opacity);
```

- `constructor()` (constructor, since 0.0.9): 생성.
- `pushTransform(graphic)` (method, since 0.0.11): 출력 상태 시작.
  - `graphic` Graphic: 변환을 걸 그래픽.
- `applyLocalTransform(graphic)` (method, since 0.4.0): 로컬 위치, 회전, 크기를 graphic 의 변환에 건다.
  - 위치와 크기를 복제하지 않고 읽는다. getLocalPosition() / getLocalScale() 을 덮어쓴 하위 클래스면 그 함수로 읽는다.
  - `graphic` Graphic: 변환을 걸 그래픽.
- `draw(graphic)` (method, since 0.0.9): 출력.
  - `graphic` Graphic: 그릴 그래픽.
- `drawChildren(graphic)` (method, since 0.4.0): 자식 목록 출력. (자식 차례대로 Graphic.drawNode, draw 가 부른다)
  - 하위 트리 거르기가 켜졌으면 부모 좌표의 보이는 사각형(Graphic.readLocalVisibleBounds)으로 보이는 자식 범위를 이분 찾기로 좁혀 그 앞뒤 자식은 부르지 않는다.
    범위는 하위 트리 경계를 셀 때 적어 둔 자식 경계(앞에서부터 모은 가장 큰 아래와 오른쪽, 뒤에서부터 모은 가장 작은 위와 왼쪽)로 찾으므로 자식이 어떤 차례로 놓여도 맞고,
    줄처럼 차례대로 놓이면 보이는 줄만 남는다. 경계를 모르는 자식이 있으면 그 자식을 넘어 좁히지 않는다. 그리기 차례는 그대로다.
  - 그리는 동안 이 노드의 경계가 바뀌면(자식이 형제를 옮김 같은) 남은 자식을 모두 부른다.
  - 이 노드가 보이는 사각형 안에 다 든 하위 트리를 그리는 중이면(Graphic.isInsideVisibleBounds) 좁히지 않고 모두 부른다. (자식도 모두 보이는 사각형 안이다)
  - `graphic` Graphic: 그릴 그래픽.

  예제: draw 를 덮어쓴 노드가 자식을 그리기

  ```js
  import { Engine, EngineConfiguration, Scene, WorldNode, Paint, Colors, Rect, Vector2, Pivot } from "./build/vanilla.js";
  
  class FrameNode extends WorldNode {
  	draw(graphic) {
  		graphic.setFillColor(Colors.white);
  		graphic.drawRect(Rect.create(0, 0, 20, 20));
  		this.drawChildren(graphic);
  	}
  	calculateDrawnRect(rect) {
  		rect.position.set(0, 0);
  		rect.size.set(20, 20);
  		return true;
  	}
  }
  
  class MainScene extends Scene {
  	initialize(engine) {
  		super.initialize(engine);
  		const frameNode = new FrameNode();
  		frameNode.setPivot(Pivot.topLeft);
  		this.getRoot().addChild(frameNode);
  		const childNode = new WorldNode();
  		childNode.setPivot(Pivot.topLeft);
  		childNode.setRect(30, 0, 20, 20);
  		childNode.addComponent(Paint);
  		frameNode.addChild(childNode);
  	}
  	draw(graphic) {
  		super.draw(graphic);
  		console.log(graphic.getLastFrameCulledSubtreeCount());
  	}
  }
  
  const engineConfiguration = new EngineConfiguration();
  const engine = new Engine(engineConfiguration);
  engine.run(new MainScene());
  ```

- `drawGizmos(graphic)` (method, since 0.0.11): 출력.
  - `graphic` Graphic: 그릴 그래픽.
- `popTransform(graphic)` (method, since 0.0.11): 출력 상태 종료.
  - `graphic` Graphic: 상태를 되돌릴 그래픽.
- `setPosition(position)` (method, since 0.0.9): 글로벌 위치 설정.
  - `position` Vector2: 부모들을 거친 월드 자리. (부모의 위치, 회전, 크기를 거꾸로 걸어 로컬 위치로 바꾼다)
- `getPosition()` (method, since 0.0.9): 글로벌 위치 반환.
  - returns Vector2: 부모들을 거친 월드 자리. (부모가 없으면 로컬 위치)
- `readPosition(out)` (method, since 0.4.0): 글로벌 위치를 주어진 벡터에 쓰기. (getPosition 과 같은 값, 새 벡터를 짓지 않는다)
  - getPosition 이나 부모의 위치, 회전, 크기 읽기를 덮어쓴 하위 클래스면 그 함수로 읽는다. (그때는 그 함수가 짓는 만큼 할당한다)
  - `out` Vector2: 쓸 벡터.
  - returns Vector2: out.

  예제: 프레임마다 같은 벡터에 글로벌 위치 읽기

  ```js
  import { TransformNode, Vector2 } from "./vanilla.js";
  const parentNode = new TransformNode();
  parentNode.setLocalPosition(Vector2.create(10, 20));
  const childNode = new TransformNode();
  childNode.setParent(parentNode);
  childNode.setLocalPosition(Vector2.create(5, 0));
  const position = Vector2.create(0, 0);
  childNode.readPosition(position);
  if (position.x !== 15 || position.y !== 20) {
  	throw new Error("position failed");
  }
  ```

- `readScale(out)` (method, since 0.4.0): 글로벌 크기를 주어진 벡터에 쓰기. (getScale 과 같은 값, 새 벡터를 짓지 않는다)
  - getScale 이나 getLocalScale 을 덮어쓴 하위 클래스면 그 함수로 읽는다.
  - `out` Vector2: 쓸 벡터.
  - returns Vector2: out.

  예제: 프레임마다 같은 벡터에 글로벌 크기 읽기

  ```js
  import { TransformNode, Vector2 } from "./vanilla.js";
  const parentNode = new TransformNode();
  parentNode.setLocalScale(Vector2.create(2, 2));
  const childNode = new TransformNode();
  childNode.setParent(parentNode);
  childNode.setLocalScale(Vector2.create(0.5, 3));
  const scale = Vector2.create(0, 0);
  childNode.readScale(scale);
  if (scale.x !== 1 || scale.y !== 6) {
  	throw new Error("scale failed");
  }
  ```

- `readLocalPosition(out)` (method, since 0.4.0): 로컬 위치를 주어진 벡터에 쓰기. (getLocalPosition 과 같은 값, 복제하지 않는다)
  - `out` Vector2: 쓸 벡터.
  - returns Vector2: out.

  예제: 로컬 위치 읽기

  ```js
  import { TransformNode, Vector2 } from "./vanilla.js";
  const node = new TransformNode();
  node.setLocalPositionXY(3, 4);
  const position = node.readLocalPosition(Vector2.create(0, 0));
  if (position.x !== 3 || position.y !== 4) {
  	throw new Error("local position failed");
  }
  ```

- `readLocalScale(out)` (method, since 0.4.0): 로컬 크기를 주어진 벡터에 쓰기. (getLocalScale 과 같은 값, 복제하지 않는다)
  - `out` Vector2: 쓸 벡터.
  - returns Vector2: out.

  예제: 로컬 크기 읽기

  ```js
  import { TransformNode, Vector2 } from "./vanilla.js";
  const node = new TransformNode();
  node.setLocalScaleXY(2, 0.5);
  const scale = node.readLocalScale(Vector2.create(0, 0));
  if (scale.x !== 2 || scale.y !== 0.5) {
  	throw new Error("local scale failed");
  }
  ```

- `setScale(scale)` (method, since 0.0.9): 글로벌 크기 설정.
  - `scale` Vector2: 부모들을 거친 크기 배율. (부모 배율로 나눠 로컬 크기로 바꾸고, 부모 배율이 0 인 축은 0)
- `getScale()` (method, since 0.0.9): 글로벌 크기 반환.
  - returns Vector2: 부모들을 거친 크기 배율.
- `setRotation(rotation)` (method, since 0.0.9): 글로벌 회전 설정.
  - `rotation` number: 부모들을 거친 회전. (도)
- `getRotation()` (method, since 0.0.9): 글로벌 회전 반환.
  - returns number: 부모들을 거친 회전. (도)
- `setLocalPosition(position)` (method, since 0.0.9): 로컬 위치 설정.
  - `position` Vector2: 부모 기준 자리. (값을 옮겨 적고 받은 벡터는 들고 있지 않는다)
- `setLocalPositionXY(x, y)` (method, since 0.4.0): 로컬 위치 설정. (x, y 를 바로 받는다, Vector2 를 만들지 않는다)
  - getLocalPosition() / setLocalPosition() 을 덮어쓴 하위 클래스면 setLocalPosition 으로 넘긴다.
  - `x` number: 부모 기준 X.
  - `y` number: 부모 기준 Y.
- `getLocalPosition()` (method, since 0.0.9): 로컬 위치 반환.
  - returns Vector2: 로컬 위치의 사본.
- `setLocalScale(scale)` (method, since 0.0.9): 로컬 크기 설정.
  - `scale` Vector2: 로컬 크기 배율. (값을 옮겨 적는다)
- `setLocalScaleXY(x, y)` (method, since 0.4.0): 로컬 크기 설정. (x, y 를 바로 받는다, Vector2 를 만들지 않는다)
  - setLocalScale() 을 덮어쓴 하위 클래스면 setLocalScale 로 넘긴다.
  - `x` number: 로컬 가로 배율.
  - `y` number: 로컬 세로 배율.
- `getLocalScale()` (method, since 0.0.9): 로컬 크기 반환.
  - returns Vector2: 로컬 크기의 사본.
- `setLocalRotation(rotation)` (method, since 0.0.9): 로컬 회전 설정.
  - `rotation` number: 로컬 회전. (도)
- `getLocalRotation()` (method, since 0.0.9): 로컬 회전 반환.
  - returns number: 로컬 회전. (도)
- `setVisible(isVisible)` (method, since 0.4.0): 보이기 설정. (켜짐, 투명도와 따로 두는 플래그, 러스트 판 WorldNode::set_visible 과 같다)
  - 거짓이면 이 노드와 자손을 그리지 않고 TouchRaycaster 의 누름도 받지 않는다. 갱신(tick)은 그대로 돈다.
  - `isVisible` boolean: 거짓이면 숨긴다. (기본 참)

  예제: 부모를 숨기면 자식도 계층에서 안 보인다

  ```js
  import { WorldNode } from "./build/vanilla.js";
  
  const parentNode = new WorldNode();
  const childNode = new WorldNode();
  parentNode.addChild(childNode);
  parentNode.setVisible(false);
  console.log(parentNode.isVisible(), parentNode.isActive(), childNode.isVisible(), childNode.isVisibleInHierarchy());
  ```

- `isVisible()` (method, since 0.0.9): 보이기 플래그 반환. (setVisible 로 정한 값, 켜짐과 투명도는 보지 않는다, 계층 판정은 isVisibleInHierarchy)
  - returns boolean: 보이기 플래그. (기본 참)
- `isVisibleInHierarchy()` (method, since 0.0.9): 현재부터 루트까지 계층 전체의 가시 상태 반환. (자신과 조상 모두 켜져 있고, 보이기 플래그가 참이고, 로컬 투명도가 0 보다 커야 참)
  - returns boolean: 자신과 모든 부모가 보이면 참.

  예제: 꺼짐, 투명도 0, 숨김 가운데 하나라도 조상에 있으면 거짓

  ```js
  import { WorldNode } from "./build/vanilla.js";
  
  const parentNode = new WorldNode();
  const childNode = new WorldNode();
  parentNode.addChild(childNode);
  parentNode.setLocalOpacity(0);
  console.log(childNode.isActiveInHierarchy(), childNode.isVisibleInHierarchy());
  parentNode.setLocalOpacity(1);
  childNode.setVisible(false);
  console.log(parentNode.isVisibleInHierarchy(), childNode.isVisibleInHierarchy());
  ```

- `getOpacity()` (method, since 0.0.9): 글로벌 투명도 반환.
  - returns number: 부모들의 투명도를 곱한 투명도. (0 ~ 1)
- `setLocalOpacity(opacity)` (method, since 0.1.0): 로컬 투명도 설정.
  - `opacity` number: 로컬 투명도. (0 ~ 1 로 자른다)
- `getLocalOpacity()` (method, since 0.0.11): 로컬 투명도 반환.
  - returns number: 로컬 투명도. (0 ~ 1)
- `setLastDrawnMaximumScale(maximumScale, frameNumber = 0)` (method, since 0.4.0): 지난번 그릴 때 변환의 가장 큰 배율과 그 프레임 번호 설정. (Graphic.drawNode 가 부른다)
  - `maximumScale` number: 변환의 가장 큰 배율.
  - `frameNumber` number: 그린 프레임 번호. (Graphic 이 프레임마다 하나씩 올리는 번호, 기본 0)
- `getLastDrawnFrameNumber()` (method, since 0.4.0): 지난번 그린 프레임 번호 반환. (setLastDrawnMaximumScale 로 적은 번호, -1 이면 그린 적 없다)
  - returns number: 지난번 그린 프레임 번호.
- `getLastDrawnMaximumScale()` (method, since 0.4.0): 지난번 그릴 때 변환의 가장 큰 배율 반환. (0 이면 아직 모른다)
  - returns number: 변환의 가장 큰 배율. (0 이면 아직 모른다)
- `setGizmoVisible(isVisible)` (method, since 0.0.9): 기즈모 그리기 여부 설정.
  - `isVisible` boolean: 참이면 기즈모를 그린다.
- `isGizmoVisible()` (method, since 0.0.9): 기즈모 그리기 여부 반환.
  - returns boolean: 기즈모를 그리면 참.
- `setOpacityLayer(isOpacityLayer)` (method, since 0.4.0): 투명도 층 설정. (CSS opacity 처럼 투명도를 노드와 자손에 묶어 한 번에 얹을지)
  - 켜고 투명도(부모의 것을 곱한 값)가 1 보다 작으면 이 노드와 자손을 층에 모아 그렸다가 그 투명도로 한 번에 얹는다. (Graphic.beginOpacityLayer)
    겹친 자식끼리 비치지 않는다. 끄면(처음) 노드마다 투명도를 곱해 따로 얹는다.
  - `isOpacityLayer` boolean: 투명도를 묶어 얹을지.

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

  ```js
  import { WorldNode } from "./build/vanilla.js";
  
  const groupNode = new WorldNode();
  groupNode.setLocalOpacity(0.5);
  groupNode.setOpacityLayer(true);
  console.log(groupNode.isOpacityLayer());
  ```

- `isOpacityLayer()` (method, since 0.4.0): 투명도 층 여부 반환.
  - returns boolean: 투명도를 노드와 자손에 묶어 얹으면 참.
- `setParent(parent)` (method, since 0.4.0): 부모 설정. (오버라이드: 옛 부모와 새 부모의 하위 트리 그리기 경계가 바뀐다)
  - `parent` Node | null: 새 부모. (null 이면 떼어 낸다)
  - returns boolean: 붙였거나 떼었으면 참. (자기 자손을 부모로 주면 거짓)
- `setActive(active)` (method, since 0.4.0): 켜짐 설정. (오버라이드: 꺼진 자식은 부모의 하위 트리 그리기 경계에 들지 않는다)
  - `active` boolean: 켤지.
- `markDrawBoundsDirty()` (method, since 0.4.0): 하위 트리 그리기 경계가 바뀌었음을 표시. (이 노드와 조상이 다음에 그릴 때 경계를 다시 셈한다)
  - 변환, 내용 크기, 자식 더함과 뺌, 켜짐과 보임, 컴포넌트가 바뀌면 엔진이 부른다. 조상으로 번지다 이미 표시된 노드에서 멈춘다.
  - draw 를 덮어쓴 노드는 calculateDrawnRect 가 알리는 사각형이 바뀔 때 부른다.

  예제: 스스로 그리는 노드가 그리는 곳이 바뀌었음을 알리기

  ```js
  import { WorldNode, Rect, Colors } from "./build/vanilla.js";
  
  class Ripple extends WorldNode {
  	radius = 10;
  	setRadius(radius) {
  		this.radius = radius;
  		this.markDrawBoundsDirty();
  	}
  	draw(graphic) {
  		super.draw(graphic);
  		graphic.setFillColor(Colors.white);
  		graphic.drawRect(Rect.create(-this.radius, -this.radius, this.radius * 2, this.radius * 2));
  	}
  	calculateDrawnRect(rect) {
  		rect.position.set(-this.radius, -this.radius);
  		rect.size.set(this.radius * 2, this.radius * 2);
  		return true;
  	}
  }
  
  const ripple = new Ripple();
  ripple.setRadius(40);
  const drawBounds = Rect.zero();
  console.log(ripple.readSubtreeDrawBounds(drawBounds), drawBounds.size.x);
  ```

- `markParentDrawBoundsDirty()` (method, since 0.4.0): 부모의 하위 트리 그리기 경계가 바뀌었음을 표시. (이 노드의 변환, 켜짐, 보임이 바뀌면 이 노드의 경계는 그대로이고 부모의 경계가 바뀐다)
- `readSubtreeDrawBounds(rect)` (method, since 0.4.0): 하위 트리 그리기 경계 읽기. (이 노드의 내용 좌표, pushTransform 을 건 뒤의 좌표, 알면 true)
  - 이 노드와 켜지고 보이는 자손이 그리는 곳을 모두 품는 사각형이다. 크기가 0 이면 아무것도 그리지 않는다.
  - 바뀐 때만 다시 셈하고(calculateSubtreeDrawBounds) 그 밖에는 셈해 둔 것을 준다. 그리기 순회가 이 사각형이 화면과 자르기 밖이면 하위 트리를 통째로 건너뛴다.
  - 어디에 그리는지 모르는 것(경계를 알리지 않는 컴포넌트, draw 를 덮어쓰고 calculateDrawnRect 를 알리지 않는 노드)이 들면 false.
  - `rect` Rect: 경계를 적을 곳.
  - returns boolean: 경계를 알면 참. (모르면 rect 를 건드리지 않는다)

  예제: 줄 노드의 하위 트리 경계 읽기

  ```js
  import { WorldNode, Paint, Rect, Vector2, Pivot } from "./build/vanilla.js";
  
  const rowNode = new WorldNode();
  rowNode.setPivot(Pivot.topLeft);
  rowNode.setContentSize(Vector2.create(300, 40));
  rowNode.addComponent(Paint);
  const iconNode = new WorldNode();
  iconNode.setPivot(Pivot.topLeft);
  iconNode.setRect(-20, 4, 32, 32);
  iconNode.addComponent(Paint);
  rowNode.addChild(iconNode);
  const drawBounds = Rect.zero();
  const isKnown = rowNode.readSubtreeDrawBounds(drawBounds);
  console.log(isKnown, drawBounds.position.x, drawBounds.size.x);
  ```

- `readParentDrawBounds(rect)` (method, since 0.4.0): 부모가 셈해 둔 이 노드의 하위 트리 그리기 경계 읽기. (부모의 내용 좌표, 이 노드의 변환을 건 경계 상자, 맞으면 true)
  - 부모가 하위 트리 경계를 셈할 때(calculateSubtreeDrawBounds) 자식마다 옮겨 적어 둔 것이다. 이 노드의 변환이나 경계가 바뀌면 부모가 다시 셈하므로 그때까지 그대로 쓴다.
  - 그리기 순회가 부모의 변환 아래에서 이 사각형을 먼저 보아, 부모 좌표의 보이는 사각형 밖이면 이 노드에 변환을 걸지 않고 건너뛴다. (스크롤은 부모의 변환만 바뀌므로 자식마다 다시 셈하지 않는다)
  - 부모가 아직 셈하지 않았거나 셈한 뒤 바뀌었으면(다시 셈할 차례), 이 노드가 어디에 그리는지 모르거나 놓이는 곳을 모르면 false.
  - `rect` Rect: 경계를 적을 곳. (부모의 내용 좌표, 크기가 0 이면 아무것도 그리지 않는다)
  - returns boolean: 맞는 경계가 있으면 참. (없으면 rect 를 건드리지 않는다)

  예제: 부모가 셈해 둔 줄의 경계를 부모 좌표로 읽기

  ```js
  import { WorldNode, Paint, Rect, Vector2, Pivot } from "./build/vanilla.js";
  
  const listNode = new WorldNode();
  listNode.setPivot(Pivot.topLeft);
  const rowNode = new WorldNode();
  rowNode.setPivot(Pivot.topLeft);
  rowNode.setRect(0, 120, 300, 40);
  rowNode.addComponent(Paint);
  listNode.addChild(rowNode);
  const drawBounds = Rect.zero();
  console.log(rowNode.readParentDrawBounds(drawBounds));
  listNode.readSubtreeDrawBounds(drawBounds);
  console.log(rowNode.readParentDrawBounds(drawBounds), drawBounds.position.y, drawBounds.size.y);
  ```

- `calculateDrawnRect(rect)` (method, since 0.4.0): 노드 스스로(컴포넌트와 자식 밖에) 그리는 사각형을 rect 에 적기. (내용 영역의 왼쪽 위가 원점, 알면 true)
  - draw 를 덮어쓰지 않은 노드는 스스로 그리는 것이 없으므로 크기 0 을 적고 true.
  - draw 를 덮어쓴 노드는 어디에 그리는지 모르므로 false. (그 노드의 조상은 하위 트리 그리기를 건너뛰지 않는다)
    덮어쓴 노드가 이 함수도 덮어써 그리는 사각형을 알리면 건너뛸 수 있다. 사각형이 바뀌면 markDrawBoundsDirty 를 부른다.
  - `rect` Rect: 그리는 사각형을 적을 곳. (노드 내용 영역의 왼쪽 위가 원점)
  - returns boolean: 알면 참.

  예제: 그리기를 덮어쓰지 않은 노드는 스스로 그리는 것이 없다

  ```js
  import { TransformNode, Rect } from "./build/vanilla.js";
  
  const node = new TransformNode();
  const drawnRect = Rect.zero();
  console.log(node.calculateDrawnRect(drawnRect), drawnRect.size.x);
  ```

- `transformDrawBoundsToParent(rect)` (method, since 0.4.0): 하위 트리 그리기 경계를 부모의 내용 좌표로 옮기기. (알면 true, calculateSubtreeDrawBounds 가 자식마다 부른다)
  - TransformNode 는 내용 영역과 피봇이 없어 어디에 놓이는지 정하지 않으므로 false. (WorldNode, UINode 가 저마다 놓는 꼴로 덮어쓴다)
  - `rect` Rect: 옮길 경계. (이 노드의 내용 좌표, 부모의 내용 좌표로 바뀐 경계 상자를 적는다)
  - returns boolean: 놓이는 곳을 알면 참.

  예제: 놓는 꼴을 모르는 노드

  ```js
  import { TransformNode, Rect } from "./build/vanilla.js";
  
  const node = new TransformNode();
  console.log(node.transformDrawBoundsToParent(Rect.create(0, 0, 10, 10)));
  ```

- `transformLocalRectToParent(rect, pivotOffsetX, pivotOffsetY, translateX, translateY)` (method, since 0.4.0): 사각형을 이 노드의 회전과 배율로 돌리고 키워 부모 좌표에 옮긴 경계 상자로 바꾸기. (transformDrawBoundsToParent 가 쓴다)
  - 차례: 기준점만큼 당김 → 배율 → 회전 → 옮김. (pushTransform 의 옮김, 회전, 배율과 같은 결과)
  - `rect` Rect: 바꿀 사각형. (이 노드의 내용 좌표, 바뀐 경계 상자를 적는다)
  - `pivotOffsetX` number: 기준점의 가로 자리. (내용 좌표, 이만큼 당긴 뒤 키운다)
  - `pivotOffsetY` number: 기준점의 세로 자리.
  - `translateX` number: 부모 좌표로 옮기는 가로 거리.
  - `translateY` number: 부모 좌표로 옮기는 세로 거리.

  예제: 두 배로 키우고 옮긴 사각형

  ```js
  import { TransformNode, Rect, Vector2 } from "./build/vanilla.js";
  
  const node = new TransformNode();
  node.setLocalScale(Vector2.create(2, 2));
  const rect = Rect.create(0, 0, 10, 10);
  node.transformLocalRectToParent(rect, 5, 5, 100, 0);
  console.log(rect.position.x, rect.size.x);
  ```

- `calculateSubtreeDrawBounds(rect)` (method, since 0.4.0): 하위 트리 그리기 경계 셈하기. (자기 그림과 켜지고 보이는 자식들 경계의 합, readSubtreeDrawBounds 가 바뀐 때만 부른다, 알면 true)
  - 자기 그림: calculateDrawnRect 와 켜진 컴포넌트. 내용 영역 안에서만 그리는 컴포넌트(Component.isDrawnInsideContent)는 내용 영역을 한 단위씩 넓혀 보고,
    밖까지 그리는 컴포넌트는 Component.calculateDrawnRect 로 본다. 그리지 않는 컴포넌트(draw 를 덮어쓰지 않은 것)는 빼고,
    모르는 컴포넌트가 하나라도 있으면 모른다. 기즈모를 그리는 노드와 내용 크기를 읽을 수 없는 노드(내용 영역 안 컴포넌트가 있을 때)도 모른다.
  - 자식: 자식의 하위 트리 경계를 자식이 옮긴(transformDrawBoundsToParent) 이 노드의 내용 좌표 경계 상자. 놓이는 곳을 모르는 자식이 있으면 모른다.
  - 모르더라도 켜지고 보이는 자식의 경계는 모두 읽는다. (자식이 셈해 두어야 자손이 바뀐 것이 이 노드까지 번진다)
  - 부모 좌표로 옮긴 자식의 경계는 자식에 적어 둔다. (readParentDrawBounds, 그리기 순회가 자식에 변환을 걸기 전에 본다, 이 노드가 다시 셈할 때까지 맞다)
  - 마스크로 자식을 잘라도 경계는 줄이지 않는다. (넉넉하게 본다)
  - `rect` Rect: 셈한 경계를 적을 곳. (이 노드의 내용 좌표)
  - returns boolean: 경계를 알면 참.
