core/component/outline
테만 그리는 컴포넌트. (vanilla.js core/component/outline.js 의 Outline)
- Paint 는 속을 채우기만 하므로, 비치는 판 위에 테를 따로 얹을 때 쓴다. (채운 판 두 장을 겹치면 비치는 속에 바깥 색이 섞인다)
- 둥근 네모 테는 노드의 내용 크기 그대로, 동그라미 테는 그 가운데에 짧은 변의 반을 반지름으로 그린다.
- 선은 내용 크기 안쪽에 들어온다. (선의 가운데가 굵기의 반만큼 안쪽)
A component that draws only an outline. (Outline in vanilla.js core/component/outline.js)
- Paint only fills, so this is used to put a separate outline over a see-through panel. (stacking two filled panels mixes the outer color into the see-through inside)
- A rounded box outline uses the node's content size as is, and a circle outline is drawn at its center with half the shorter side as the radius.
- The line stays inside the content size. (the center of the line is half the thickness inward)
Outlinestruct traits Default, Component
테만 그리는 컴포넌트. (속은 비우고 노드 content_size 의 테두리만 긋는다)
- 처음은 흰색, 굵기 1, 둥근 크기 0, 네모 테.
- 선은 내용 크기 안쪽에 그어 바깥 꼴이 내용 크기와 같다. 둥근 크기도 바깥 꼴 기준이다.
A component that draws only an outline. (leaves the inside empty and strokes only the border of the node's content_size)
- Initially white, thickness 1, round size 0, box outline.
- The line is stroked inside the content size, so the outer shape equals the content size. The round size is also based on the outer shape.
use vanilla::{Color, NodeTree, Outline, Paint, Vector2};
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let card_id = node_tree.create_child(root_id, "Card");
node_tree[card_id].set_content_size(Vector2::create(200.0, 120.0));
node_tree.add_component(card_id, Paint::create_with_color(Color::black().with_alpha(0.4)));
let outline = node_tree.add_component(card_id, Outline::new()).unwrap();
outline.set_color("#ffcc00");
outline.set_line_width(3.0);
outline.set_round_size(12.0);
let outline = node_tree[card_id].get_component::<Outline>().unwrap();
assert_eq!(outline.get_line_width(), 3.0);
assert!(!outline.is_circle());생성.
Constructor.
반환ReturnsOutline 흰색, 굵기 1, 둥근 크기 0 인 네모 테 컴포넌트.Box outline component, white, thickness 1, round size 0.
짝Counterpart: vanilla.js Outline.constructor
출력.
- 굵기가 0 이하이거나, 굵기를 빼고 남는 너비, 높이(동그라미면 반지름)가 0 이하면 그리지 않는다.
- Graphic 의 선 색이 이 색으로 바뀐다.
Draw.
- Does not draw if the thickness is 0 or less, or if the width or height left after subtracting the thickness (the radius for a circle) is 0 or less.
- The Graphic's stroke color changes to this color.
- transform&NodeTransform
- 테를 그릴 노드 트랜스폼. (content_size 를 읽는다)Node transform to draw the outline on. (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>
- 테 색. (알파가 불투명도, 처음 흰색)Outline color. (alpha is the opacity, initially white)
짝Counterpart: vanilla.js Outline.setColor
굵기 설정. (0 이면 그리지 않는다)
Sets the thickness. (0 does not draw)
- line_widthf64
- 선 굵기. (노드 좌표, 0 이하면 그리지 않는다, 처음 1)Line thickness. (node coordinates, does not draw if 0 or less, initially 1)
짝Counterpart: vanilla.js Outline.setLineWidth
굵기 반환.
Returns the thickness.
반환Returnsf64 선 굵기. (노드 좌표)Line thickness. (node coordinates)
짝Counterpart: vanilla.js Outline.getLineWidth
귀퉁이 둥근 정도 설정. (바깥 꼴 기준)
Sets the corner roundness. (based on the outer shape)
- round_sizef64
- 바깥 꼴의 귀퉁이 둥근 크기. (노드 좌표, 처음 0) 선의 가운데는 굵기의 반만큼 덜 둥글게 긋는다. 동그라미 테에는 쓰지 않는다.Corner round size of the outer shape. (node coordinates, initially 0) The center of the line is stroked half the thickness less rounded. Not used for circle outlines.
짝Counterpart: vanilla.js Outline.setRoundSize
귀퉁이 둥근 정도 반환.
Returns the corner roundness.
반환Returnsf64 바깥 꼴의 귀퉁이 둥근 크기. (노드 좌표)Corner round size of the outer shape. (node coordinates)
짝Counterpart: vanilla.js Outline.getRoundSize
동그라미 테로 그릴지 설정.
Sets whether to draw as a circle border.
- is_circlebool
- true 면 내용 크기 가운데에 짧은 변의 반을 바깥 반지름으로 하는 동그라미 테, false 면 네모 테. (처음 false)If true, a circle outline at the center of the content size with half the shorter side as the outer radius, if false, a box outline. (initially false)
짝Counterpart: vanilla.js Outline.setCircle
동그라미 테인지 반환.
Returns whether it is a circle border.
반환Returnsbool 동그라미 테면 true, 네모 테면 false.true for a circle outline, false for a box outline.
짝Counterpart: vanilla.js Outline.isCircle