# misc/indicator (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/misc/indicator/

Indicator class.

## Indicator extends Object

Indicator class.

Example: Draw a spinning gear over a scene

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

const indicator = new Indicator();
indicator.setPosition(640, 360);
indicator.setRadius(32);
indicator.setColor("#ffd34dff");
indicator.setSpeed(Math.PI);

class IndicatorScene extends Scene {
	tick(timeDelta) {
		super.tick(timeDelta);
		indicator.tick(timeDelta);
	}

	draw(graphic) {
		super.draw(graphic);
		indicator.draw(graphic);
	}
}

const engineConfiguration = new EngineConfiguration();
engineConfiguration.referenceResolutionSize = Vector2.create(1280, 720);
const engine = new Engine(engineConfiguration);
engine.run(new IndicatorScene());
```

- `constructor()` (constructor, since 0.0.9): Constructor.
- `tick(timeDelta)` (method, since 0.0.9): Update.
  - `timeDelta` number: Time since the last frame. (seconds, does not spin while hidden)
- `draw(graphic)` (method, since 0.0.9): Draw.
  - `graphic` Graphic: Graphic to draw on. (draws nothing while hidden)
- `buildTeethSegments()` (method, since 0.4.0): Returns the list of gear tooth segments. (relative to the center before rotation, a list of [start, end])
  - returns Vector2[][]: List of [start, end] segments for the 8 teeth.
- `setPosition(x, y)` (method, since 0.0.9): Sets the position.
  - `x` number: Center x coordinate.
  - `y` number: Center y coordinate.
- `getPosition()` (method, since 0.0.9): Returns the position.
  - returns Vector2: Center position. (not a copy)
- `setRadius(radius)` (method, since 0.0.9): Sets the size.
  - `radius` number: Radius to the tooth tips. (1 if less than 1)
- `getRadius()` (method, since 0.4.0): Returns the volume.
  - returns number: Radius to the tooth tips.
- `setColor(color)` (method, since 0.0.9): Sets the color.
  - `color` string | Color: (e.g. "#ff0000", "rgba(255,255,255,0.8)")
- `setSpeed(speedRadiansPerSecond)` (method, since 0.0.9): Sets the rotation speed.
  - `speedRadiansPerSecond` number: Rotation speed. (radians per second, spins the other way if negative)
- `getRotation()` (method, since 0.4.0): Returns the current rotation angle. (radians)
  - returns number: Current rotation angle. (radians)
- `setVisible(isVisible)` (method, since 0.0.9): Sets whether it is displayed.
  - `isVisible` boolean: True if visible. (tick and draw do nothing when false)
- `getVisible()` (method, since 0.0.9): Returns whether it is displayed.
  - returns boolean: True if visible.
