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

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

Component that determines the color and opacity of the content.

## Paint extends Component

Component that determines the color and opacity of the content.

Example: Fill one rounded panel

```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): Constructor.
- `draw(graphic)` (method, since 0.2.0): Draw.
  - `graphic` Graphic: Graphics.
- `isDrawnInsideContent()` (method, since 0.4.0): 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)
  - returns boolean: True if drawing only inside the content area.
- `writeGeometryKey(geometryKey)` (method, since 0.4.0): 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)
  - `geometryKey` GeometryKey: Key to write the inputs to.
  - returns boolean: True if the inputs were written.
- `setColor(other)` (method, since 0.2.0): Sets the color.
  - `other` Color | string | CanvasGradient | CanvasPattern: Color. (a Color or a "#rrggbb(aa)" or "rgb(a)(...)" string, transparent if null or undefined, other values are ignored)
- `getColor()` (method, since 0.2.0): Returns the color.
  - returns Color: Color.
- `setRoundSize(roundSize)` (method, since 0.2.0): Sets the round size.
  - `roundSize` number: Corner radius. (content size units, a sharp rectangle if 0 or less, clamped to half of the shorter side)
- `getRoundSize()` (method, since 0.3.0): Returns the round size.
  - returns number: Corner radius.
