GpuTexture
Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.
Up and coming
Pictures that live on the graphics card: shaders draw into them, and you read, save or show them.
Make one with GpuService:CreateTextureAsync or LoadTextureAsync, or take the one a ShaderProgram, ImageProcessor or MeshBatch render drew. ReadAsync gives RGBA8 bytes back, supersampled when you ask for a smaller size; SaveAsync writes a PNG; ToIcon shows it in an ImageLabel with no file in between. Destroy frees its GPU memory.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| Size | Vector2 | read-only | Width and height in pixels; read-only. |
| Format | TextureFormat | read-only | Read-only: RGBA8, or RGBA32F, the default. |
| Filter | TextureFilter | Linear, or Nearest for pixel art. |
Methods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| WriteAsync yields | (pixels: buffer) | (boolean, string?) | Writes RGBA8 bytes into the texture, left to right and top to bottom, and waits for the upload. |
| ReadAsync yields | (size: Vector2?) | (buffer?, string?) | Reads the pixels back as RGBA8 bytes; a smaller size is box-filtered with alpha weighting, so a 4x drawing reads back supersampled. |
| SaveAsync yields | (path: string | PathHandler) | (boolean, string?) | Saves the texture as a PNG file and waits until it is written. |
| CloneAsync yields | () | (GpuTexture?, string?) | |
| ResizeAsync yields | (size: Vector2, filter: "Nearest" | "Box" | "Lanczos") | (boolean, string?) | |
| CropAsync yields | (rect: Rect) | (boolean, string?) | |
| GetContentBoundsAsync yields | (alphaAbove: number?) | (Rect?, string?) | Returns the box around every pixel whose alpha is above the threshold, for trimming a sprite or a render. |
| GetRangeAsync yields | () | ({ Min: { number }, Max: { number } }?, string?) | Returns each channel's minimum and maximum over the opaque pixels, for normalising a height pass. |
| ToIcon | () | Icon | Returns an Icon for an ImageLabel's Image that shows the texture with no file saved in between. |
Events
| Name | Passes | Description |
|---|---|---|
| ContentChanged | () | Fires when a ShaderProgram, an ImageProcessor or WriteAsync writes into the texture; an ImageLabel showing it refreshes. |
From ShotInstance 33
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
