# ui/uiprogressring (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/ui/uiprogressring/

진행 고리.

## UIProgressRing extends Component

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

예제: 동그란 진행 고리 그리기

```js
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);
```

- `constructor()` (constructor, since 0.4.0): 생성.
- `draw(graphic)` (method, since 0.4.0): 출력. (바탕 고리 한 바퀴, 그 위에 채운 몫)
  - `graphic` Graphic: 그릴 그래픽. (노드 로컬 좌표, 내용 영역 왼쪽 위가 원점)
- `isDrawnInsideContent()` (method, since 0.4.0): 내용 영역 안에서만 그리는지 반환. (고리는 내용 크기 안쪽으로 굵기의 반만큼 들여 그린다)
  - draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false.
  - returns boolean: draw 를 덮어쓰지 않았으면 참.
- `readPerimeterPoints(left, top, width, height, roundSize)` (method, since 0.4.0): 둥근 네모 둘레의 점. (위 가운데에서 시작해 시계 방향, 닫는 점은 넣지 않는다)
  - `left` number: 왼쪽. (픽셀)
  - `top` number: 위쪽. (픽셀)
  - `width` number: 너비. (픽셀)
  - `height` number: 높이. (픽셀)
  - `roundSize` number: 귀퉁이 반지름. (너비와 높이의 반으로 자른다)
  - returns Array<Vector2>: 둘레의 점. (위 가운데 점 하나와 귀퉁이마다 11 개, 모두 45 개)
- `readPartialPoints(points, ratio)` (method, since 0.4.0): 둘레의 앞 몫만큼의 점. (길이로 셈하고, 끝점은 마지막 변 위에서 잘라 넣는다)
  - `points` Array<Vector2>: readPerimeterPoints 의 결과. (닫힌 꼴)
  - `ratio` number: 앞에서부터 잘라 낼 둘레 길이의 몫. (0 ~ 1)
  - returns Array<Vector2>: 첫 점에서 시작해 잘린 끝점으로 끝나는 열린 점 목록.
- `setRatio(ratio)` (method, since 0.4.0): 채운 몫 설정. (0 ~ 1 로 자른다)
  - `ratio` number: 채운 몫. (0 ~ 1)
- `getRatio()` (method, since 0.4.0): 채운 몫 반환.
  - returns number: 채운 몫. (0 ~ 1)
- `setRoundSize(roundSize)` (method, since 0.4.0): 귀퉁이 둥근 정도 설정. (크기의 반 이상이면 동그라미)
  - `roundSize` number: 바깥 꼴 귀퉁이의 반지름. (픽셀, 0 이면 네모)
- `getRoundSize()` (method, since 0.4.0): 귀퉁이 둥근 정도 반환.
  - returns number: 바깥 꼴 귀퉁이의 반지름. (픽셀)
- `setLineWidth(lineWidth)` (method, since 0.4.0): 선 굵기 설정.
  - `lineWidth` number: 선 굵기. (픽셀)
- `getLineWidth()` (method, since 0.4.0): 선 굵기 반환.
  - returns number: 선 굵기. (픽셀)
- `setFillColor(color)` (method, since 0.4.0): 채운 몫의 색 설정.
  - `color` Color | string: 채운 몫의 색. (Color, "#rrggbb", "rgba(...)")
- `getFillColor()` (method, since 0.4.0): 채운 몫의 색 반환.
  - returns Color: 채운 몫의 색.
- `setTrackColor(color)` (method, since 0.4.0): 나머지의 색 설정.
  - `color` Color | string: 나머지의 색. (Color, "#rrggbb", "rgba(...)")
- `getTrackColor()` (method, since 0.4.0): 나머지의 색 반환.
  - returns Color: 나머지의 색.
- `getPerimeterPoints()` (method, since 0.4.0): 둘레의 점 반환. (마지막으로 그린 크기의 것)
  - returns Array<Vector2>: 둘레의 점. (한 번도 그리지 않았으면 빈 배열)
- `static parseColor(color)` (static, since 0.4.0): 색 값 읽기. ("#rrggbb", "rgba(...)" 또는 Color)
  - `color` Color | string: 색 값. ("rgb" 로 시작하는 글은 rgba 로, 그 밖의 글은 16 진 색으로 읽는다)
  - returns Color: 읽은 색. (Color 를 주면 그대로)
