vanilladocs
vanillapunch.com
API / ui/uiprogressring

ui/uiprogressring

진행 고리.

Progress ring.

UIProgressRingextends Component

짝Counterpart: vanilla-engine UIProgressRing

진행 고리.

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

Progress ring.

  • A thin line running along the node's shape (rounded rectangle, a circle if the roundness 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 line's center is inset by half the thickness.
  • Perimeter points are recomputed only when the size, roundness or thickness changes.
예제Example동그란 진행 고리 그리기Drawing a round progress ring
import { Engine, EngineConfiguration, UIScene, UIProgressRing, WorldNode, Pivot, Vector2 } from "./build/vanilla.js";

class RingScene extends UIScene {
	create() {
		super.create();
		const ringNode = new WorldNode();
		ringNode.setPivot(Pivot.middleCenter.clone());
		ringNode.setAnchor(Pivot.topLeft.clone());
		ringNode.setContentSize(Vector2.create(96, 96));
		ringNode.setLocalPosition(Vector2.create(320, 180));
		const progressRing = ringNode.addComponent(UIProgressRing);
		progressRing.setRoundSize(48);
		progressRing.setLineWidth(6);
		progressRing.setFillColor("#4ade80");
		progressRing.setTrackColor("rgba(255, 255, 255, 0.15)");
		progressRing.setRatio(0.7);
		const root = this.getRoot();
		root.addChild(ringNode);
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const scene = new RingScene();
scene.setLoadingMinDurationMs(0);
engine.run(scene);
생성자constructorconstructor()#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

짝Counterpart: vanilla-engine UIProgressRing.new

정적staticstatic parseColor(color)#0.4.0 부터since 0.4.0소스source

색 값 읽기. ("#rrggbb", "rgba(...)" 또는 Color)

Reads a color value. ("#rrggbb", "rgba(...)" or Color)

colorColor | string
색 값. ("rgb" 로 시작하는 글은 rgba 로, 그 밖의 글은 16 진 색으로 읽는다)Color value. (text starting with "rgb" is read as rgba, other text as a hex color)

반환ReturnsColor 읽은 색. (Color 를 주면 그대로)The parsed color. (a Color is returned as is)

메서드methoddraw(graphic)#0.4.0 부터since 0.4.0소스source

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

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

graphicGraphic
그릴 그래픽. (노드 로컬 좌표, 내용 영역 왼쪽 위가 원점)Graphic to draw with. (node local coordinates, origin at the top-left of the content area)
메서드methodisDrawnInsideContent()#0.4.0 부터since 0.4.0소스source

내용 영역 안에서만 그리는지 반환. (고리는 내용 크기 안쪽으로 굵기의 반만큼 들여 그린다)

  • draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false.

Returns whether it draws only inside the content area. (the ring is drawn inset inside the content size by half the thickness)

  • false for subclasses that override draw, since where they draw is unknown.

반환Returnsboolean draw 를 덮어쓰지 않았으면 참.True if draw is not overridden.

메서드methodreadPerimeterPoints(left, top, width, height, roundSize)#0.4.0 부터since 0.4.0소스source

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

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

leftnumber
왼쪽. (픽셀)Left. (pixels)
topnumber
위쪽. (픽셀)Top. (pixels)
widthnumber
너비. (픽셀)Width. (pixels)
heightnumber
높이. (픽셀)Height. (pixels)
roundSizenumber
귀퉁이 반지름. (너비와 높이의 반으로 자른다)Corner radius. (clamped to half the width and height)

반환ReturnsArray<Vector2> 둘레의 점. (위 가운데 점 하나와 귀퉁이마다 11 개, 모두 45 개)Perimeter points. (one top-center point and 11 per corner, 45 in total)

짝Counterpart: vanilla-engine UIProgressRing.read_perimeter_points

메서드methodreadPartialPoints(points, ratio)#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)

pointsArray<Vector2>
readPerimeterPoints 의 결과. (닫힌 꼴)Result of readPerimeterPoints. (closed shape)
rationumber
앞에서부터 잘라 낼 둘레 길이의 몫. (0 ~ 1)Share of the perimeter length to cut from the start. (0 ~ 1)

반환ReturnsArray<Vector2> 첫 점에서 시작해 잘린 끝점으로 끝나는 열린 점 목록.Open point list starting at the first point and ending at the cut end point.

짝Counterpart: vanilla-engine UIProgressRing.read_partial_points

메서드methodsetRatio(ratio)#0.4.0 부터since 0.4.0소스source

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

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

rationumber
채운 몫. (0 ~ 1)Filled share. (0 ~ 1)

짝Counterpart: vanilla-engine UIProgressRing.set_ratio

메서드methodgetRatio()#0.4.0 부터since 0.4.0소스source

채운 몫 반환.

Returns the filled fraction.

반환Returnsnumber 채운 몫. (0 ~ 1)Filled share. (0 ~ 1)

짝Counterpart: vanilla-engine UIProgressRing.get_ratio

메서드methodsetRoundSize(roundSize)#0.4.0 부터since 0.4.0소스source

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

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

roundSizenumber
바깥 꼴 귀퉁이의 반지름. (픽셀, 0 이면 네모)Corner radius of the outer shape. (pixels, a rectangle if 0)

짝Counterpart: vanilla-engine UIProgressRing.set_round_size

메서드methodgetRoundSize()#0.4.0 부터since 0.4.0소스source

귀퉁이 둥근 정도 반환.

Returns the corner roundness.

반환Returnsnumber 바깥 꼴 귀퉁이의 반지름. (픽셀)Corner radius of the outer shape. (pixels)

짝Counterpart: vanilla-engine UIProgressRing.get_round_size

메서드methodsetLineWidth(lineWidth)#0.4.0 부터since 0.4.0소스source

선 굵기 설정.

Sets the line thickness.

lineWidthnumber
선 굵기. (픽셀)Line width. (pixels)

짝Counterpart: vanilla-engine UIProgressRing.set_line_width

메서드methodgetLineWidth()#0.4.0 부터since 0.4.0소스source

선 굵기 반환.

Returns the line thickness.

반환Returnsnumber 선 굵기. (픽셀)Line width. (pixels)

짝Counterpart: vanilla-engine UIProgressRing.get_line_width

메서드methodsetFillColor(color)#0.4.0 부터since 0.4.0소스source

채운 몫의 색 설정.

Sets the color of the filled fraction.

colorColor | string
채운 몫의 색. (Color, "#rrggbb", "rgba(...)")Color of the filled share. (Color, "#rrggbb", "rgba(...)")

짝Counterpart: vanilla-engine UIProgressRing.set_fill_color

메서드methodgetFillColor()#0.4.0 부터since 0.4.0소스source

채운 몫의 색 반환.

Returns the color of the filled fraction.

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

짝Counterpart: vanilla-engine UIProgressRing.get_fill_color

메서드methodsetTrackColor(color)#0.4.0 부터since 0.4.0소스source

나머지의 색 설정.

Sets the color of the rest.

colorColor | string
나머지의 색. (Color, "#rrggbb", "rgba(...)")Color of the rest. (Color, "#rrggbb", "rgba(...)")

짝Counterpart: vanilla-engine UIProgressRing.set_track_color

메서드methodgetTrackColor()#0.4.0 부터since 0.4.0소스source

나머지의 색 반환.

Returns the color of the rest.

반환ReturnsColor 나머지의 색.Color of the rest.

짝Counterpart: vanilla-engine UIProgressRing.get_track_color

메서드methodgetPerimeterPoints()#0.4.0 부터since 0.4.0소스source

둘레의 점 반환. (마지막으로 그린 크기의 것)

Returns the perimeter points. (for the last drawn size)

반환ReturnsArray<Vector2> 둘레의 점. (한 번도 그리지 않았으면 빈 배열)Perimeter points. (empty array if never drawn)

짝Counterpart: vanilla-engine UIProgressRing.get_perimeter_points