# WideLine

Class · category: Graphics

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/extras/renderers/wide-line.js#L46

A connected, variable-width line rendered by a [WideLineRenderer](https://api.playcanvas.com/engine/classes/WideLineRenderer.md). Point data is supplied
using packed numeric arrays to avoid allocating an object for each point.

A WideLine can belong to at most one WideLineRenderer. Removing it from the renderer leaves the
WideLine intact, allowing it to be added to another renderer later.

## Accessors

### cap

```ts
get cap(): number
set cap(value: number)
```

Gets the cap style.

### closed

```ts
get closed(): boolean
set closed(value: boolean)
```

Gets whether the last point connects back to the first point.

### dashLength

```ts
get dashLength(): number
set dashLength(value: number)
```

Gets the length of each visible dash in world units.

### dashOffset

```ts
get dashOffset(): number
set dashOffset(value: number)
```

Gets the offset of the dash pattern in world units.

### gapLength

```ts
get gapLength(): number
set gapLength(value: number)
```

Gets the length of each gap in world units.

### join

```ts
get join(): number
set join(value: number)
```

Gets the join style.

### pointCount

```ts
get pointCount(): number
```

The number of points in the line. This is zero until [WideLine#set](https://api.playcanvas.com/engine/classes/WideLine.md#set) is called.

### renderer

```ts
get renderer(): WideLineRenderer | null
```

The renderer that owns this line, or null when the line is not being rendered.

## Methods

### set

```ts
set(positions: ArrayLike<number>, colors?: ArrayLike<number> | Color, widths?: number | ArrayLike<number>): WideLine
```

Atomically replaces all point data. This is the only operation that can change the number of
points. The colors and widths can each be supplied either per point or as a single uniform
value.

**Parameters**

- `positions` (`ArrayLike<number>`): Packed xyz coordinates. The length must be a multiple
  of three and contain at least two points.
- `colors` (`ArrayLike<number> |` [`Color`](https://api.playcanvas.com/engine/classes/Color.md), optional, default `Color.WHITE`): Packed rgb values with one color per point, or a
  single color used by every point. The alpha component of a [Color](https://api.playcanvas.com/engine/classes/Color.md) is ignored.
- `widths` (`number | ArrayLike<number>`, optional, default `1`): One width per point, or a single width used by
  every point. Width units are selected by the owning [WideLineRenderer](https://api.playcanvas.com/engine/classes/WideLineRenderer.md) and values must
  be non-negative.

**Returns** [`WideLine`](https://api.playcanvas.com/engine/classes/WideLine.md): This line.

### setColors

```ts
setColors(colors: ArrayLike<number> | Color): WideLine
```

Replaces colors without changing the number of points.

**Parameters**

- `colors` (`ArrayLike<number> |` [`Color`](https://api.playcanvas.com/engine/classes/Color.md)): Packed rgb values containing exactly
  `pointCount * 3` values, or a single color used by every point. The alpha component of a
  [Color](https://api.playcanvas.com/engine/classes/Color.md) is ignored.

**Returns** [`WideLine`](https://api.playcanvas.com/engine/classes/WideLine.md): This line.

### setPositions

```ts
setPositions(positions: ArrayLike<number>): WideLine
```

Replaces positions without changing the number of points.

**Parameters**

- `positions` (`ArrayLike<number>`): Packed xyz coordinates containing exactly
  `pointCount * 3` values.

**Returns** [`WideLine`](https://api.playcanvas.com/engine/classes/WideLine.md): This line.

### setWidths

```ts
setWidths(widths: number | ArrayLike<number>): WideLine
```

Replaces widths without changing the number of points.

**Parameters**

- `widths` (`number | ArrayLike<number>`): An array containing exactly `pointCount` values,
  or a single width used by every point. Width units are selected by the owning
  [WideLineRenderer](https://api.playcanvas.com/engine/classes/WideLineRenderer.md) and values must be non-negative.

**Returns** [`WideLine`](https://api.playcanvas.com/engine/classes/WideLine.md): This line.
