ui/uiprogressview
진행률 표시.
Progress display.
UIProgressViewextends UIView
진행률 표시.
- 노드의 contentSize 영역을 트랙으로 사용.
- value 비율만큼 fill 영역을 그린다.
- 입력은 없음. 값은 외부에서 setValue 로만 변경.
- UIView 를 상속하여 컨테이너 표시 객체로서의 일관성을 유지하고, WorldNode 에 부착될 때 자동 마스크/콘텐츠 노드 처리를 받는다.
Progress display.
- Uses the node's contentSize area as the track.
- Draws the fill area by the value ratio.
- No input. The value is changed only externally via setValue.
- Inherits UIView to stay consistent as a container display object, and gets automatic mask/content node handling when attached to a WorldNode.
import { Engine, EngineConfiguration, UIScene, UIProgressView, WorldNode, Color, Pivot, Vector2 } from "./build/vanilla.js";
class ProgressScene extends UIScene {
create() {
super.create();
const progressNode = new WorldNode();
progressNode.setPivot(Pivot.topLeft.clone());
progressNode.setAnchor(Pivot.topLeft.clone());
progressNode.setContentSize(Vector2.create(400, 24));
progressNode.setLocalPosition(Vector2.create(120, 168));
const progressView = progressNode.addComponent(UIProgressView);
progressView.setRange(0, 100);
progressView.setValue(65);
progressView.setTrackColor(new Color(0.2, 0.2, 0.25, 1));
progressView.setFillColor(new Color(0.3, 0.8, 0.5, 1));
progressView.setCornerRadius(12);
const ratio = progressView.getRatio();
console.log(ratio);
const root = this.getRoot();
root.addChild(progressNode);
}
}
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const scene = new ProgressScene();
scene.setLoadingMinDurationMs(0);
engine.run(scene);내용 영역 안에서만 그리는지 반환. (트랙과 채움은 내용 크기의 사각형 안만 칠한다, 화면 밖과 자르기 밖 거르기가 쓴다)
- draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false. (그 클래스가 이 함수도 덮어써 알린다)
Returns whether it draws only inside the content area. (the track and fill paint only inside the content-size rectangle; used by off-screen and outside-clip culling)
- Subclasses that override draw return false because where they draw is unknown. (such a class overrides this function too to report it)
반환Returnsboolean 내용 영역 안에서만 그리면 참.True if drawing only inside the content area.
출력. (트랙 + 채움. 트랙은 UIView.backgroundColor 사용)
- cornerRadius 처리를 위해 super.draw 를 호출하지 않고 직접 그린다.
Draw. (track + fill. The track uses UIView.backgroundColor)
- Draws directly without calling super.draw, to handle cornerRadius.
- graphicGraphic
- 그릴 그래픽. (노드 로컬 좌표, 내용 영역 왼쪽 위가 원점)Graphic to draw with. (node local coordinates, origin at the top-left of the content area)
0~1 비율 반환.
Returns the 0~1 ratio.
반환Returnsnumber 범위 안에서 값의 비율. (0 ~ 1, 범위가 0 이하면 0)Ratio of the value within the range. (0 ~ 1, 0 if the range is 0 or less)
짝Counterpart: vanilla-engine UIProgressView.get_ratio
값 설정.
Sets the value.
- valuenumber
- 값. (최소 ~ 최대로 자른다)Value. (clamped to minimum ~ maximum)
짝Counterpart: vanilla-engine UIProgressView.set_value
값 반환.
Returns the value.
반환Returnsnumber 범위로 자른 값.Value clamped to the range.
짝Counterpart: vanilla-engine UIProgressView.get_value
최소~최대 값 범위 설정.
Sets the minimum~maximum value range.
- minValuenumber
- 최소 값. (비율 0)Minimum value. (ratio 0)
- maxValuenumber
- 최대 값. (비율 1, 최소 이하면 비율이 늘 0)Maximum value. (ratio 1, the ratio is always 0 if it is not above the minimum)
짝Counterpart: vanilla-engine UIProgressView.set_range
최소 값 반환.
Returns the minimum value.
반환Returnsnumber 범위의 최소 값.Minimum value of the range.
짝Counterpart: vanilla-engine UIProgressView.get_min_value
최대 값 반환.
Returns the maximum value.
반환Returnsnumber 범위의 최대 값.Maximum value of the range.
짝Counterpart: vanilla-engine UIProgressView.get_max_value
반대편 값 설정. (null 이면 끔, 진행 방향의 반대쪽 끝에서 차오른다)
Sets the opposite value. (off if null, fills from the end opposite the progress direction)
- secondaryValuenumber | null
- 반대편 값. (최소 ~ 최대로 자른다, null 이면 끈다)Opposite value. (clamped to minimum ~ maximum, null turns it off)
짝Counterpart: vanilla-engine UIProgressView.set_secondary_value
import { UIProgressView, Color } from "./build/vanilla.js";
const progressView = new UIProgressView();
progressView.setRange(0, 100);
progressView.setValue(40);
progressView.setSecondaryValue(35);
progressView.setSecondaryFillColor(new Color(0.94, 0.33, 0.31, 1));
const secondaryValue = progressView.getSecondaryValue();
console.log(secondaryValue);
progressView.setSecondaryValue(null);반대편 값 반환.
Returns the opposite value.
반환Returnsnumber | null 반대편 값. (끈 상태면 null)Opposite value. (null when off)
짝Counterpart: vanilla-engine UIProgressView.get_secondary_value
반대편 채움 색 설정.
Sets the opposite fill color.
- colorColor | string
- 반대편 채움 색. (복제하지 않고 그대로 쥔다)Opposite fill color. (kept as is, not cloned)
짝Counterpart: vanilla-engine UIProgressView.set_secondary_fill_color
반대편 채움 색 반환.
Returns the opposite fill color.
반환ReturnsColor 반대편 채움 색.Opposite fill color.
짝Counterpart: vanilla-engine UIProgressView.get_secondary_fill_color
트랙 색 설정.
Sets the track color.
- colorColor | string
- 트랙 색. (UIView 의 배경 색으로 넣는다)Track color. (set as the UIView background color)
짝Counterpart: vanilla-engine UIProgressView.set_track_color
트랙 색 반환.
Returns the track color.
반환ReturnsColor 트랙 색. (UIView 의 배경 색)Track color. (the UIView background color)
짝Counterpart: vanilla-engine UIProgressView.get_track_color
채움 색.
Fill color.
- colorColor | string
- 채움 색. (복제하지 않고 그대로 쥔다)Fill color. (kept as is, not cloned)
짝Counterpart: vanilla-engine UIProgressView.set_fill_color
채움 색 반환.
Returns the fill color.
반환ReturnsColor 채움 색.Fill color.
짝Counterpart: vanilla-engine UIProgressView.get_fill_color
라운드 코너 반지름.
Rounded corner radius.
- radiusnumber
- 반지름. (픽셀, 0 이하면 네모로 그린다)Radius. (pixels, drawn as a plain rectangle if 0 or less)
짝Counterpart: vanilla-engine UIProgressView.set_corner_radius
라운드 코너 반지름 반환.
Returns the rounded corner radius.
반환Returnsnumber 반지름. (픽셀)Radius. (pixels)
짝Counterpart: vanilla-engine UIProgressView.get_corner_radius
방향. (ProgressDirection.horizontal / vertical)
Direction. (ProgressDirection.horizontal / vertical)
- directionstring
- "horizontal" 이면 왼쪽에서 오른쪽, "vertical" 이면 아래에서 위로 채운다."horizontal" fills from left to right, "vertical" fills from bottom to top.
짝Counterpart: vanilla-engine UIProgressView.set_direction
방향 반환.
Returns the direction.
반환Returnsstring "horizontal" 이나 "vertical"."horizontal" or "vertical".
짝Counterpart: vanilla-engine UIProgressView.get_direction
ProgressDirectionenum
진행률 방향.
Progress direction.
| 이름Name | 값Value | 설명Description |
|---|---|---|
horizontal | horizontal | 좌→우 채움Fills left to right |
vertical | vertical | 하→상 채움Fills bottom to top |