vanilladocs
vanillapunch.com
API / core/component/paint

core/component/paint

내용의 색상과 투명도를 결정하는 컴포넌트.

Component that determines the color and opacity of the content.

Paintextends Component

짝Counterpart: vanilla-engine Paint

내용의 색상과 투명도를 결정하는 컴포넌트.

Component that determines the color and opacity of the content.

예제Example둥근 판 하나 칠하기Fill one rounded panel
import { Engine, EngineConfiguration, Scene, Vector2, WorldNode, Paint } from "./build/vanilla.js";

class MainScene extends Scene {
	async load(engine) {
		await super.load(engine);
		const node = new WorldNode();
		node.setContentSize(Vector2.create(200, 120));
		node.setLocalPosition(Vector2.create(320, 180));
		const paint = node.addComponent(Paint);
		paint.setColor("#3366ff");
		paint.setRoundSize(16);
		const root = this.getRoot();
		root.addChild(node);
	}
}

const engineConfiguration = new EngineConfiguration();
engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
생성자constructorconstructor()#0.2.0 부터since 0.2.0소스source

생성.

Constructor.

짝Counterpart: vanilla-engine Paint.new

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

출력.

Draw.

graphicGraphic
그래픽.Graphics.
메서드methodisDrawnInsideContent()#0.4.0 부터since 0.4.0소스source

내용 영역 안에서만 그리는지 반환. (내용 크기의 사각형만 칠한다)

  • draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false. (그 클래스가 이 함수도 덮어써 알린다)

Returns whether it draws only inside the content area. (fills only the content-size rectangle)

  • false for subclasses that override draw, since where they draw is unknown. (that class overrides this function too to report it)

반환Returnsboolean 내용 영역 안에서만 그리면 참.True if drawing only inside the content area.

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

그리기 입력을 기하 캐시 열쇠에 적기. (색, 모서리 반지름, 내용 크기)

  • draw 를 덮어쓴 하위 클래스는 무엇을 읽는지 모르므로 false. (그 클래스가 이 함수도 덮어써 알린다)

Writes the draw inputs to the geometry cache key. (color, corner radius, content size)

  • A subclass that overrides draw returns false because what it reads is unknown. (that class overrides this function too to report them)
geometryKeyGeometryKey
입력을 적을 열쇠.Key to write the inputs to.

반환Returnsboolean 입력을 적었으면 참.True if the inputs were written.

메서드methodsetColor(other)#0.2.0 부터since 0.2.0소스source

색상 설정.

Sets the color.

otherColor | string | CanvasGradient | CanvasPattern
색. (Color 나 "#rrggbb(aa)", "rgb(a)(...)" 글, null 이나 undefined 면 투명, 그 밖의 값은 무시한다)Color. (a Color or a "#rrggbb(aa)" or "rgb(a)(...)" string, transparent if null or undefined, other values are ignored)

짝Counterpart: vanilla-engine Paint.set_color

메서드methodgetColor()#0.2.0 부터since 0.2.0소스source

색상 반환.

Returns the color.

반환ReturnsColor 색상.Color.

짝Counterpart: vanilla-engine Paint.get_color

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

라운드 크기 설정.

Sets the round size.

roundSizenumber
모서리 반지름. (내용 크기 단위, 0 이하면 각진 사각형, 짧은 변의 반을 넘으면 반으로 자른다)Corner radius. (content size units, a sharp rectangle if 0 or less, clamped to half of the shorter side)

짝Counterpart: vanilla-engine Paint.set_round_size

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

라운드 사이즈 반환.

Returns the round size.

반환Returnsnumber 모서리 반지름.Corner radius.

짝Counterpart: vanilla-engine Paint.get_round_size