vanilladocs
vanillapunch.com
API / ui/uiprogressring

ui/uiprogressring

진행 고리. (vanilla.js ui/uiprogressring.js 의 UIProgressRing)

  • 노드의 꼴(둥근 네모, 둥근 정도가 크기의 반이면 동그라미)을 따라 도는 가는 선이다.
  • 위 가운데에서 시계 방향으로 채운 몫만큼 채운 색, 나머지는 바탕 색으로 그린다.
  • 붙인 노드의 내용 크기 전체가 고리의 바깥 꼴이고, 선의 가운데가 그 안쪽으로 굵기의 반만큼 들어온다.
  • 둘레의 점은 크기, 둥근 정도, 굵기가 바뀔 때만 다시 셈한다.

Progress ring. (UIProgressRing of vanilla.js ui/uiprogressring.js)

  • A thin line that runs along the node's shape (a rounded rectangle, a circle when the rounding is half the size).
  • From the top center clockwise, the filled fraction is drawn in the fill color and the rest in the background color.
  • The whole content size of the attached node is the ring's outer shape, and the center of the line sits inside it by half the thickness.
  • The perimeter points are recalculated only when the size, rounding, or thickness changes.

UIProgressRingstruct traits Default, Component

짝Counterpart: vanilla.js UIProgressRing소스source

진행 고리.

  • 붙인 노드의 내용 크기를 바깥 꼴로, 위 가운데에서 시계 방향으로 채운 몫을 그린다.

Progress ring.

  • Uses the attached node's content size as the outer shape and draws the fraction filled clockwise from the top center.
예제Example48 x 48 동그라미 고리A 48 x 48 circular ring
use vanilla::{NodeTree, UIProgressRing, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let ring_id = node_tree.create_child(root_id, "LoadingRing");
node_tree[ring_id].set_content_size(Vector2::create(48.0, 48.0));
let ring = node_tree.add_component(ring_id, UIProgressRing::new()).expect("ring");
ring.set_round_size(24.0);
ring.set_line_width(4.0);
ring.set_ratio(0.25);
assert_eq!(ring.get_ratio(), 0.25);
ring.set_ratio(1.5);
assert_eq!(ring.get_ratio(), 1.0);
생성자constructorpub fn new() -> UIProgressRing#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

반환ReturnsUIProgressRing 붙기 전의 고리. (몫 0, 둥근 정도 0, 굵기 2, 채운 색 흰색)Ring before being attached. (fraction 0, rounding 0, thickness 2, white fill color)

짝Counterpart: vanilla.js UIProgressRing.constructor

정적staticpub fn read_perimeter_points(left: f64, top: f64, width: f64, height: f64, round_size: f64) -> Vec<Vector2>#0.4.0 부터since 0.4.0소스source

둥근 네모 둘레의 점. (위 가운데에서 시작해 시계 방향, 닫는 점은 넣지 않는다)

Points on the rounded rectangle perimeter. (starting from the top center, clockwise, without the closing point)

leftf64
네모의 왼쪽.Left of the rectangle.
topf64
네모의 위.Top of the rectangle.
widthf64
네모의 가로.Width of the rectangle.
heightf64
네모의 세로.Height of the rectangle.
round_sizef64
귀퉁이 반지름. (가로와 세로의 반을 넘으면 그 값으로 자른다)Corner radius. (clamped to half the width and height if it exceeds that)

반환ReturnsVec<Vector2> 둘레의 점 45 개. (위 가운데 1 개, 귀퉁이마다 11 개)45 perimeter points. (1 at the top center, 11 per corner)

짝Counterpart: vanilla.js UIProgressRing.readPerimeterPoints

예제Example첫 점은 위 가운데The first point is the top center
use vanilla::{UIProgressRing, Vector2};

let points = UIProgressRing::read_perimeter_points(0.0, 0.0, 100.0, 60.0, 0.0);
assert_eq!(points.len(), 45);
assert_eq!(points[0], Vector2::create(50.0, 0.0));
정적staticpub fn read_partial_points(points: &[Vector2], ratio: f64) -> Vec<Vector2>#0.4.0 부터since 0.4.0소스source

둘레의 앞 몫만큼의 점. (길이로 셈하고, 끝점은 마지막 변 위에서 잘라 넣는다)

Points for the leading fraction of the perimeter. (computed by length; the end point is cut on the last edge and added)

points&[Vector2]
둘레의 점. (닫는 점 없이, read_perimeter_points 의 결과)Perimeter points. (without a closing point, the result of read_perimeter_points)
ratiof64
앞에서부터 그릴 몫. (닫은 둘레 길이의 비율, 0 ~ 1)Fraction to draw from the start. (ratio of the closed perimeter length, 0 ~ 1)

반환ReturnsVec<Vector2> 첫 점부터 그 몫까지 이은 점. (points 가 비면 빈 목록, 1 이상이면 첫 점으로 돌아와 닫는다)Points connected from the first point up to that fraction. (an empty list if points is empty, returns to the first point and closes if 1 or more)

짝Counterpart: vanilla.js UIProgressRing.readPartialPoints

예제Example반 바퀴면 아래 가운데에서 끝난다Half a turn ends at the bottom center
use vanilla::UIProgressRing;

let points = UIProgressRing::read_perimeter_points(0.0, 0.0, 100.0, 100.0, 0.0);
let half_points = UIProgressRing::read_partial_points(&points, 0.5);
let last_point = half_points[half_points.len() - 1];
assert!((last_point.x - 50.0).abs() < 0.01);
assert!((last_point.y - 100.0).abs() < 0.01);
메서드methodpub fn draw_ring(&mut self, transform: &NodeTransform, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

출력. (바탕 고리 한 바퀴, 그 위에 채운 몫)

Draw. (one full background ring, with the filled fraction on top)

transform&NodeTransform
노드 변환. (내용 크기가 고리의 바깥 꼴, 크기에서 굵기를 뺀 가로나 세로가 1 이하면 그리지 않는다)Node transform. (the content size is the ring's outer shape, not drawn if the width or height minus the thickness is 1 or less)
graphic&mut Graphic
그릴 그래픽.Graphic to draw with.
메서드methodpub fn set_ratio(&mut self, ratio: f64)#0.4.0 부터since 0.4.0소스source

채운 몫 설정. (0 ~ 1 로 자른다)

Sets the filled fraction. (clamped to 0 ~ 1)

ratiof64
채운 몫. (0 ~ 1, 넘으면 자른다)Filled fraction. (0 ~ 1, clamped if exceeded)

짝Counterpart: vanilla.js UIProgressRing.setRatio

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

채운 몫 반환.

Returns the filled fraction.

반환Returnsf64 채운 몫. (0 ~ 1, 기본 0)Filled fraction. (0 ~ 1, default 0)

짝Counterpart: vanilla.js UIProgressRing.getRatio

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

귀퉁이 둥근 정도 설정. (크기의 반 이상이면 동그라미)

Sets the corner roundness. (a circle if half the size or more)

round_sizef64
바깥 꼴의 귀퉁이 반지름. (선의 가운데는 굵기의 반을 뺀 반지름으로 돈다)Corner radius of the outer shape. (the center of the line runs at the radius minus half the thickness)

짝Counterpart: vanilla.js UIProgressRing.setRoundSize

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

귀퉁이 둥근 정도 반환.

Returns the corner roundness.

반환Returnsf64 바깥 꼴의 귀퉁이 반지름. (기본 0)Corner radius of the outer shape. (default 0)

짝Counterpart: vanilla.js UIProgressRing.getRoundSize

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

선 굵기 설정.

Sets the line thickness.

line_widthf64
선 굵기. (기본 2)Line thickness. (default 2)

짝Counterpart: vanilla.js UIProgressRing.setLineWidth

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

선 굵기 반환.

Returns the line thickness.

반환Returnsf64 선 굵기. (기본 2)Line thickness. (default 2)

짝Counterpart: vanilla.js UIProgressRing.getLineWidth

메서드methodpub fn set_fill_color(&mut self, color: impl Into<Color>)#0.4.0 부터since 0.4.0소스source

채운 몫의 색 설정.

Sets the color of the filled fraction.

colorimpl Into<Color>
채운 몫의 색. (기본 흰색)Color of the filled fraction. (default white)

짝Counterpart: vanilla.js UIProgressRing.setFillColor

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

채운 몫의 색 반환.

Returns the color of the filled fraction.

반환ReturnsColor 채운 몫의 색.Color of the filled share.

짝Counterpart: vanilla.js UIProgressRing.getFillColor

메서드methodpub fn set_track_color(&mut self, color: impl Into<Color>)#0.4.0 부터since 0.4.0소스source

나머지의 색 설정.

Sets the color of the rest.

colorimpl Into<Color>
바탕 고리의 색. (기본 Color::create(0.2, 0.2, 0.25, 1.0))Color of the background ring. (default Color::create(0.2, 0.2, 0.25, 1.0))

짝Counterpart: vanilla.js UIProgressRing.setTrackColor

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

나머지의 색 반환.

Returns the color of the rest.

반환ReturnsColor 바탕 고리의 색.Color of the background ring.

짝Counterpart: vanilla.js UIProgressRing.getTrackColor

메서드methodpub fn get_perimeter_points(&self) -> &[Vector2]#0.4.0 부터since 0.4.0소스source

마지막으로 셈한 둘레의 점. (그린 뒤에 맞는 값, 원본 getPerimeterPoints)

The last calculated perimeter points. (valid after drawing, original getPerimeterPoints)

반환Returns&[Vector2] 선의 가운데가 지나는 둘레의 점. (한 번도 그리지 않았으면 빈 목록)Perimeter points the center of the line passes through. (an empty list if never drawn)

짝Counterpart: vanilla.js UIProgressRing.getPerimeterPoints