vanilladocs
vanillapunch.com
API / core/component/paint

core/component/paint

색 채우기 컴포넌트. (노드 content_size 영역을 단색 / 둥근 사각형으로 칠한다)

Color fill component. (paints the node's content_size area as a solid / rounded rectangle)

Paintstruct traits Default, Component

짝Counterpart: vanilla.js Paint소스source

색 채우기 컴포넌트. (노드 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.
예제Example둥근 파란 판A round blue panel
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);
생성자constructorpub fn new() -> Paint#0.3.2 부터since 0.3.2소스source

생성.

Constructor.

반환ReturnsPaint 흰색, 둥근 크기 0 인 새 컴포넌트.New component, white, round size 0.

짝Counterpart: vanilla.js Paint.constructor

정적staticpub fn create_with_color(color: impl Into<Color>) -> Paint#0.3.2 부터since 0.3.2소스source

색과 함께 생성.

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)

예제Example색 글로 만들어 노드에 붙이기Create from a color string and attach to a node
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);
메서드methodpub fn draw_paint(&self, transform: &NodeTransform, graphic: &mut Graphic)#0.3.2 부터since 0.3.2소스source

출력. (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)
메서드methodpub fn set_color(&mut self, color: impl Into<Color>)#0.3.2 부터since 0.3.2소스source

색상 설정. (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

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

색상 반환.

Returns the color.

반환ReturnsColor 칠하는 색.The paint color.

짝Counterpart: vanilla.js Paint.getColor

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

라운드 크기 설정.

Sets the round size.

round_sizef64
귀퉁이 둥근 크기. (노드 좌표, 0 이하면 곧은 사각형)Corner round size. (node coordinates, a sharp rectangle if 0 or less)

짝Counterpart: vanilla.js Paint.setRoundSize

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

라운드 크기 반환.

Returns the round size.

반환Returnsf64 귀퉁이 둥근 크기. (노드 좌표)Corner round size. (node coordinates)

짝Counterpart: vanilla.js Paint.getRoundSize