# Copy

interface in `@dioramajs/diorama/effects`

```ts
import type { Copy } from '@dioramajs/diorama/effects'
```

Control of one element's GL copy from outside its effects. Taken with `leave: 'ghost'`, the
copy is not parked or released when its element leaves the document. It becomes a ghost
owned by the taker. Every write requests a frame. One owner per element.

```ts
interface Copy
```

## Members

| Name | Type | Description |
| --- | --- | --- |
| `above` | `number` | Draw level over the page. Higher levels draw above lower ones, 0 is the page. Default 0. While a copy above 0 is drawn, a canvas under the page goes into the top layer, over the page. |
| `box` | `Box \| undefined` | Draws at this viewport box instead of the element's. CSS opacity is not followed while set. |
| `clip` | `Box \| undefined` | Clips to this viewport box instead of the clipping ancestor's. Undefined keeps the ancestor's, frozen relative to the copy's box once the element left or while `box` is set. |
| `crop` | `Crop \| undefined` | Region of the picture to show instead of object-fit and the effects' `surface.zoom`, in texture UV (y up). Undefined follows them. Lets an owner move the framing smoothly during a flight. |
| `cssOpacity` | `number` | CSS opacity of the element and its ancestors as last read, 1 before the first read. Frozen for a ghost. Still read while `box` is set, but not applied. |
| `drawable` | `boolean` | Can be drawn now: compiled (placed objects too while veiled) and media ready. |
| `drawn` | `DrawnBox \| undefined` | The last drawn frame, undefined if never drawn. Frozen for a ghost and while veiled. |
| `effects` | `readonly string[]` | In effect order. |
| `element` | `Element` | The element whose copy this is. |
| `leave` | `'ghost' \| 'release'` | When the element leaves the document, 'ghost' keeps the copy as a ghost and 'release' lets the effects go the usual way (parked, then released) and releases this copy. |
| `opacity` | `number` | Alpha multiplier 0..1. Default 1. |
| `posed` | `PosedBox \| undefined` | Where the element's effects pose this copy (`ctx.pose` on its layer) as of the last frame, worked out from the element's box even while `box` holds the copy elsewhere, so an owner can let go of it there without a jump. Undefined while not posed, and for a ghost. |
| `presence` | `number` | `u.presence` of the copy's effects, 0..1. Default 1. |
| `radius` | `number \| undefined` | border-radius override in px. Undefined keeps the element's, frozen once it left. |
| `ready` | `Promise<boolean>` | Resolves true once drawable, false if it never will be (failed, off, unavailable, released, or no records after a reconcile that saw the element connected). |
| `source` | `string` | `currentSrc` the texture shows, '' without media. |
| `state` | `CopyState` | 'none' means no drawable copy yet. 'ghost' means the element left and the copy lives on. |
| `veil` | `boolean` | Hides both the copy and the DOM (`data-dio-state="entering"`) while loading goes on. |
| `cropAt` | `cropAt(box: Box): Crop \| undefined` | The region object-fit and the effects' `surface.zoom` show in this box, undefined until the picture size is known. |
| `dispose` | `dispose(): void` | Same as release, so a copy works as a kernel `Cleanup`. |
| `release` | `release(): void` | Idempotent. A connected element's copy goes back to its DOM life, a ghost is released. |

Also exported from `@dioramajs/effects`.

Defined in [packages/effects/src/types.ts](https://github.com/MasterKurosava/diorama/blob/main/packages/effects/src/types.ts#L845).
