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

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

Component that draws only a border. (rounded rectangle border or circle border)

## Outline extends Component

Component that draws only a border. (rounded rectangle border or circle border)
- Paint only fills the inside, so this is used to put a separate border on top of a translucent panel. (stacking two filled panels mixes the outer color into the translucent inside)
- The rounded rectangle border is drawn at the node's content size as is, and the circle border is drawn at its center with half the shorter side as the radius.
- The line stays inside the content size. (the line's center is inset by half the thickness)

Example: Put an outline on a translucent panel

```js
import { Engine, EngineConfiguration, Scene, Vector2, WorldNode, Paint, Outline } from "./build/vanilla.js";

class MainScene extends Scene {
	async load(engine) {
		await super.load(engine);
		const root = this.getRoot();
		const panelNode = new WorldNode();
		panelNode.setContentSize(Vector2.create(240, 140));
		panelNode.setLocalPosition(Vector2.create(200, 180));
		const paint = panelNode.addComponent(Paint);
		paint.setColor("rgba(0, 0, 0, 0.5)");
		paint.setRoundSize(20);
		const outline = panelNode.addComponent(Outline);
		outline.setColor("#ffffff");
		outline.setLineWidth(4);
		outline.setRoundSize(20);
		root.addChild(panelNode);

		const ringNode = new WorldNode();
		ringNode.setContentSize(Vector2.create(100, 100));
		ringNode.setLocalPosition(Vector2.create(480, 180));
		const ring = ringNode.addComponent(Outline);
		ring.setColor("#ffcc00");
		ring.setLineWidth(6);
		ring.setCircle(true);
		root.addChild(ringNode);
	}
}

const engineConfiguration = new EngineConfiguration();
engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
```

- `constructor()` (constructor, since 0.4.0): Constructor.
- `draw(graphic)` (method, since 0.4.0): Draw.
  - `graphic` Graphic: Graphics.
- `isDrawnInsideContent()` (method, since 0.4.0): Returns whether it draws only inside the content area. (the line is drawn inset inside the content size by half the thickness)
  - false for subclasses that override draw, since where they draw is unknown.
  - returns boolean: True if drawing only inside the content area.
- `setColor(other)` (method, since 0.4.0): Sets the color.
  - `other` Color | string: Outline color. (a Color or a "#rrggbb(aa)" or "rgb(a)(...)" string, transparent if null or undefined, other values are ignored)
- `getColor()` (method, since 0.4.0): Returns the color.
  - returns Color: Outline color.
- `setLineWidth(lineWidth)` (method, since 0.4.0): Sets the thickness.
  - `lineWidth` number: Outline width. (content size units, not drawn if 0 or less)
- `getLineWidth()` (method, since 0.4.0): Returns the thickness.
  - returns number: Outline width.
- `setRoundSize(roundSize)` (method, since 0.4.0): Sets the corner roundness. (based on the outer shape)
  - `roundSize` number: Corner radius of the outer shape. (content size units, unused for a circle outline)
- `getRoundSize()` (method, since 0.4.0): Returns the corner roundness.
  - returns number: Corner radius of the outer shape.
- `setCircle(isCircle)` (method, since 0.4.0): Sets whether to draw as a circle border.
  - `isCircle` boolean: A circle outline if true, a rounded rectangle outline if false.
- `isCircle()` (method, since 0.4.0): Returns whether it is a circle border.
  - returns boolean: True if it is a circle outline.
