core/component/mask
마스크 컴포넌트.
Mask component.
Maskextends Component
마스크 컴포넌트.
- 부착된 노드의 contentSize 영역으로 자식 노드들의 그리기를 클리핑한다.
- 실제 begin/end 호출은 노드의 draw 가 자식 그리기 직전/직후에 한다. (draw() 자체는 컴포넌트 출력 단계에서 호출되지만 아무것도 하지 않는다.)
Mask component.
- Clips the drawing of child nodes to the contentSize area of the attached node.
- The actual begin/end calls are made by the node's draw right before/after drawing children. (draw() itself is called in the component draw phase but does nothing.)
import { Engine, EngineConfiguration, Scene, Vector2, WorldNode, Paint, Mask } from "./build/vanilla.js";
class MainScene extends Scene {
async load(engine) {
await super.load(engine);
const windowNode = new WorldNode();
windowNode.setContentSize(Vector2.create(200, 200));
windowNode.setLocalPosition(Vector2.create(320, 180));
const paint = windowNode.addComponent(Paint);
paint.setColor("#223344");
paint.setRoundSize(24);
const mask = windowNode.addComponent(Mask);
mask.setRoundSize(24);
const root = this.getRoot();
root.addChild(windowNode);
const childNode = new WorldNode();
childNode.setContentSize(Vector2.create(160, 160));
childNode.setLocalPosition(Vector2.create(160, 160));
const childPaint = childNode.addComponent(Paint);
childPaint.setColor("#ff6633");
windowNode.addChild(childNode);
}
}
const engineConfiguration = new EngineConfiguration();
engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());클리핑 시작. (노드의 draw 가 자식 그리기 직전에 호출)
Starts clipping. (called by the node's draw right before drawing children)
- graphicGraphic
- 그래픽.Graphics.
짝Counterpart: vanilla-engine Mask.begin_clip
클리핑 종료. (노드의 draw 가 자식 그리기 직후에 호출)
Ends clipping. (called by the node's draw right after drawing children)
- graphicGraphic
- 그래픽.Graphics.
짝Counterpart: vanilla-engine Mask.end_clip
내용 영역 안에서만 그리는지 반환. (컴포넌트 출력 단계에서는 아무것도 그리지 않는다)
- 걸러져도 자식을 자르는 클립은 노드의 draw 가 그대로 건다.
- draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false.
Returns whether it draws only inside the content area. (draws nothing in the component draw phase)
- Even if culled, the node's draw still applies the clip that cuts children.
- false for subclasses that override draw, since where they draw is unknown.
반환Returnsboolean 내용 영역 안에서만 그리면 참.True if drawing only inside the content area.
둥근 모서리 반지름 설정. (Paint 의 roundSize 와 같은 값을 주면 배경 모양대로 잘린다)
Sets the rounded corner radius. (giving the same value as Paint's roundSize clips along the background shape)
- roundSizenumber
- 둥근 모서리 반지름. (내용 크기 단위, 음수는 0, 0 이면 사각형)Rounded corner radius. (content size units, negative becomes 0, a rectangle if 0)
짝Counterpart: vanilla-engine Mask.set_round_size
둥근 모서리 반지름 반환.
Returns the rounded corner radius.
반환Returnsnumber 둥근 모서리 반지름.Rounded corner radius.
짝Counterpart: vanilla-engine Mask.get_round_size