core/component/paint
색 채우기 컴포넌트. (노드 content_size 영역을 단색 / 둥근 사각형으로 칠한다)
Color fill component. (paints the node's content_size area as a solid / rounded rectangle)
Paintstruct traits Default, Component
색 채우기 컴포넌트. (노드 content_size 영역을 한 색으로 칠한다)
- 둥근 크기가 0 보다 크면 둥근 사각형, 아니면 곧은 사각형으로 칠한다. (처음 흰색, 둥근 크기 0)
- 그리기만 하므로 tick 을 받지 않는다. Sprite 는 그림이 없을 때 이것으로 칠한다.
Color fill component. (paints the node's content_size area in one color)
- Paints a rounded rectangle if the round size is greater than 0, otherwise a sharp rectangle. (initially white, round size 0)
- It only draws, so it does not receive tick. Sprite paints with this when it has no image.
use vanilla::{Color, NodeTree, Paint, Vector2};
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let panel_id = node_tree.create_child(root_id, "Panel");
node_tree[panel_id].set_content_size(Vector2::create(240.0, 120.0));
let paint = node_tree.add_component(panel_id, Paint::new()).unwrap();
paint.set_color("#3366cc");
paint.set_round_size(16.0);
let paint = node_tree[panel_id].get_component::<Paint>().unwrap();
assert_eq!(paint.get_color(), Color::create_from_hex("#3366cc"));
assert_eq!(paint.get_round_size(), 16.0);생성.
Constructor.
반환ReturnsPaint 흰색, 둥근 크기 0 인 새 컴포넌트.New component, white, round size 0.
짝Counterpart: vanilla.js Paint.constructor
색과 함께 생성.
Constructor with a color.
- colorimpl Into<Color>
- 칠할 색. (Color 또는 "#rrggbb" 같은 문자열)Color to paint. (a Color or a string such as "#rrggbb")
반환ReturnsPaint 그 색으로 칠하는 새 컴포넌트. (둥근 크기 0)New component that paints in that color. (round size 0)
use vanilla::{Color, NodeTree, Paint};
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let node_id = node_tree.create_child(root_id, "Background");
let paint = node_tree.add_component(node_id, Paint::create_with_color("#ff0000")).unwrap();
assert_eq!(paint.get_color(), Color::create(1.0, 0.0, 0.0, 1.0));
let half_black = Paint::create_with_color(Color::black().with_alpha(0.5));
assert_eq!(half_black.get_color().alpha, 0.5);출력. (Sprite 가 이미지 없을 때도 이것을 쓴다)
- 노드 content 좌표의 (0, 0, content_size 너비, 높이) 사각형을 지금 색으로 채운다. Graphic 의 채우기 색이 이 색으로 바뀐다.
Draw. (Sprite also uses this when it has no image)
- Fills the (0, 0, content_size width, height) rectangle in node content coordinates with the current color. The Graphic's fill color changes to this color.
- transform&NodeTransform
- 칠할 노드 트랜스폼. (content_size 를 읽는다)Node transform to paint. (reads content_size)
- graphic&mut Graphic
- 그릴 그래픽. (노드 트랜스폼이 걸린 상태)Graphic to draw to. (with the node transform applied)
색상 설정. (Color 또는 "#rrggbb" 같은 문자열)
Sets the color. (a Color or a string such as "#rrggbb")
- colorimpl Into<Color>
- 칠할 색. (알파가 불투명도)Color to paint. (alpha is the opacity)
짝Counterpart: vanilla.js Paint.setColor
색상 반환.
Returns the color.
반환ReturnsColor 칠하는 색.The paint color.
짝Counterpart: vanilla.js Paint.getColor
라운드 크기 설정.
Sets the round size.
- round_sizef64
- 귀퉁이 둥근 크기. (노드 좌표, 0 이하면 곧은 사각형)Corner round size. (node coordinates, a sharp rectangle if 0 or less)
짝Counterpart: vanilla.js Paint.setRoundSize
라운드 크기 반환.
Returns the round size.
반환Returnsf64 귀퉁이 둥근 크기. (노드 좌표)Corner round size. (node coordinates)
짝Counterpart: vanilla.js Paint.getRoundSize