vanilladocs
vanillapunch.com
API / core/node/worldnode

core/node/worldnode

월드 노드.

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

World node.

  • Parent/child hierarchy + activation (the original Node)
  • Holds components + tick (the original ComponentNode)
  • Local TRS + recursive rendering (the original TransformNode)
  • pivot / anchor / content_size + touch (the original WorldNode)
  • Nodes live in the scene's NodeTree storage, and parents and children are linked by handles (NodeId). Changing the tree (attaching children, removing, finding) and iterating the tree (tick, draw, touch) are done by NodeTree.

NodeTransformstruct traits Clone, Debug, Default

소스source

노드 트랜스폼. (컴포넌트가 tick / draw 에서 받아 읽고 바꾸는 노드 상태)

  • local_position 은 부모 영역 안에서 자기 피봇 점의 좌표다. (anchor 는 anchored_position 계산용)
  • local_rotation 은 도 단위. (원본과 같음)

Node transform. (node state that components read and change on tick / draw)

  • local_position is the coordinate of its own pivot point within the parent area. (anchor is for computing anchored_position)
  • local_rotation is in degrees. (same as the original)
예제Example가운데 피봇 노드를 사각형에 놓고 경계 보기Place a center-pivot node on a rectangle and check its bounds
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));
생성자constructorpub fn new() -> NodeTransform#0.3.2 부터since 0.3.2소스source

생성.

Constructor.

반환ReturnsNodeTransform 위치 (0, 0), 배율 1, 회전 0, 불투명도 1, 내용 크기 0, 피봇과 앵커는 가운데, 보이는 트랜스폼.Position (0, 0), scale 1, rotation 0, opacity 1, content size 0, pivot and anchor at the center, a visible transform.

메서드methodpub fn set_local_position(&mut self, local_position: Vector2)#0.3.2 부터since 0.3.2소스source

로컬 위치 설정.

Sets the local position.

local_positionVector2
부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리.Position of the pivot point measured from the top-left of the parent's content area.
메서드methodpub fn get_local_position(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

로컬 위치 반환.

Returns the local position.

반환ReturnsVector2 로컬 위치. (부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리)Local position. (position of the pivot point measured from the top-left of the parent's content area)

메서드methodpub fn set_local_scale(&mut self, local_scale: Vector2)#0.3.2 부터since 0.3.2소스source

로컬 크기 설정.

Sets the local scale.

local_scaleVector2
축마다 배율. (1 이 원래 크기, 음수면 그 축으로 뒤집혀 그려진다)Scale per axis. (1 is the original size, negative draws it flipped on that axis)
메서드methodpub fn get_local_scale(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

로컬 크기 반환.

Returns the local scale.

반환ReturnsVector2 로컬 배율.Local scale.

메서드methodpub fn set_local_rotation(&mut self, local_rotation: f64)#0.3.2 부터since 0.3.2소스source

로컬 회전 설정. (도)

Sets the local rotation. (degrees)

local_rotationf64
회전. (도, 양수면 화면에서 시계 방향)Rotation. (degrees, positive is clockwise on screen)
메서드methodpub fn get_local_rotation(&self) -> f64#0.3.2 부터since 0.3.2소스source

로컬 회전 반환. (도)

Returns the local rotation. (degrees)

반환Returnsf64 로컬 회전. (도)Local rotation. (degrees)

메서드methodpub fn set_local_opacity(&mut self, local_opacity: f64)#0.3.2 부터since 0.3.2소스source

로컬 투명도 설정. (자식에게 곱해져 내려간다)

Sets the local opacity. (multiplied down into the children)

local_opacityf64
불투명도. (0 ~ 1, 밖의 값은 잘라 넣는다)Opacity. (0 ~ 1, values outside are clamped)
메서드methodpub fn get_local_opacity(&self) -> f64#0.3.2 부터since 0.3.2소스source

로컬 투명도 반환.

Returns the local alpha.

반환Returnsf64 로컬 불투명도. (0 ~ 1)Local opacity. (0 ~ 1)

메서드methodpub fn set_pivot(&mut self, pivot: Vector2)#0.3.2 부터since 0.3.2소스source

피봇 설정. (content_size 안에서 기준점의 비율, 기본 가운데)

Sets the pivot. (ratio of the reference point within content_size, default center)

pivotVector2
내용 크기 안의 기준점 비율. ((0, 0) 왼쪽 위, (1, 1) 오른쪽 아래, Pivot 상수)Ratio of the reference point within the content size. ((0, 0) top-left, (1, 1) bottom-right, Pivot constants)
메서드methodpub fn get_pivot(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

피봇 반환.

Returns the pivot.

반환ReturnsVector2 피봇. (내용 크기 안의 비율)Pivot. (ratio within the content size)

메서드methodpub fn set_content_size(&mut self, content_size: Vector2)#0.3.2 부터since 0.3.2소스source

컨텐츠 크기 설정.

Sets the content size.

content_sizeVector2
내용 크기. (노드 좌표, 배율을 걸기 전)Content size. (node coordinates, before scale is applied)
메서드methodpub fn get_content_size(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

컨텐츠 크기 반환.

Returns the content size.

반환ReturnsVector2 내용 크기. (노드 좌표, 배율을 걸기 전)Content size. (node coordinates, before scale is applied)

메서드methodpub fn set_local_position_xy(&mut self, x: f64, y: f64)#0.4.0 부터since 0.4.0소스source

로컬 위치 설정. (x, y 를 바로 받는다, 원본 setLocalPositionXY)

Sets the local position. (takes x, y directly, the original setLocalPositionXY)

xf64
로컬 위치 x.Local position x.
yf64
로컬 위치 y.Local position y.
메서드methodpub fn set_local_scale_xy(&mut self, x: f64, y: f64)#0.4.0 부터since 0.4.0소스source

로컬 크기 설정. (x, y 를 바로 받는다, 원본 setLocalScaleXY)

Sets the local scale. (takes x, y directly, the original setLocalScaleXY)

xf64
가로 배율.Horizontal scale.
yf64
세로 배율.Vertical scale.
메서드methodpub fn set_content_size_xy(&mut self, width: f64, height: f64)#0.4.0 부터since 0.4.0소스source

컨텐츠 크기 설정. (너비, 높이를 바로 받는다, 원본 setContentSizeXY)

Sets the content size. (takes width, height directly, the original setContentSizeXY)

widthf64
내용 너비.Content width.
heightf64
내용 높이.Content height.
메서드methodpub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)#0.4.0 부터since 0.4.0소스source

부모 영역 안의 사각형에 놓기. (x, y 는 이 노드의 왼쪽 위, 부모 내용 영역의 왼쪽 위가 원점, 원본 setRect)

  • 내용 크기를 width, height 로 두고, 피봇이 어디든 왼쪽 위가 (x, y) 에 오게 로컬 위치를 정한다. (x + width * pivot.x, y + height * pivot.y)
  • 앵커는 바꾸지 않는다. 로컬 위치는 앵커와 무관하게 부모 왼쪽 위 기준이라 앵커가 어디든 같은 자리다.
  • 로컬 배율과 회전은 보지 않는다. (배율 1, 회전 0 일 때 화면에서도 그 사각형이다)

Places it on a rectangle within the parent area. (x, y is this node's top-left, origin at the top-left of the parent's content area, the original setRect)

  • Sets the content size to width, height and sets the local position so the top-left lands on (x, y) wherever the pivot is. (x + width * pivot.x, y + height * pivot.y)
  • Does not change the anchor. The local position is relative to the parent's top-left regardless of the anchor, so it is the same place wherever the anchor is.
  • Ignores the local scale and rotation. (with scale 1 and rotation 0 it is that rectangle on screen too)
xf64
왼쪽 위 x. (부모 내용 영역의 왼쪽 위 기준)Top-left x. (relative to the top-left of the parent's content area)
yf64
왼쪽 위 y. (부모 내용 영역의 왼쪽 위 기준)Top-left y. (relative to the top-left of the parent's content area)
widthf64
내용 너비.Content width.
heightf64
내용 높이.Content height.
메서드methodpub fn set_anchor(&mut self, anchor: Vector2)#0.3.2 부터since 0.3.2소스source

앵커 설정. (부모 content_size 안의 비율)

Sets the anchor. (ratio within the parent's content_size)

anchorVector2
부모 내용 크기 안의 비율. (anchored_position 의 기준점, Pivot 상수)Ratio within the parent's content size. (reference point of anchored_position, Pivot constants)
메서드methodpub fn get_anchor(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

앵커 반환.

Returns the anchor.

반환ReturnsVector2 앵커. (부모 내용 크기 안의 비율)Anchor. (ratio within the parent's content size)

메서드methodpub fn set_anchored_position(&mut self, anchored_position: Vector2, parent_content_size: Vector2)#0.3.2 부터since 0.3.2소스source

앵커 기준 위치 설정. (부모 content_size 를 알아야 한다)

  • 로컬 위치를 (부모 내용 크기 x 앵커) + anchored_position 으로 둔다.

Sets the anchor-relative position. (needs the parent's content_size)

  • Sets the local position to (parent content size x anchor) + anchored_position.
anchored_positionVector2
앵커 점에서 본 위치.Position measured from the anchor point.
parent_content_sizeVector2
부모의 내용 크기.The parent's content size.
예제Example부모 오른쪽 아래에서 20 씩 안쪽에 놓기Place it 20 inward from the parent's bottom-right
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));
메서드methodpub fn get_anchored_position(&self, parent_content_size: Vector2) -> Vector2#0.3.2 부터since 0.3.2소스source

앵커 기준 위치 반환.

Returns the anchor-relative position.

parent_content_sizeVector2
부모의 내용 크기.The parent's content size.

반환ReturnsVector2 앵커 점(부모 내용 크기 x 앵커)에서 본 로컬 위치.Local position measured from the anchor point (parent content size x anchor).

메서드methodpub fn set_visible(&mut self, is_visible: bool)#0.3.2 부터since 0.3.2소스source

보이기 설정. (꺼도 tick 은 돈다. 원본 isVisible)

Sets visibility. (tick still runs when off. The original isVisible)

is_visiblebool
그릴지. (false 면 이 노드와 자손을 그리지 않고 터치도 받지 않는다)Whether to draw. (if false, this node and its descendants are not drawn and receive no touches)
메서드methodpub fn is_visible(&self) -> bool#0.3.2 부터since 0.3.2소스source

보이기 여부.

Whether visible.

반환Returnsbool 보이면 true.True if visible.

메서드methodpub fn calculate_local_matrix(&self) -> TransformMatrix#0.3.2 부터since 0.3.2소스source

로컬 변환 행렬. (push_transform 과 같은 순서: 이동 → 회전 → 크기 → 피봇 보정)

Local transform matrix. (same order as push_transform: translate → rotate → scale → pivot correction)

반환ReturnsTransformMatrix 이 노드 내용 좌표의 점을 부모 내용 좌표로 옮기는 행렬.Matrix that maps a point in this node's content coordinates to the parent's content coordinates.

메서드methodpub fn get_local_bounds(&self) -> Rect#0.3.2 부터since 0.3.2소스source

부모 영역에서 본 경계 사각형. (회전이 없을 때 정확하다. 충돌 검사 등)

Bounding rectangle seen from the parent area. (exact when there is no rotation. For collision tests and such)

반환ReturnsRect 부모 내용 좌표의 경계 사각형. (배율은 절댓값으로 걸고 회전은 넣지 않는다)Bounding rectangle in the parent's content coordinates. (scale is applied as an absolute value and rotation is not included)

WorldNodestruct

짝Counterpart: vanilla.js WorldNode소스source

월드 노드.

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

World node.

  • Holds the name, active state, touch receiving, transform, component list, and parent and child handles.
예제Example노드 하나에 컴포넌트를 붙이고 찾기Add and find components on a node
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());
생성자constructorpub fn new(name: &str) -> WorldNode#0.3.2 부터since 0.3.2소스source

생성. (트리에 넣을 때는 NodeTree::create_node 를 쓴다)

Creates. (use NodeTree::create_node to put it in a tree)

name&str
노드 이름. (이름으로 찾기에 쓴다)Node name. (used for finding by name)

반환ReturnsWorldNode 부모가 없고 활성인 새 노드. (터치는 받지 않는다)A new active node with no parent. (does not receive touches)

짝Counterpart: vanilla.js WorldNode.constructor

메서드methodpub fn get_instance_id(&self) -> u64#0.3.2 부터since 0.3.2소스source

인스턴스 식별자.

Instance identifier.

반환Returnsu64 만들 때 받은 번호. (1 부터, 노드마다 겹치지 않는다)Number assigned at creation. (from 1, unique per node)

짝Counterpart: vanilla.js Object.getInstanceId

메서드methodpub fn set_name(&mut self, name: &str)#0.3.2 부터since 0.3.2소스source

이름 설정.

Sets the name.

name&str
새 이름.New name.

짝Counterpart: vanilla.js Node.setName

메서드methodpub fn get_name(&self) -> &str#0.3.2 부터since 0.3.2소스source

이름 반환.

Returns the name.

반환Returns&str 노드 이름.Node name.

짝Counterpart: vanilla.js Node.getName

메서드methodpub fn get_parent_id(&self) -> Option<NodeId>#0.3.2 부터since 0.3.2소스source

부모 핸들. (루트이거나 아직 붙지 않았으면 None)

Parent handle. (None if it is the root or not attached yet)

반환ReturnsOption<NodeId> 부모 핸들. 루트이거나 아직 붙지 않았으면 None.Parent handle. None if it is the root or not attached yet.

메서드methodpub fn get_child_ids(&self) -> &[NodeId]#0.3.2 부터since 0.3.2소스source

자식 핸들 목록. (그리는 순서)

Child handle list. (draw order)

반환Returns&[NodeId] 자식 핸들 목록. (앞이 먼저 그려진다)Child handle list. (earlier is drawn first)

메서드methodpub fn get_child_count(&self) -> usize#0.3.2 부터since 0.3.2소스source

자식 수.

Child count.

반환Returnsusize 바로 아래 자식 수.Number of direct children.

짝Counterpart: vanilla.js Node.getChildCount

메서드methodpub fn is_root(&self) -> bool#0.4.0 부터since 0.4.0소스source

부모가 없는지. (원본 isRoot, 트리의 루트와 아직 붙이지 않은 노드)

Whether it has no parent. (the original isRoot, the tree's root and nodes not attached yet)

반환Returnsbool 부모가 없으면 true.True if it has no parent.

짝Counterpart: vanilla.js Node.isRoot

메서드methodpub fn is_leaf(&self) -> bool#0.4.0 부터since 0.4.0소스source

자식이 없는지. (원본 isLeaf)

Whether it has no children. (the original isLeaf)

반환Returnsbool 자식이 없으면 true.True if it has no children.

짝Counterpart: vanilla.js Node.isLeaf

메서드methodpub fn has_parent(&self) -> bool#0.4.0 부터since 0.4.0소스source

부모가 있는지. (원본 hasParent)

Whether it has a parent. (the original hasParent)

반환Returnsbool 부모가 있으면 true.True if it has a parent.

짝Counterpart: vanilla.js Node.hasParent

메서드methodpub fn get_child(&self, child_index: usize) -> Option<NodeId>#0.4.0 부터since 0.4.0소스source

그 자리의 자식. (범위 밖이면 None, 원본 getChild 의 null)

The child at that position. (None if out of range, the original getChild's null)

child_indexusize
자식 자리. (0 부터, 그리는 순서)Child position. (from 0, draw order)

반환ReturnsOption<NodeId> 그 자리의 자식 핸들. 범위 밖이면 None.Child handle at that position. None if out of range.

짝Counterpart: vanilla.js Node.getChild

메서드methodpub fn has_child(&self, child_id: NodeId) -> bool#0.4.0 부터since 0.4.0소스source

그 노드가 자식인지. (원본 hasChild)

Whether that node is a child. (the original hasChild)

child_idNodeId
찾을 노드.Node to find.

반환Returnsbool 바로 아래 자식이면 true.True if it is a direct child.

짝Counterpart: vanilla.js Node.hasChild

메서드methodpub fn get_child_index(&self, child_id: NodeId) -> Option<usize>#0.4.0 부터since 0.4.0소스source

자식의 자리. (그리는 순서의 번호, 자식이 아니면 None. 원본 getChildIndex 의 -1)

Position of the child. (index in draw order, None if not a child. The original getChildIndex's -1)

child_idNodeId
찾을 자식.Child to find.

반환ReturnsOption<usize> 그리는 순서의 번호. (0 부터) 바로 아래 자식이 아니면 None.Index in draw order. (from 0) None if not a direct child.

짝Counterpart: vanilla.js Node.getChildIndex

메서드methodpub fn set_active(&mut self, is_active: bool)#0.3.2 부터since 0.3.2소스source

활성화 설정. (꺼지면 tick 도 draw 도 하지 않는다)

Sets active. (when off, neither tick nor draw runs)

is_activebool
켤지. (false 면 이 노드와 자손이 tick, 그리기, 터치에서 빠진다)Whether to turn it on. (if false, this node and its descendants are left out of tick, drawing and touch)

짝Counterpart: vanilla.js TransformNode.setActive

메서드methodpub fn is_active(&self) -> bool#0.3.2 부터since 0.3.2소스source

활성화 여부.

Whether enabled.

반환Returnsbool 자기 활성 플래그. (조상까지 보려면 NodeTree::is_active_in_hierarchy)Own active flag. (use NodeTree::is_active_in_hierarchy to include ancestors)

짝Counterpart: vanilla.js Node.isActive

메서드methodpub fn set_interactable(&mut self, is_interactable: bool)#0.3.2 부터since 0.3.2소스source

터치를 받을지 설정.

Sets whether to receive touches.

is_interactablebool
터치를 받을지. (기본 false)Whether to receive touches. (default false)

짝Counterpart: vanilla.js WorldNode.setInteractable

메서드methodpub fn is_interactable(&self) -> bool#0.3.2 부터since 0.3.2소스source

터치를 받는지.

Whether it receives touches.

반환Returnsbool 터치를 받으면 true.True if it receives touches.

짝Counterpart: vanilla.js WorldNode.isInteractable

메서드methodpub fn set_gizmo_visible(&mut self, is_gizmo_visible: bool)#0.3.2 부터since 0.3.2소스source

기즈모 표시 설정.

Sets gizmo drawing.

is_gizmo_visiblebool
기즈모(내용 테두리와 피봇 점)를 그릴지.Whether to draw the gizmo (content border and pivot point).

짝Counterpart: vanilla.js TransformNode.setGizmoVisible

메서드methodpub fn is_gizmo_visible(&self) -> bool#0.3.2 부터since 0.3.2소스source

기즈모 표시 여부.

Whether gizmos are drawn.

반환Returnsbool 기즈모를 그리면 true.true if gizmos are drawn.

짝Counterpart: vanilla.js TransformNode.isGizmoVisible

메서드methodpub fn set_opacity_layer(&mut self, is_opacity_layer: bool)#0.4.0 부터since 0.4.0소스source

투명도 층 설정. (CSS opacity 처럼 투명도를 노드와 자손에 묶어 한 번에 얹을지)

  • 켜고 투명도(부모의 것을 곱한 값)가 1 보다 작으면 NodeTree 가 이 노드와 자손을 층에 모아 그렸다가 그 투명도로 한 번에 얹는다. (Graphic::begin_opacity_layer) 겹친 자식끼리 비치지 않는다. 끄면(처음) 노드마다 투명도를 곱해 따로 얹는다.

Sets the opacity layer. (Whether to group the opacity over the node and its descendants and lay it down at once, like CSS opacity)

  • When on and the opacity (multiplied by the parent's) is below 1, NodeTree draws this node and its descendants into a layer and lays it down at once with that opacity. (Graphic::begin_opacity_layer) Overlapping children do not show through each other. When off (the default), opacity is multiplied per node and each is laid down separately.
is_opacity_layerbool
투명도를 묶어 얹을지.Whether to lay the opacity down as a group.

짝Counterpart: vanilla.js TransformNode.setOpacityLayer

예제Example반투명한 묶음 노드 (겹친 자식이 서로 비치지 않는다)A translucent group node (overlapping children do not show through each other)
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());
메서드methodpub fn is_opacity_layer(&self) -> bool#0.4.0 부터since 0.4.0소스source

투명도 층 여부.

Whether the node is an opacity layer.

반환Returnsbool 투명도를 노드와 자손에 묶어 얹으면 true.true if the opacity is grouped over the node and its descendants.

짝Counterpart: vanilla.js TransformNode.isOpacityLayer

메서드methodpub fn get_transform(&self) -> &NodeTransform#0.3.2 부터since 0.3.2소스source

트랜스폼 반환.

Returns the transform.

반환Returns&NodeTransform 노드 트랜스폼.Node transform.

메서드methodpub fn get_transform_mut(&mut self) -> &mut NodeTransform#0.3.2 부터since 0.3.2소스source

트랜스폼 반환. (변경용)

Returns the transform. (mutable)

반환Returns&mut NodeTransform 노드 트랜스폼. (변경용)Node transform. (mutable)

메서드methodpub fn set_local_position(&mut self, local_position: Vector2)#0.3.2 부터since 0.3.2소스source

트랜스폼 바로가기.

  • 로컬 위치 설정. (NodeTransform::set_local_position)

Transform shortcuts.

  • Sets the local position. (NodeTransform::set_local_position)
local_positionVector2
부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리.Position of the pivot point measured from the top-left of the parent's content area.

짝Counterpart: vanilla.js TransformNode.setLocalPosition

메서드methodpub fn get_local_position(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

로컬 위치 반환. (NodeTransform::get_local_position)

Returns the local position. (NodeTransform::get_local_position)

반환ReturnsVector2 로컬 위치. (부모 내용 영역의 왼쪽 위에서 본 피봇 점의 자리)Local position. (position of the pivot point measured from the top-left of the parent's content area)

짝Counterpart: vanilla.js TransformNode.getLocalPosition

메서드methodpub fn set_local_scale(&mut self, local_scale: Vector2)#0.3.2 부터since 0.3.2소스source

로컬 배율 설정. (NodeTransform::set_local_scale)

Sets the local scale. (NodeTransform::set_local_scale)

local_scaleVector2
축마다 배율. (1 이 원래 크기, 음수면 그 축으로 뒤집혀 그려진다)Scale per axis. (1 is the original size, negative draws it flipped on that axis)

짝Counterpart: vanilla.js TransformNode.setLocalScale

메서드methodpub fn get_local_scale(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

로컬 배율 반환. (NodeTransform::get_local_scale)

Returns the local scale. (NodeTransform::get_local_scale)

반환ReturnsVector2 로컬 배율.Local scale.

짝Counterpart: vanilla.js TransformNode.getLocalScale

메서드methodpub fn set_local_rotation(&mut self, local_rotation: f64)#0.3.2 부터since 0.3.2소스source

로컬 회전 설정. (NodeTransform::set_local_rotation)

Sets the local rotation. (NodeTransform::set_local_rotation)

local_rotationf64
회전. (도, 양수면 화면에서 시계 방향)Rotation. (degrees, positive is clockwise on screen)

짝Counterpart: vanilla.js TransformNode.setLocalRotation

메서드methodpub fn get_local_rotation(&self) -> f64#0.3.2 부터since 0.3.2소스source

로컬 회전 반환. (NodeTransform::get_local_rotation)

Returns the local rotation. (NodeTransform::get_local_rotation)

반환Returnsf64 로컬 회전. (도)Local rotation. (degrees)

짝Counterpart: vanilla.js TransformNode.getLocalRotation

메서드methodpub fn set_local_opacity(&mut self, local_opacity: f64)#0.3.2 부터since 0.3.2소스source

로컬 불투명도 설정. (NodeTransform::set_local_opacity, 자식에게 곱해져 내려간다)

Sets the local opacity. (NodeTransform::set_local_opacity, multiplied down into the children)

local_opacityf64
불투명도. (0 ~ 1, 밖의 값은 잘라 넣는다)Opacity. (0 ~ 1, values outside are clamped)

짝Counterpart: vanilla.js TransformNode.setLocalOpacity

메서드methodpub fn get_local_opacity(&self) -> f64#0.3.2 부터since 0.3.2소스source

로컬 불투명도 반환. (NodeTransform::get_local_opacity)

Returns the local opacity. (NodeTransform::get_local_opacity)

반환Returnsf64 로컬 불투명도. (0 ~ 1)Local opacity. (0 ~ 1)

짝Counterpart: vanilla.js TransformNode.getLocalOpacity

메서드methodpub fn set_pivot(&mut self, pivot: Vector2)#0.3.2 부터since 0.3.2소스source

피봇 설정. (NodeTransform::set_pivot)

Sets the pivot. (NodeTransform::set_pivot)

pivotVector2
내용 크기 안의 기준점 비율. ((0, 0) 왼쪽 위, (1, 1) 오른쪽 아래, Pivot 상수)Ratio of the reference point within the content size. ((0, 0) top-left, (1, 1) bottom-right, Pivot constants)

짝Counterpart: vanilla.js WorldNode.setPivot

메서드methodpub fn get_pivot(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

피봇 반환. (NodeTransform::get_pivot)

Returns the pivot. (NodeTransform::get_pivot)

반환ReturnsVector2 피봇. (내용 크기 안의 비율)Pivot. (ratio within the content size)

짝Counterpart: vanilla.js WorldNode.getPivot

메서드methodpub fn set_content_size(&mut self, content_size: Vector2)#0.3.2 부터since 0.3.2소스source

내용 크기 설정. (NodeTransform::set_content_size)

Sets the content size. (NodeTransform::set_content_size)

content_sizeVector2
내용 크기. (노드 좌표, 배율을 걸기 전)Content size. (node coordinates, before scale is applied)

짝Counterpart: vanilla.js WorldNode.setContentSize

메서드methodpub fn get_content_size(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

내용 크기 반환. (NodeTransform::get_content_size)

Returns the content size. (NodeTransform::get_content_size)

반환ReturnsVector2 내용 크기. (노드 좌표, 배율을 걸기 전)Content size. (node coordinates, before scale is applied)

짝Counterpart: vanilla.js WorldNode.getContentSize

메서드methodpub fn copy_content_size_to(&self, target: &mut Vector2)#0.4.0 부터since 0.4.0소스source

내용 크기를 target 에 적는다. (원본 copyContentSizeTo, 새 값을 만들지 않고 받을 자리에 적는다)

Writes the content size into target. (the original copyContentSizeTo, writes into the given place without making a new value)

target&mut Vector2
내용 크기를 받을 벡터. (노드 좌표, 배율을 걸기 전)Vector that receives the content size. (node coordinates, before scale)

짝Counterpart: vanilla.js WorldNode.copyContentSizeTo

예제Example
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));
메서드methodpub fn read_content_size(&self, out: &mut Vector2)#0.4.0 부터since 0.4.0소스source

내용 크기를 out 에 적는다. (원본 readContentSize, get_content_size 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)

Writes the content size into out. (original readContentSize, the same value as get_content_size, writes into the given place without creating a new value)

out&mut Vector2
적을 자리.The place to write into.

짝Counterpart: vanilla.js WorldNode.readContentSize

예제Example
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));
메서드methodpub fn read_pivot(&self, out: &mut Vector2)#0.4.0 부터since 0.4.0소스source

피봇을 out 에 적는다. (원본 readPivot, get_pivot 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)

Writes the pivot into out. (original readPivot, the same value as get_pivot, writes into the given place without creating a new value)

out&mut Vector2
적을 자리.The place to write into.

짝Counterpart: vanilla.js WorldNode.readPivot

예제Example
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));
메서드methodpub fn read_local_position(&self, out: &mut Vector2)#0.4.0 부터since 0.4.0소스source

로컬 위치를 out 에 적는다. (원본 readLocalPosition, get_local_position 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)

Writes the local position into out. (original readLocalPosition, the same value as get_local_position, writes into the given place without creating a new value)

out&mut Vector2
적을 자리.The place to write into.

짝Counterpart: vanilla.js TransformNode.readLocalPosition

예제Example
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));
메서드methodpub fn read_local_scale(&self, out: &mut Vector2)#0.4.0 부터since 0.4.0소스source

로컬 배율을 out 에 적는다. (원본 readLocalScale, get_local_scale 과 같은 값, 새 값을 만들지 않고 받을 자리에 적는다)

Writes the local scale into out. (original readLocalScale, the same value as get_local_scale, writes into the given place without creating a new value)

out&mut Vector2
적을 자리.The place to write into.

짝Counterpart: vanilla.js TransformNode.readLocalScale

예제Example
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));
메서드methodpub fn set_local_position_xy(&mut self, x: f64, y: f64)#0.4.0 부터since 0.4.0소스source

로컬 위치 설정. (x, y 를 바로 받는다, NodeTransform::set_local_position_xy)

Sets the local position. (takes x, y directly, NodeTransform::set_local_position_xy)

xf64
로컬 위치 x.Local position x.
yf64
로컬 위치 y.Local position y.

짝Counterpart: vanilla.js TransformNode.setLocalPositionXY

메서드methodpub fn set_local_scale_xy(&mut self, x: f64, y: f64)#0.4.0 부터since 0.4.0소스source

로컬 배율 설정. (x, y 를 바로 받는다, NodeTransform::set_local_scale_xy)

Sets the local scale. (takes x, y directly, NodeTransform::set_local_scale_xy)

xf64
가로 배율.Horizontal scale.
yf64
세로 배율.Vertical scale.

짝Counterpart: vanilla.js TransformNode.setLocalScaleXY

메서드methodpub fn set_content_size_xy(&mut self, width: f64, height: f64)#0.4.0 부터since 0.4.0소스source

내용 크기 설정. (너비, 높이를 바로 받는다, NodeTransform::set_content_size_xy)

Sets the content size. (takes width, height directly, NodeTransform::set_content_size_xy)

widthf64
내용 너비.Content width.
heightf64
내용 높이.Content height.

짝Counterpart: vanilla.js WorldNode.setContentSizeXY

메서드methodpub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)#0.4.0 부터since 0.4.0소스source

부모 영역 안의 사각형에 놓기. (NodeTransform::set_rect, 피봇이 어디든 왼쪽 위가 (x, y) 에 온다)

Places it on a rectangle within the parent area. (NodeTransform::set_rect, the top-left lands on (x, y) wherever the pivot is)

xf64
왼쪽 위 x. (부모 내용 영역의 왼쪽 위 기준)Top-left x. (relative to the top-left of the parent's content area)
yf64
왼쪽 위 y. (부모 내용 영역의 왼쪽 위 기준)Top-left y. (relative to the top-left of the parent's content area)
widthf64
내용 너비.Content width.
heightf64
내용 높이.Content height.

짝Counterpart: vanilla.js WorldNode.setRect

메서드methodpub fn set_last_drawn_maximum_scale(&mut self, last_drawn_maximum_scale: f64, frame_number: u64)#0.4.0 부터since 0.4.0소스source

지난번 그릴 때의 가장 큰 배율과 그 그리기 프레임 번호 기억. (NodeTree 가 push_transform 뒤에 부른다, 원본 setLastDrawnMaximumScale)

  • 그리기 프레임 번호는 Graphic::begin_frame_statistics 마다 하나씩 오른다. 지난 프레임에 그리지 않은 노드(화면 밖이라 하위 트리째 건너뛴 것)는 다음에 그릴 때 처음 그리는 것으로 본다.

Remembers the largest scale of the last draw and its draw frame number. (NodeTree calls it after push_transform, original setLastDrawnMaximumScale)

  • The draw frame number goes up by one on every Graphic::begin_frame_statistics. A node not drawn last frame (skipped with its subtree because it was off screen) is treated as drawn for the first time when drawn next.
last_drawn_maximum_scalef64
변환의 가장 큰 배율. (0 이면 모른다)Largest scale of the transform. (0 if unknown)
frame_numberu64
그린 그리기 프레임 번호. (모르면 0)Draw frame number it was drawn in. (0 if unknown)

짝Counterpart: vanilla.js TransformNode.setLastDrawnMaximumScale

메서드methodpub fn get_last_drawn_maximum_scale(&self) -> f64#0.4.0 부터since 0.4.0소스source

지난번 그릴 때 변환의 가장 큰 배율 반환.

Returns the largest scale of the transform at the last draw.

반환Returnsf64 가장 큰 배율. (0 이면 아직 모른다)Largest scale. (not known yet if 0)

짝Counterpart: vanilla.js TransformNode.getLastDrawnMaximumScale

메서드methodpub fn get_last_drawn_frame_number(&self) -> u64#0.4.0 부터since 0.4.0소스source

지난번 그린 그리기 프레임 번호. (원본 getLastDrawnFrameNumber)

Draw frame number of the last draw. (original getLastDrawnFrameNumber)

반환Returnsu64 set_last_drawn_maximum_scale 로 기억한 프레임 번호. (그린 적 없으면 0)Frame number remembered with set_last_drawn_maximum_scale. (0 if never drawn)

짝Counterpart: vanilla.js TransformNode.getLastDrawnFrameNumber

예제Example기억한 배율과 프레임 번호 읽기Read the remembered scale and frame number
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);
메서드methodpub fn mark_draw_bounds_dirty(&self)#0.4.0 부터since 0.4.0소스source

이 노드의 하위 트리 그리기 경계가 바뀌었음을 알린다. (원본 TransformNode.markDrawBoundsDirty)

  • 내용 크기, 기즈모 표시, 컴포넌트 더하고 빼기는 엔진이 알아서 부른다. 컴포넌트의 그리는 사각형이 바뀌면 컴포넌트가 mark_drawn_rect_dirty 를 부른다.
  • 다음에 경계를 읽을 때(그리기 전) 이 노드와 조상이 다시 셈한다. 트리에 들지 않은 노드면 할 일이 없다.

Tells that this node's subtree draw bounds changed. (original TransformNode.markDrawBoundsDirty)

  • The engine calls it by itself for content size, gizmo display and adding or removing components. When a component's drawn rect changes the component calls mark_drawn_rect_dirty.
  • This node and its ancestors recompute the next time the bounds are read (before drawing). Does nothing for a node not in a tree.

짝Counterpart: vanilla.js TransformNode.markDrawBoundsDirty

예제Example경계를 다시 셈하게 하기Make the bounds recompute
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();
메서드methodpub fn mark_parent_draw_bounds_dirty(&self)#0.4.0 부터since 0.4.0소스source

부모의 하위 트리 그리기 경계가 바뀌었음을 알린다. (원본 TransformNode.markParentDrawBoundsDirty, 이 노드의 변환, 켜짐, 보임이 바뀌면 엔진이 알아서 부른다)

Tells that the parent's subtree draw bounds changed. (original TransformNode.markParentDrawBoundsDirty, the engine calls it by itself when this node's transform, active state or visibility changes)

짝Counterpart: vanilla.js TransformNode.markParentDrawBoundsDirty

메서드methodpub fn set_anchor(&mut self, anchor: Vector2)#0.3.2 부터since 0.3.2소스source

앵커 설정. (NodeTransform::set_anchor)

Sets the anchor. (NodeTransform::set_anchor)

anchorVector2
부모 내용 크기 안의 비율. (anchored_position 의 기준점, Pivot 상수)Ratio within the parent's content size. (reference point of anchored_position, Pivot constants)

짝Counterpart: vanilla.js WorldNode.setAnchor

메서드methodpub fn get_anchor(&self) -> Vector2#0.3.2 부터since 0.3.2소스source

앵커 반환. (NodeTransform::get_anchor)

Returns the anchor. (NodeTransform::get_anchor)

반환ReturnsVector2 앵커. (부모 내용 크기 안의 비율)Anchor. (ratio within the parent's content size)

짝Counterpart: vanilla.js WorldNode.getAnchor

메서드methodpub fn set_visible(&mut self, is_visible: bool)#0.3.2 부터since 0.3.2소스source

보이기 설정. (NodeTransform::set_visible, 꺼도 tick 은 돈다)

Sets visibility. (NodeTransform::set_visible, tick still runs when off)

is_visiblebool
그릴지. (false 면 이 노드와 자손을 그리지 않고 터치도 받지 않는다)Whether to draw. (if false, this node and its descendants are not drawn and receive no touches)

짝Counterpart: vanilla.js TransformNode.setVisible

메서드methodpub fn is_visible(&self) -> bool#0.3.2 부터since 0.3.2소스source

보이기 여부. (NodeTransform::is_visible)

Whether visible. (NodeTransform::is_visible)

반환Returnsbool 보이면 true.True if visible.

짝Counterpart: vanilla.js TransformNode.isVisible

메서드methodpub fn add_component<T: Component + 'static>(&mut self, component: T) -> &mut T#0.3.2 부터since 0.3.2소스source

컴포넌트 추가. (추가한 컴포넌트를 돌려준다)

  • 붙이기 전에 의존 컴포넌트(Component::require)가 없으면 만들어 붙이고, 그 뒤 attach 를 부른다.
  • attach_to_tree 는 부르지 않는다. 붙을 때 자식 노드를 만드는 컴포넌트는 NodeTree::add_component 로 붙인다.

Adds a component. (returns the added component)

  • Before attaching, creates and attaches any missing dependency components (Component::require), then calls attach.
  • Does not call attach_to_tree. Components that create child nodes when attached are added with NodeTree::add_component.
componentT
붙일 컴포넌트.Component to add.

반환Returns&mut T 붙인 컴포넌트. (변경용)The added component. (mutable)

짝Counterpart: vanilla.js ComponentNode.addComponent

예제Example붙이면서 돌려받은 컴포넌트를 바로 고치기Modify the component returned while adding it right away
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));
메서드methodpub fn get_or_add_component<T: Component + Default + 'static>(&mut self) -> &mut T#0.4.0 부터since 0.4.0소스source

컴포넌트 반환. 없으면 기본값으로 만들어 붙이고 반환. (원본 getOrAddComponent)

Returns the component. If missing, creates one with default values, attaches it and returns it. (the original getOrAddComponent)

반환Returns&mut T 그 타입의 첫 컴포넌트. (변경용) 없었으면 새로 붙인 기본값.The first component of that type. (mutable) A newly attached default one if there was none.

짝Counterpart: vanilla.js ComponentNode.getOrAddComponent

예제Example두 번 불러도 하나만 붙는다Only one is attached even if called twice
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);
메서드methodpub fn get_components<T: Component + 'static>(&self) -> Vec<&T>#0.4.0 부터since 0.4.0소스source

그 타입의 컴포넌트 모두. (원본 getComponents)

All components of that type. (the original getComponents)

반환ReturnsVec<&T> 그 타입의 컴포넌트 모두. (붙인 차례) 없으면 빈 목록.All components of that type. (order added) An empty list if none.

짝Counterpart: vanilla.js ComponentNode.getComponents

메서드methodpub fn get_component<T: Component + 'static>(&self) -> Option<&T>#0.3.2 부터since 0.3.2소스source

컴포넌트 반환. (그 타입의 첫 번째)

Returns the component. (the first of that type)

반환ReturnsOption<&T> 그 타입의 첫 컴포넌트. 없으면 None.The first component of that type. None if none.

짝Counterpart: vanilla.js ComponentNode.getComponent

메서드methodpub fn get_component_mut<T: Component + 'static>(&mut self) -> Option<&mut T>#0.3.2 부터since 0.3.2소스source

컴포넌트 반환. (변경용, 그 타입의 첫 번째)

Returns the component. (mutable, the first of that type)

반환ReturnsOption<&mut T> 그 타입의 첫 컴포넌트. (변경용) 없으면 None.The first component of that type. (mutable) None if none.

짝Counterpart: vanilla.js ComponentNode.getComponent

메서드methodpub fn has_component<T: Component + 'static>(&self) -> bool#0.3.2 부터since 0.3.2소스source

컴포넌트가 있는지.

Whether it has the component.

반환Returnsbool 그 타입의 컴포넌트가 있으면 true.True if it has a component of that type.

짝Counterpart: vanilla.js ComponentNode.hasComponent

메서드methodpub fn remove_component<T: Component + 'static>(&mut self) -> usize#0.3.2 부터since 0.3.2소스source

컴포넌트 제거. (그 타입 모두, 제거한 수)

  • 떼는 컴포넌트마다 detach 를 부른다.

Removes components. (all of that type, count removed)

  • Calls detach for each removed component.

반환Returnsusize 뗀 컴포넌트 수. (없으면 0)Number of components removed. (0 if none)

짝Counterpart: vanilla.js ComponentNode.removeComponent

예제Example그 타입을 모두 떼기Remove all of that type
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);
메서드methodpub fn get_all_components(&self) -> &Vec<Box<dyn Component>>#0.3.2 부터since 0.3.2소스source

모든 컴포넌트.

All components.

반환Returns&Vec<Box<dyn Component>> 붙인 컴포넌트 모두. (붙인 차례)All added components. (order added)

짝Counterpart: vanilla.js ComponentNode.getAllComponents

메서드methodpub fn push_transform(&self, graphic: &mut Graphic)#0.3.2 부터since 0.3.2소스source

출력 상태 시작. (이동 → 회전 → 크기 → 피봇 보정 → 투명도 곱)

  • Graphic 상태를 하나 쌓은 뒤 건다. pop_transform 과 짝으로 부른다.

Begins the draw state. (translate → rotate → scale → pivot correction → opacity multiply)

  • Pushes one Graphic state, then applies it. Call paired with pop_transform.
graphic&mut Graphic
트랜스폼을 걸 Graphic.Graphic to apply the transform to.

짝Counterpart: vanilla.js WorldNode.pushTransform

메서드methodpub fn push_component_transforms(&mut self, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

컴포넌트의 노드 출력 상태 시작. (push_transform 바로 뒤, 켜진 컴포넌트를 붙인 차례로)

Begins the components' node draw state. (right after push_transform, enabled components in the order added)

graphic&mut Graphic
그리는 Graphic. (push_transform 이 걸린 상태)Graphic drawing. (with push_transform applied)
메서드methodpub fn pop_component_transforms(&mut self, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

컴포넌트의 노드 출력 상태 끝. (pop_transform 바로 앞, 켜진 컴포넌트를 붙인 차례의 거꾸로)

Ends the components' node draw state. (right before pop_transform, enabled components in reverse order added)

graphic&mut Graphic
그리는 Graphic.Graphic drawing.
메서드methodpub fn draw_components(&mut self, graphic: &mut Graphic) -> (Option<f64>, bool)#0.3.2 부터since 0.3.2소스source

컴포넌트 출력. (자식은 NodeTree 가 그린다)

  • 돌려주는 것: (Mask 가 있으면 둥근 크기, 화면 밖이라 건너뛰었는지)
  • 켜진 컴포넌트가 모두 그리는 사각형을 알려 주면(calculate_drawn_rect) 그 합을 지금 Graphic 변환으로 화면에 대 보고, 밖이면 그리지 않는다. 하나라도 모르면 거르지 않는다. 걸러도 자식은 NodeTree 가 따로 판정한다.

Draws the components. (NodeTree draws the children)

  • Returns: (the corner radius if there is a Mask, whether it was skipped for being off screen)
  • If every enabled component reports the rectangle it draws (calculate_drawn_rect), their union is tested against the screen with the current Graphic transform and not drawn if outside. If any one is unknown, nothing is culled. Even when culled, NodeTree judges the children separately.
graphic&mut Graphic
그릴 Graphic. (push_transform 이 걸린 상태)Graphic to draw with. (with push_transform applied)

반환Returns(Option<f64>, bool) (켜진 자르는 컴포넌트(Mask)의 귀퉁이 둥근 크기, 없으면 None. 화면 밖이라 그리지 않았으면 true)(the corner radius of the enabled clipping component (Mask), None if none. True if not drawn for being off screen)

메서드methodpub fn draw_gizmos(&mut self, graphic: &mut Graphic)#0.3.2 부터since 0.3.2소스source

기즈모 출력. (기즈모 표시가 켜진 컴포넌트의 draw_gizmos 다음에 content_size 테두리와 피봇 점)

  • 전역 알파를 잠깐 1 로 두고 그린 뒤 되돌린다. 테두리와 피봇 점은 '#00ff00', 테두리 굵기 1, 피봇 점 반지름 4.

Draws gizmos. (the content_size border and pivot point after draw_gizmos of components whose gizmo display is on)

  • Sets the global alpha to 1 briefly while drawing and restores it. The border and pivot point are '#00ff00', the border width is 1 and the pivot point radius is 4.
graphic&mut Graphic
그릴 Graphic. (push_transform 이 걸린 상태)Graphic to draw with. (with push_transform applied)

짝Counterpart: vanilla.js WorldNode.drawGizmos

메서드methodpub fn pop_transform(&self, graphic: &mut Graphic)#0.3.2 부터since 0.3.2소스source

출력 상태 종료.

Ends the draw state.

graphic&mut Graphic
push_transform 에서 쌓은 상태를 꺼낼 Graphic.Graphic to pop the state pushed in push_transform from.

짝Counterpart: vanilla.js TransformNode.popTransform

메서드methodpub fn contains_point(&self, world_matrix: &TransformMatrix, view_position: Vector2) -> bool#0.3.2 부터since 0.3.2소스source

점이 이 노드의 content_size 영역 안에 있는지. (world_matrix 는 이 노드까지 누적한 행렬)

Whether a point is within this node's content_size area. (world_matrix is the matrix accumulated up to this node)

world_matrix&TransformMatrix
루트부터 이 노드까지 곱한 행렬. (NodeTree::calculate_world_matrix)Matrix multiplied from the root to this node. (NodeTree::calculate_world_matrix)
view_positionVector2
볼 점. (뷰 좌표)Point to check. (view coordinates)

반환Returnsbool 점이 내용 영역 (0, 0) ~ content_size 안이면 true. (경계 포함) 행렬을 뒤집을 수 없으면 false.True if the point is within the content area (0, 0) ~ content_size. (inclusive of the edges) False if the matrix cannot be inverted.

예제Example왼쪽 위 피봇 노드의 영역 안과 밖Inside and outside the area of a top-left-pivot node
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)));