API / base/pivot
base/pivot
피봇 / 앵커 값.
- 원본 base/pivot.js 의 Pivot 객체를 연관 상수로 옮겼다.
Pivot / anchor values.
- The Pivot object of the original base/pivot.js moved to associated constants.
Pivotstruct
피봇과 앵커 상수. (내용 크기 안의 비율, (0, 0) 이 왼쪽 위, (1, 1) 이 오른쪽 아래)
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
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));정가운데. (0.5, 0.5)
Middle center. (0.5, 0.5)
반환ReturnsVector2
짝Counterpart: vanilla.js Pivot.middleCenter