# core/component/paint (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/core/component/paint/

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

## Paint extends Component

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

예제: 둥근 판 하나 칠하기

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

- `constructor()` (constructor, since 0.2.0): 생성.
- `draw(graphic)` (method, since 0.2.0): 출력.
  - `graphic` Graphic: 그래픽.
- `isDrawnInsideContent()` (method, since 0.4.0): 내용 영역 안에서만 그리는지 반환. (내용 크기의 사각형만 칠한다)
  - draw 를 덮어쓴 하위 클래스는 어디에 그리는지 모르므로 false. (그 클래스가 이 함수도 덮어써 알린다)
  - returns boolean: 내용 영역 안에서만 그리면 참.
- `writeGeometryKey(geometryKey)` (method, since 0.4.0): 그리기 입력을 기하 캐시 열쇠에 적기. (색, 모서리 반지름, 내용 크기)
  - draw 를 덮어쓴 하위 클래스는 무엇을 읽는지 모르므로 false. (그 클래스가 이 함수도 덮어써 알린다)
  - `geometryKey` GeometryKey: 입력을 적을 열쇠.
  - returns boolean: 입력을 적었으면 참.
- `setColor(other)` (method, since 0.2.0): 색상 설정.
  - `other` Color | string | CanvasGradient | CanvasPattern: 색. (Color 나 "#rrggbb(aa)", "rgb(a)(...)" 글, null 이나 undefined 면 투명, 그 밖의 값은 무시한다)
- `getColor()` (method, since 0.2.0): 색상 반환.
  - returns Color: 색상.
- `setRoundSize(roundSize)` (method, since 0.2.0): 라운드 크기 설정.
  - `roundSize` number: 모서리 반지름. (내용 크기 단위, 0 이하면 각진 사각형, 짧은 변의 반을 넘으면 반으로 자른다)
- `getRoundSize()` (method, since 0.3.0): 라운드 사이즈 반환.
  - returns number: 모서리 반지름.
